git-svn: remove leading slashes from fetch lines in the generate config
We were previously sensitive to leading slashes in the fetch lines and incorrectly writing them to the config if the user used them (needlessly) in the command-line. This fixes the issue and allows us to play nicely with legacy configs that have leading slashes in fetch lines. Thanks to Bradford Smith for figuring this out for me: > > This works: > > git-svn clone https://my.server.net/repos/path/ -Ttrunk/testing > -ttags/testing -bbranches/testing testing > > This doesn't: > > git-svn clone https://my.server.net/repos/path -T/trunk/testing > -t/tags/testing -b/branches/testing testing Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Jul 14, 2007 at 12:40 UTC
46cf98baa5a1d74a9d00dc1092b29e4af93e8615
1 file changed
+4
-1
git-svn.perl
+4
-1
@@ -1026,7 +1026,9 @@ sub read_all_remotes {
1026
my $r = {};
1027
foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
1028
if (m!^(.+)\.fetch=\s*(.*)\s*:\s*refs/remotes/(.+)\s*$!) {
1029
- $r->{$1}->{fetch}->{$2} = $3;
1029
+ my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
1030
+ $local_ref =~ s{^/}{};
1031
+ $r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
1032
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
1033
$r->{$1}->{url} = $2;
1034
} elsif (m!^(.+)\.(branches|tags)=
@@ -1146,6 +1148,7 @@ sub init_remote_config {
1148
unless ($no_write) {
1149
command_noisy('config',
1150
"svn-remote.$self->{repo_id}.url", $url);
1151
+ $self->{path} =~ s{^/}{};
1152
command_noisy('config', '--add',
1153
"svn-remote.$self->{repo_id}.fetch",
1154
"$self->{path}:".$self->refname);