line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::FastExport; |
2
|
|
|
|
|
|
|
$Git::FastExport::VERSION = '0.106'; |
3
|
5
|
|
|
5
|
|
34767
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
135
|
|
4
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
178
|
|
5
|
5
|
|
|
5
|
|
17
|
use Carp; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
462
|
|
6
|
5
|
|
|
5
|
|
30
|
use Scalar::Util qw( blessed ); |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
364
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
1815
|
use Git::Repository; |
|
5
|
|
|
|
|
69346
|
|
|
5
|
|
|
|
|
30
|
|
9
|
5
|
|
|
5
|
|
2754
|
use Git::FastExport::Block; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
3675
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $LF = "\012"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
62
|
|
|
62
|
1
|
1268
|
my ( $class, $handle ) = @_; |
15
|
62
|
|
|
|
|
625
|
return bless { stream => $handle }, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub next_block { |
19
|
1186
|
|
|
1186
|
1
|
11827
|
my ($self) = @_; |
20
|
1186
|
|
|
|
|
1779
|
my $fh = $self->{stream}; |
21
|
1186
|
100
|
|
|
|
2608
|
return if !defined $fh; |
22
|
|
|
|
|
|
|
|
23
|
1185
|
|
|
|
|
10980
|
my $block = bless {}, 'Git::FastExport::Block'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# pick up the header from the previous round, or read it (first time) |
26
|
1185
|
|
100
|
|
|
1807372
|
$self->{header} ||= <$fh>; |
27
|
1185
|
|
|
|
|
3640
|
$block->{header} = delete $self->{header}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# nothing left to process |
30
|
1185
|
100
|
|
|
|
3827
|
return if !defined $block->{header}; |
31
|
|
|
|
|
|
|
|
32
|
1125
|
|
|
|
|
2379
|
chomp $block->{header}; |
33
|
1125
|
|
|
|
|
7937
|
( $block->{type} ) = $block->{header} =~ /^(\w+)/g; |
34
|
|
|
|
|
|
|
|
35
|
1125
|
|
|
|
|
1681
|
local $_; |
36
|
1125
|
|
|
|
|
5712
|
while (<$fh>) { |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# we've reached the beginning of the next block |
39
|
3623
|
100
|
|
|
|
20094
|
if (/^(commit|tag|reset|blob|checkpoint|progress|feature|option|done)\b/) { |
40
|
1066
|
50
|
|
|
|
2824
|
s/^progress /progress [$self->{source}] / if exists $self->{source}; |
41
|
1066
|
|
|
|
|
1565
|
$self->{header} = $_; |
42
|
1066
|
|
|
|
|
1735
|
last; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
2557
|
|
|
|
|
2584
|
chomp; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# special case of data block |
48
|
2557
|
100
|
|
|
|
13261
|
if (/^data (.*)/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
49
|
485
|
50
|
|
|
|
1872
|
if ( substr( $1, 0, 2 ) eq '<<' ) { # Delimited format |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# 'data' SP '<<' LF |
52
|
|
|
|
|
|
|
# LF |
53
|
|
|
|
|
|
|
# LF |
54
|
|
|
|
|
|
|
# LF? |
55
|
0
|
|
|
|
|
0
|
my $delim = substr( $1, 2 ); |
56
|
0
|
|
|
|
|
0
|
local $/ = "$LF$delim$LF"; |
57
|
0
|
|
|
|
|
0
|
chomp( $block->{data} = <$fh> ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { # Exact byte count format |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# 'data' SP LF |
62
|
|
|
|
|
|
|
# LF? |
63
|
485
|
|
|
|
|
919
|
my $bytes = $1; |
64
|
485
|
50
|
|
|
|
726
|
if ($bytes) { |
65
|
485
|
|
|
|
|
2220
|
local $/ = \$bytes; |
66
|
485
|
|
|
|
|
3446
|
$block->{data} = <$fh>; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
|
|
|
|
0
|
$block->{data} = ""; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
elsif (/^(?:[MDRC] |deleteall)/) { |
74
|
220
|
|
|
|
|
217
|
push @{ $block->{files} }, $_; |
|
220
|
|
|
|
|
1332
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
elsif (/^(\w+)/) { |
77
|
1308
|
|
|
|
|
1155
|
push @{ $block->{$1} }, $_; |
|
1308
|
|
|
|
|
10042
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# ignore empty lines, but choke on others |
82
|
544
|
50
|
|
|
|
1824
|
die "Unexpected line:\n$_\n" if !/^$/; |
83
|
544
|
|
|
|
|
2413
|
$block->{footer} .= "\012"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# post-processing |
88
|
1125
|
100
|
|
|
|
3346
|
if ( $block->{type} eq 'commit' ) { |
89
|
|
|
|
|
|
|
( $block->{committer_date} ) |
90
|
258
|
|
|
|
|
2778
|
= $block->{committer}[0] =~ /^committer [^>]*> (\d+) [-+]\d+$/g; |
91
|
|
|
|
|
|
|
( $block->{author_date} ) |
92
|
258
|
|
|
|
|
1274
|
= $block->{author}[0] =~ /^author [^>]*> (\d+) [-+]\d+$/g; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1125
|
|
|
|
|
5118
|
return $block; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
'progress 1 objects'; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |