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

[PATCH 2/2] git svn: the branch command no longer needs the full path

From
EWEric Wong <normalperson@yhbt.net>
Date
Jul 25, 2009, 11:10 UTC
Message-ID
<20090725111044.GA7969@dcvr.yhbt.net>
In-Reply-To
<20090725103821.GA13534@dcvr.yhbt.net>

This was introduced in 0b2af457a49e3b00d47d556d5301934d27909db8 ("Fix branch detection when repository root is inaccessible") but reintroduced in the previous commit.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
  Also pushed out to git://git.bogomips.org/git-svn along with some
  other changes:
  # I removed the "-" in "git svn" in the pushed out version of
  # "git svn: revert default behavior for --minimize-url"
  Eric Wong (4):
        git svn: revert default behavior for --minimize-url
        git svn: the branch command no longer needs the full path
        t9142: remember to stop httpd if it was used
        git svn: avoid escaping '/' when renaming/copying files
  # I thought I had pushed this out earlier:
  Robert Allan Zeh (1):
        git svn: add gc command
 git-svn.perl                         |   19 ++++++++++++++++---
 t/t9141-git-svn-multiple-branches.sh |    8 ++++----
 2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 10b77ad..9808597 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -666,9 +666,22 @@ sub cmd_branch {
 			}
 		}
 		unless (defined $glob) {
-			die "Unknown ",
-			    $_tag ? "tag" : "branch",
-			    " destination $_branch_dest\n";
+			my $dest_re = qr/\b\Q$_branch_dest\E\b/;
+			foreach my $g (@{$allglobs}) {
+				$g->{path}->{left} =~ /$dest_re/ or next;
+				if (defined $glob) {
+					die "Ambiguous destination: ",
+					    $_branch_dest, "\nmatches both '",
+					    $glob->{path}->{left}, "' and '",
+					    $g->{path}->{left}, "'\n";
+				}
+				$glob = $g;
+			}
+			unless (defined $glob) {
+				die "Unknown ",
+				    $_tag ? "tag" : "branch",
+				    " destination $_branch_dest\n";
+			}
 		}
 	}
 	my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
index cb9a6d2..3cd0671 100755
--- a/t/t9141-git-svn-multiple-branches.sh
+++ b/t/t9141-git-svn-multiple-branches.sh
@@ -99,22 +99,22 @@ test_expect_success 'Multiple branch or tag paths require -d' '
 
 test_expect_success 'create new branches and tags' '
 	( cd git_project &&
-		git svn branch -m "New branch 1" -d project/b_one New1 ) &&
+		git svn branch -m "New branch 1" -d b_one New1 ) &&
 	( cd svn_project &&
 		svn_cmd up && test -e b_one/New1/a.file ) &&
 
 	( cd git_project &&
-		git svn branch -m "New branch 2" -d project/b_two New2 ) &&
+		git svn branch -m "New branch 2" -d b_two New2 ) &&
 	( cd svn_project &&
 		svn_cmd up && test -e b_two/New2/a.file ) &&
 
 	( cd git_project &&
-		git svn branch -t -m "New tag 1" -d project/tags_A Tag1 ) &&
+		git svn branch -t -m "New tag 1" -d tags_A Tag1 ) &&
 	( cd svn_project &&
 		svn_cmd up && test -e tags_A/Tag1/a.file ) &&
 
 	( cd git_project &&
-		git svn tag -m "New tag 2" -d project/tags_B Tag2 ) &&
+		git svn tag -m "New tag 2" -d tags_B Tag2 ) &&
 	( cd svn_project &&
 		svn_cmd up && test -e tags_B/Tag2/a.file )
 '
-- 
Eric Wong
Previous: Eric WongNext: Junio C Hamano
Message 6 of 12 in “[ANNOUNCE] GIT 1.6.4-rc2”
  1. Junio C HamanoJul 23, 2009
  2. Tony FinchJul 23, 2009
  3. Eric WongJul 24, 2009
  4. Junio C HamanoJul 24, 2009
  5. Eric WongJul 25, 2009
  6. 2/2 git svn: the branch command no longer needs the full pathEric Wong, Jul 25, 2009
  7. Junio C HamanoJul 26, 2009
  8. t9143: do not fail if Compress::Zlib is missingEric Wong, Jul 26, 2009
  9. Mattias NisslerJul 25, 2009
  10. Eric WongJul 25, 2009
  11. Mattias NisslerJul 25, 2009
  12. git svn: make minimize URL more reliable over http(s)Eric Wong, Jul 25, 2009

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.