/usr/share/perl5/Git/PurePerl/Loose.pm is in libgit-pureperl-perl 0.53-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package Git::PurePerl::Loose;
use Moose;
use MooseX::StrictConstructor;
use MooseX::Types::Path::Class;
use Compress::Zlib qw(compress uncompress);
use Path::Class;
use namespace::autoclean;
has 'directory' => (
is => 'ro',
isa => 'Path::Class::Dir',
required => 1,
coerce => 1
);
sub get_object {
my ( $self, $sha1 ) = @_;
my $filename
= file( $self->directory, substr( $sha1, 0, 2 ), substr( $sha1, 2 ) );
return unless -f $filename;
my $compressed = $filename->slurp( iomode => '<:raw' );
my $data = uncompress($compressed);
my ( $kind, $size, $content ) = $data =~ /^(\w+) (\d+)\0(.*)$/s;
return ( $kind, $size, $content );
}
sub put_object {
my ( $self, $object ) = @_;
my $filename = file(
$self->directory,
substr( $object->sha1, 0, 2 ),
substr( $object->sha1, 2 )
);
$filename->parent->mkpath;
my $compressed = compress( $object->raw );
my $fh = $filename->openw;
binmode($fh); #important for Win32
$fh->print($compressed) || die "Error writing to $filename: $!";
}
sub all_sha1s {
my $self = shift;
my $files = Data::Stream::Bulk::Path::Class->new(
dir => $self->directory,
only_files => 1,
);
return Data::Stream::Bulk::Filter->new(
filter => sub {
[ map { m{([a-z0-9]{2})[/\\]([a-z0-9]{38})}; $1 . $2 }
grep {m{[/\\][a-z0-9]{2}[/\\]}} @$_
];
},
stream => $files,
);
}
__PACKAGE__->meta->make_immutable;
|