git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
EWEric Wong <normalperson@yhbt.net>
Date
Jul 14, 2007, 19:40 UTC
Message-ID
<20070714194031.GA5160@soma>
In-Reply-To
<f158199e0707141159t290d3aa9g90c6799e98520f56@mail.gmail.com>

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:
Show 10 quoted lines
>
> 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>
---
 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
Previous: Bradford Smith
Message 4 of 4 in “git-svn: trunk missing, checks out tag instead”
  1. Bradford SmithJul 13, 2007
  2. Fwd: git-svn: trunk missing, checks out tag insteadBradford Smith, Jul 13, 2007
  3. Fwd: git-svn: trunk missing, checks out tag insteadBradford Smith, Jul 14, 2007
  4. git-svn: remove leading slashes from fetch lines in the generate configEric Wong, Jul 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.