Skip to content

Commit 7faf068

Browse files
Eric WongJunio C Hamano
authored andcommitted
git-svn: avoid md5 calculation entirely if SVN doesn't provide one
There's no point in calculating an MD5 if we're not going to use it. We'll also avoid the possibility of there being a bug in the Perl MD5 library not being able to handle zero-sized files. This is a followup to 20b3d20, which allows us to track repositories that do not provide MD5 checksums. Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb09626 commit 7faf068

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

git-svn.perl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,12 +2472,16 @@ sub close_file {
24722472
my $hash;
24732473
my $path = $self->git_path($fb->{path});
24742474
if (my $fh = $fb->{fh}) {
2475-
seek($fh, 0, 0) or croak $!;
2476-
my $md5 = Digest::MD5->new;
2477-
$md5->addfile($fh);
2478-
my $got = $md5->hexdigest;
2479-
die "Checksum mismatch: $path\n",
2480-
"expected: $exp\n got: $got\n" if (defined $exp && $got ne $exp);
2475+
if (defined $exp) {
2476+
seek($fh, 0, 0) or croak $!;
2477+
my $md5 = Digest::MD5->new;
2478+
$md5->addfile($fh);
2479+
my $got = $md5->hexdigest;
2480+
if ($got ne $exp) {
2481+
die "Checksum mismatch: $path\n",
2482+
"expected: $exp\n got: $got\n";
2483+
}
2484+
}
24812485
sysseek($fh, 0, 0) or croak $!;
24822486
if ($fb->{mode_b} == 120000) {
24832487
sysread($fh, my $buf, 5) == 5 or croak $!;

0 commit comments

Comments
 (0)