line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::Pack::WithIndex; |
2
|
4
|
|
|
4
|
|
20
|
use Moose; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
29
|
|
3
|
4
|
|
|
4
|
|
19750
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
37
|
|
4
|
4
|
|
|
4
|
|
9582
|
use namespace::autoclean; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Git::PurePerl::Pack'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'index_filename' => |
9
|
|
|
|
|
|
|
( is => 'rw', isa => 'Path::Class::File', required => 0, coerce => 1 ); |
10
|
|
|
|
|
|
|
has 'index' => |
11
|
|
|
|
|
|
|
( is => 'rw', isa => 'Git::PurePerl::PackIndex', required => 0 ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub BUILD { |
14
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
15
|
3
|
|
|
|
|
102
|
my $index_filename = $self->filename; |
16
|
3
|
|
|
|
|
10
|
$index_filename =~ s/\.pack/.idx/; |
17
|
3
|
|
|
|
|
235
|
$self->index_filename($index_filename); |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
33
|
|
|
16
|
my $index_fh = IO::File->new($index_filename) || confess($!); |
20
|
3
|
|
|
|
|
178
|
$index_fh->binmode(); |
21
|
3
|
|
|
|
|
39
|
$index_fh->read( my $signature, 4 ); |
22
|
3
|
|
|
|
|
56
|
$index_fh->read( my $version, 4 ); |
23
|
3
|
|
|
|
|
26
|
$version = unpack( 'N', $version ); |
24
|
3
|
|
|
|
|
16
|
$index_fh->close; |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
46
|
if ( $signature eq "\377tOc" ) { |
27
|
1
|
50
|
|
|
|
6
|
if ( $version == 2 ) { |
28
|
1
|
|
|
|
|
76
|
$self->index( |
29
|
|
|
|
|
|
|
Git::PurePerl::PackIndex::Version2->new( |
30
|
|
|
|
|
|
|
filename => $index_filename |
31
|
|
|
|
|
|
|
) |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
0
|
confess("Unknown version"); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} else { |
37
|
2
|
|
|
|
|
94
|
$self->index( |
38
|
|
|
|
|
|
|
Git::PurePerl::PackIndex::Version1->new( |
39
|
|
|
|
|
|
|
filename => $index_filename |
40
|
|
|
|
|
|
|
) |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_object { |
46
|
2318
|
|
|
2318
|
0
|
2613
|
my ( $self, $want_sha1 ) = @_; |
47
|
2318
|
|
|
|
|
63666
|
my $offset = $self->index->get_object_offset($want_sha1); |
48
|
2318
|
50
|
|
|
|
3386
|
return unless $offset; |
49
|
2318
|
|
|
|
|
6280
|
return $self->unpack_object($offset); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
53
|
|
|
|
|
|
|
|