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 <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
48d044b5fe
commit
e70dc780a4
14
git-svn.perl
14
git-svn.perl
@ -232,7 +232,7 @@ sub rebuild {
|
|||||||
my @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);
|
my @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);
|
||||||
next if (!@commit); # skip merges
|
next if (!@commit); # skip merges
|
||||||
my ($url, $rev, $uuid) = extract_metadata($commit[$#commit]);
|
my ($url, $rev, $uuid) = extract_metadata($commit[$#commit]);
|
||||||
if (!$rev || !$uuid) {
|
if (!defined $rev || !$uuid) {
|
||||||
croak "Unable to extract revision or UUID from ",
|
croak "Unable to extract revision or UUID from ",
|
||||||
"$c, $commit[$#commit]\n";
|
"$c, $commit[$#commit]\n";
|
||||||
}
|
}
|
||||||
@ -832,8 +832,14 @@ sub commit_diff {
|
|||||||
print STDERR "Needed URL or usable git-svn id command-line\n";
|
print STDERR "Needed URL or usable git-svn id command-line\n";
|
||||||
commit_diff_usage();
|
commit_diff_usage();
|
||||||
}
|
}
|
||||||
my $r = shift || $_revision;
|
my $r = shift;
|
||||||
die "-r|--revision is a required argument\n" unless (defined $r);
|
unless (defined $r) {
|
||||||
|
if (defined $_revision) {
|
||||||
|
$r = $_revision
|
||||||
|
} else {
|
||||||
|
die "-r|--revision is a required argument\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (defined $_message && defined $_file) {
|
if (defined $_message && defined $_file) {
|
||||||
print STDERR "Both --message/-m and --file/-F specified ",
|
print STDERR "Both --message/-m and --file/-F specified ",
|
||||||
"for the commit message.\n",
|
"for the commit message.\n",
|
||||||
@ -2493,7 +2499,7 @@ sub extract_metadata {
|
|||||||
my $id = shift or return (undef, undef, undef);
|
my $id = shift or return (undef, undef, undef);
|
||||||
my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
|
my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
|
||||||
\s([a-f\d\-]+)$/x);
|
\s([a-f\d\-]+)$/x);
|
||||||
if (!$rev || !$uuid || !$url) {
|
if (!defined $rev || !$uuid || !$url) {
|
||||||
# some of the original repositories I made had
|
# some of the original repositories I made had
|
||||||
# identifiers like this:
|
# identifiers like this:
|
||||||
($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
|
($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
|
||||||
|
Reference in New Issue
Block a user