@@ -909,7 +909,7 @@ sub cmd_multi_init {
909909 }
910910 do_git_init_db();
911911 if (defined $_trunk) {
912- my $trunk_ref = $_prefix . ' trunk' ;
912+ my $trunk_ref = ' refs/remotes/ ' . $_prefix . ' trunk' ;
913913 # try both old-style and new-style lookups:
914914 my $gs_trunk = eval { Git::SVN-> new($trunk_ref ) };
915915 unless ($gs_trunk ) {
@@ -1654,23 +1654,23 @@ sub resolve_local_globs {
16541654 return unless defined $glob_spec ;
16551655 my $ref = $glob_spec -> {ref };
16561656 my $path = $glob_spec -> {path };
1657- foreach (command(qw# for-each-ref --format=%(refname) refs/remotes # )) {
1658- next unless m # ^refs/remotes/ $ref ->{regex}$ # ;
1657+ foreach (command(qw# for-each-ref --format=%(refname) refs/# )) {
1658+ next unless m # ^$ref ->{regex}$ # ;
16591659 my $p = $1 ;
16601660 my $pathname = desanitize_refname($path -> full_path($p ));
16611661 my $refname = desanitize_refname($ref -> full_path($p ));
16621662 if (my $existing = $fetch -> {$pathname }) {
16631663 if ($existing ne $refname ) {
16641664 die " Refspec conflict:\n " ,
1665- " existing: refs/remotes/ $existing \n " ,
1666- " globbed: refs/remotes/ $refname \n " ;
1665+ " existing: $existing \n " ,
1666+ " globbed: $refname \n " ;
16671667 }
1668- my $u = (::cmt_metadata(" refs/remotes/ $refname " ))[0];
1668+ my $u = (::cmt_metadata(" $refname " ))[0];
16691669 $u =~ s ! ^\Q $url\E (/|$)!! or die
1670- " refs/remotes/ $refname : '$url ' not found in '$u '\n " ;
1670+ " $refname : '$url ' not found in '$u '\n " ;
16711671 if ($pathname ne $u ) {
16721672 warn " W: Refspec glob conflict " ,
1673- " (ref: refs/remotes/ $refname ):\n " ,
1673+ " (ref: $refname ):\n " ,
16741674 " expected path: $pathname \n " ,
16751675 " real path: $u \n " ,
16761676 " Continuing ahead with $u \n " ;
@@ -1748,33 +1748,35 @@ sub read_all_remotes {
17481748 my $use_svm_props = eval { command_oneline(qw/ config --bool
17491749 svn.useSvmProps/ ) };
17501750 $use_svm_props = $use_svm_props eq ' true' if $use_svm_props ;
1751+ my $svn_refspec = qr {\s */?(.*?)\s *:\s *(.+?)\s *} ;
17511752 foreach (grep { s / ^svn-remote\. // } command(qw/ config -l/ )) {
1752- if (m ! ^(.+)\. fetch=\s *(.*)\s *:\s *(.+)\s *$ ! ) {
1753- my ($remote , $local_ref , $_remote_ref) = ($1 , $2 , $3 );
1754- die (" svn-remote.$remote : remote ref '$_remote_ref' "
1755- . " must start with 'refs/remotes/'\n " )
1756- unless $_remote_ref =~ m { ^refs/remotes/(.+)} ;
1757- my $remote_ref = $1 ;
1758- $local_ref =~ s { ^/} {} ;
1753+ if (m ! ^(.+)\. fetch=$svn_refspec $ ! ) {
1754+ my ($remote , $local_ref , $remote_ref ) = ($1 , $2 , $3 );
1755+ die (" svn-remote.$remote : remote ref '$remote_ref ' "
1756+ . " must start with 'refs/'\n " )
1757+ unless $remote_ref =~ m { ^refs/} ;
17591758 $r -> {$remote }-> {fetch }-> {$local_ref } = $remote_ref ;
17601759 $r -> {$remote }-> {svm } = {} if $use_svm_props ;
17611760 } elsif (m ! ^(.+)\. usesvmprops=\s *(.*)\s *$ ! ) {
17621761 $r -> {$1 }-> {svm } = {};
17631762 } elsif (m ! ^(.+)\. url=\s *(.*)\s *$ ! ) {
17641763 $r -> {$1 }-> {url } = $2 ;
1765- } elsif (m ! ^(.+)\. (branches|tags)=
1766- (.*):refs/remotes/(.+)\s *$ /! x ) {
1767- my ($p , $g ) = ($3 , $4 );
1764+ } elsif (m ! ^(.+)\. (branches|tags)=$svn_refspec $ ! ) {
1765+ my ($remote , $t , $local_ref , $remote_ref ) =
1766+ ($1 , $2 , $3 , $4 );
1767+ die (" svn-remote.$remote : remote ref '$remote_ref ' ($t ) "
1768+ . " must start with 'refs/'\n " )
1769+ unless $remote_ref =~ m { ^refs/} ;
17681770 my $rs = {
1769- t => $2 ,
1770- remote => $1 ,
1771- path => Git::SVN::GlobSpec-> new($p ),
1772- ref => Git::SVN::GlobSpec-> new($g ) };
1771+ t => $t ,
1772+ remote => $remote ,
1773+ path => Git::SVN::GlobSpec-> new($local_ref ),
1774+ ref => Git::SVN::GlobSpec-> new($remote_ref ) };
17731775 if (length ($rs -> {ref }-> {right }) != 0) {
17741776 die " The '*' glob character must be the last " ,
1775- " character of '$g '\n " ;
1777+ " character of '$remote_ref '\n " ;
17761778 }
1777- push @{ $r -> {$1 }-> {$2 } }, $rs ;
1779+ push @{ $r -> {$remote }-> {$t } }, $rs ;
17781780 }
17791781 }
17801782
@@ -1882,9 +1884,9 @@ sub init_remote_config {
18821884 }
18831885 }
18841886 my ($xrepo_id , $xpath ) = find_ref($self -> refname);
1885- if (defined $xpath ) {
1887+ if (! $no_write && defined $xpath ) {
18861888 die " svn-remote.$xrepo_id .fetch already set to track " ,
1887- " $xpath :refs/remotes/ " , $self -> refname, " \n " ;
1889+ " $xpath :" , $self -> refname, " \n " ;
18881890 }
18891891 unless ($no_write ) {
18901892 command_noisy(' config' ,
@@ -1959,7 +1961,7 @@ sub find_ref {
19591961 my ($ref_id ) = @_ ;
19601962 foreach (command(qw/ config -l/ )) {
19611963 next unless m ! ^svn-remote\. (.+)\. fetch=
1962- \s *(.*)\s *:\s *refs/remotes/ (.+)\s *$ ! x ;
1964+ \s */? (.*? )\s *:\s *(.+? )\s *$ ! x ;
19631965 my ($repo_id , $path , $ref ) = ($1 , $2 , $3 );
19641966 if ($ref eq $ref_id ) {
19651967 $path = ' ' if ($path =~ m # ^\. /?# );
@@ -1976,16 +1978,16 @@ sub new {
19761978 if (!defined $repo_id ) {
19771979 die " Could not find a \" svn-remote.*.fetch\" key " ,
19781980 " in the repository configuration matching: " ,
1979- " refs/remotes/ $ref_id \n " ;
1981+ " $ref_id \n " ;
19801982 }
19811983 }
19821984 my $self = _new($class , $repo_id , $ref_id , $path );
19831985 if (!defined $self -> {path } || !length $self -> {path }) {
19841986 my $fetch = command_oneline(' config' , ' --get' ,
19851987 " svn-remote.$repo_id .fetch" ,
1986- " :refs/remotes/ $ref_id \$ " ) or
1988+ " :$ref_id \$ " ) or
19871989 die " Failed to read \" svn-remote.$repo_id .fetch\" " ,
1988- " \" :refs/remotes/ $ref_id \$\" in config\n " ;
1990+ " \" :$ref_id \$\" in config\n " ;
19891991 ($self -> {path }, undef ) = split (/ \s *:\s */ , $fetch );
19901992 }
19911993 $self -> {url } = command_oneline(' config' , ' --get' ,
@@ -1996,7 +1998,7 @@ sub new {
19961998}
19971999
19982000sub refname {
1999- my ($refname ) = " refs/remotes/ $_ [0]->{ref_id}" ;
2001+ my ($refname ) = $_ [0]-> {ref_id } ;
20002002
20012003 # It cannot end with a slash /, we'll throw up on this because
20022004 # SVN can't have directories with a slash in their name, either:
@@ -3331,12 +3333,23 @@ sub _new {
33313333 }
33323334 unless (defined $ref_id && length $ref_id ) {
33333335 $_prefix = ' ' unless defined ($_prefix);
3334- $_ [2] = $ref_id = $_prefix . $Git::SVN::default_ref_id ;
3336+ $_ [2] = $ref_id =
3337+ " refs/remotes/$_prefix$Git::SVN::default_ref_id " ;
33353338 }
33363339 $_ [1] = $repo_id ;
33373340 my $dir = " $ENV {GIT_DIR}/svn/$ref_id " ;
3341+
3342+ # Older repos imported by us used $GIT_DIR/svn/foo instead of
3343+ # $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo
3344+ if ($ref_id =~ m { ^refs/remotes/(.*)} ) {
3345+ my $old_dir = " $ENV {GIT_DIR}/svn/$1 " ;
3346+ if (-d $old_dir && ! -d $dir ) {
3347+ $dir = $old_dir ;
3348+ }
3349+ }
3350+
33383351 $_ [3] = $path = ' ' unless (defined $path );
3339- mkpath([" $ENV {GIT_DIR}/svn " ]);
3352+ mkpath([$dir ]);
33403353 bless {
33413354 ref_id => $ref_id , dir => $dir , index => " $dir /index" ,
33423355 path => $path , config => " $ENV {GIT_DIR}/svn/config" ,
@@ -5509,7 +5522,7 @@ sub minimize_connections {
55095522 my $pfx = " svn-remote.$x ->{old_repo_id}" ;
55105523
55115524 my $old_fetch = quotemeta (" $x ->{old_path}:" .
5512- " refs/remotes/ $x ->{ref_id}" );
5525+ " $x ->{ref_id}" );
55135526 command_noisy(qw/ config --unset/ ,
55145527 " $pfx .fetch" , ' ^' . $old_fetch . ' $' );
55155528 delete $r -> {$x -> {old_repo_id }}->
@@ -5578,7 +5591,7 @@ sub new {
55785591 my ($class , $glob ) = @_ ;
55795592 my $re = $glob ;
55805593 $re =~ s ! /+$!! g ; # no need for trailing slashes
5581- $re =~ m ! ^([^*]*)(\* (?:/\* )*)([^*] *)$ ! ;
5594+ $re =~ m ! ^([^*]*)(\* (?:/\* )*)(. *)$ ! ;
55825595 my $temp = $re ;
55835596 my ($left , $right ) = ($1 , $3 );
55845597 $re = $2 ;
0 commit comments