git svn: allow uppercase UUIDs from SVN

SVN allows uppercase A-F characters in repositories.  Although
`svnadmin' does not create UUIDs with uppercase by default, it
is possible to change the UUID of a SVN repository and SVN
itself will make no attempt to normalize them.

Thanks to Esben Skovenborg for discovering this issue.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
Eric Wong 2009-07-11 14:13:12 -07:00
parent 0b2af457a4
commit b3e9593627

View file

@ -1359,11 +1359,11 @@ sub read_repo_config {
sub extract_metadata { sub extract_metadata {
my $id = shift or return (undef, undef, undef); my $id = shift or return (undef, undef, undef);
my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+) my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+)
\s([a-f\d\-]+)$/x); \s([a-f\d\-]+)$/ix);
if (!defined $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 =~/^\s*git-svn-id:\s(\d+)\@([a-f\d\-]+)/); ($rev, $uuid) = ($id =~/^\s*git-svn-id:\s(\d+)\@([a-f\d\-]+)/i);
} }
return ($url, $rev, $uuid); return ($url, $rev, $uuid);
} }
@ -2010,7 +2010,7 @@ sub _set_svm_vars {
chomp($src, $uuid); chomp($src, $uuid);
$uuid =~ m{^[0-9a-f\-]{30,}$} $uuid =~ m{^[0-9a-f\-]{30,}$}i
or die "doesn't look right - svm:uuid is '$uuid'\n"; or die "doesn't look right - svm:uuid is '$uuid'\n";
# the '!' is used to mark the repos_root!/relative/path # the '!' is used to mark the repos_root!/relative/path
@ -2096,7 +2096,7 @@ sub svnsync {
die "doesn't look right - svn:sync-from-url is '$url'\n"; die "doesn't look right - svn:sync-from-url is '$url'\n";
my $uuid = tmp_config('--get', "$section.svnsync-uuid"); my $uuid = tmp_config('--get', "$section.svnsync-uuid");
($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}) or ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}i) or
die "doesn't look right - svn:sync-from-uuid is '$uuid'\n"; die "doesn't look right - svn:sync-from-uuid is '$uuid'\n";
$svnsync = { url => $url, uuid => $uuid } $svnsync = { url => $url, uuid => $uuid }
@ -2114,7 +2114,7 @@ sub svnsync {
die "doesn't look right - svn:sync-from-url is '$url'\n"; die "doesn't look right - svn:sync-from-url is '$url'\n";
my $uuid = $rp->{'svn:sync-from-uuid'} or die $err . "uuid\n"; my $uuid = $rp->{'svn:sync-from-uuid'} or die $err . "uuid\n";
($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}) or ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}i) or
die "doesn't look right - svn:sync-from-uuid is '$uuid'\n"; die "doesn't look right - svn:sync-from-uuid is '$uuid'\n";
my $section = "svn-remote.$self->{repo_id}"; my $section = "svn-remote.$self->{repo_id}";
@ -2130,7 +2130,7 @@ sub ra_uuid {
unless ($self->{ra_uuid}) { unless ($self->{ra_uuid}) {
my $key = "svn-remote.$self->{repo_id}.uuid"; my $key = "svn-remote.$self->{repo_id}.uuid";
my $uuid = eval { tmp_config('--get', $key) }; my $uuid = eval { tmp_config('--get', $key) };
if (!$@ && $uuid && $uuid =~ /^([a-f\d\-]{30,})$/) { if (!$@ && $uuid && $uuid =~ /^([a-f\d\-]{30,})$/i) {
$self->{ra_uuid} = $uuid; $self->{ra_uuid} = $uuid;
} else { } else {
die "ra_uuid called without URL\n" unless $self->{url}; die "ra_uuid called without URL\n" unless $self->{url};
@ -2848,7 +2848,7 @@ sub make_log_entry {
die "Can't have both 'useSvmProps' and 'rewriteRoot' ", die "Can't have both 'useSvmProps' and 'rewriteRoot' ",
"options set!\n"; "options set!\n";
} }
my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}; my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}i;
# we don't want "SVM: initializing mirror for junk" ... # we don't want "SVM: initializing mirror for junk" ...
return undef if $r == 0; return undef if $r == 0;
my $svm = $self->svm; my $svm = $self->svm;