Skip to content

Commit e70dc78

Browse files
Eric WongJunio C Hamano
authored andcommitted
git-svn: correctly handle revision 0 in SVN repositories
some SVN repositories have a revision 0 (committed by no author and no date) when created; so when we need to ensure that we check any revision variables are defined, and not just non-zero. Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48d044b commit e70dc78

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

git-svn.perl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ sub rebuild {
232232
my @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);
233233
next if (!@commit); # skip merges
234234
my ($url, $rev, $uuid) = extract_metadata($commit[$#commit]);
235-
if (!$rev || !$uuid) {
235+
if (!defined $rev || !$uuid) {
236236
croak "Unable to extract revision or UUID from ",
237237
"$c, $commit[$#commit]\n";
238238
}
@@ -832,8 +832,14 @@ sub commit_diff {
832832
print STDERR "Needed URL or usable git-svn id command-line\n";
833833
commit_diff_usage();
834834
}
835-
my $r = shift || $_revision;
836-
die "-r|--revision is a required argument\n" unless (defined $r);
835+
my $r = shift;
836+
unless (defined $r) {
837+
if (defined $_revision) {
838+
$r = $_revision
839+
} else {
840+
die "-r|--revision is a required argument\n";
841+
}
842+
}
837843
if (defined $_message && defined $_file) {
838844
print STDERR "Both --message/-m and --file/-F specified ",
839845
"for the commit message.\n",
@@ -2493,7 +2499,7 @@ sub extract_metadata {
24932499
my $id = shift or return (undef, undef, undef);
24942500
my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
24952501
\s([a-f\d\-]+)$/x);
2496-
if (!$rev || !$uuid || !$url) {
2502+
if (!defined $rev || !$uuid || !$url) {
24972503
# some of the original repositories I made had
24982504
# identifiers like this:
24992505
($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);

0 commit comments

Comments
 (0)