[PATCH] git-svn: remove leading slashes from fetch lines in the generate config

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Wong
Date: Saturday, July 14, 2007 - 12:40 pm

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:

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index b3dffcc..299b40f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1026,7 +1026,9 @@ sub read_all_remotes {
 	my $r = {};
 	foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
 		if (m!^(.+)\.fetch=\s*(.*)\s*:\s*refs/remotes/(.+)\s*$!) {
-			$r->{$1}->{fetch}->{$2} = $3;
+			my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
+			$local_ref =~ s{^/}{};
+			$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
 		} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
 			$r->{$1}->{url} = $2;
 		} elsif (m!^(.+)\.(branches|tags)=
@@ -1146,6 +1148,7 @@ sub init_remote_config {
 	unless ($no_write) {
 		command_noisy('config',
 			      "svn-remote.$self->{repo_id}.url", $url);
+		$self->{path} =~ s{^/}{};
 		command_noisy('config', '--add',
 			      "svn-remote.$self->{repo_id}.fetch",
 			      "$self->{path}:".$self->refname);
-- 
Eric Wong
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git-svn: remove leading slashes from fetch lines i ..., Eric Wong, (Sat Jul 14, 12:40 pm)