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

[PATCH 1/3] Fix multi-glob assertion in git-svn

From
EWEric Wong <normalperson@yhbt.net>
Date
Aug 8, 2008, 08:56 UTC
Message-ID
<20080808085655.GA9479@untitled>
In-Reply-To
<20080808084025.GA8718@untitled>
From: Marcus Griep <marcus@griep.us>
Date: Thu, 7 Aug 2008 11:34:01 -0400
Subject: [PATCH 1/3] Fix multi-glob assertion in git-svn

Fixes bad regex match check for multiple globs (would always return one glob regardless of actual number).

[ew: fixed a bashism in the test and some minor line-wrapping]
Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
 Oops, resent as I forgot to change the From: header
 git-svn.perl            |    5 +++--
 t/t9108-git-svn-glob.sh |   21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 06a82c8..503a7c9 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4915,14 +4915,15 @@ sub new {
 	my ($class, $glob) = @_;
 	my $re = $glob;
 	$re =~ s!/+$!!g; # no need for trailing slashes
-	my $nr = ($re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g);
-	my ($left, $right) = ($1, $2);
+	my $nr = $re =~ tr/*/*/;
 	if ($nr > 1) {
 		die "Only one '*' wildcard expansion ",
 		    "is supported (got $nr): '$glob'\n";
 	} elsif ($nr == 0) {
 		die "One '*' is needed for glob: '$glob'\n";
 	}
+	$re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g;
+	my ($left, $right) = ($1, $2);
 	$re = quotemeta($left) . $re . quotemeta($right);
 	if (length $left && !($left =~ s!/+$!!g)) {
 		die "Missing trailing '/' on left side of: '$glob' ($left)\n";
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index f6f71d0..a6f88bd 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -83,4 +83,25 @@ test_expect_success 'test left-hand-side only globbing' '
 	cmp expect.two output.two
 	'
 
+echo "Only one '*' wildcard expansion is supported (got 2): 'branches/*/*'" \
+     > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multi-globs' '
+	git config --add svn-remote.three.url "$svnrepo" &&
+	git config --add svn-remote.three.fetch \
+	                 trunk:refs/remotes/three/trunk &&
+	git config --add svn-remote.three.branches \
+	                 "branches/*/*:refs/remotes/three/branches/*" &&
+	git config --add svn-remote.three.tags \
+	                 "tags/*/*:refs/remotes/three/tags/*" &&
+	cd tmp &&
+		echo "try try" >> tags/end/src/b/readme &&
+		poke tags/end/src/b/readme &&
+		svn commit -m "try to try"
+		cd .. &&
+	test_must_fail git-svn fetch three 2> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
 test_done
-- 
1.6.0.rc2.4.g0643f
Previous: Eric WongNext: Eric Wong
Message 13 of 14 in “git-svn: Allow deep branch names by supporting multi-globs”
  1. 2/2 git-svn: Allow deep branch names by supporting multi-globsMarcus Griep, Aug 6, 2008
  2. Eric WongAug 7, 2008
  3. 0/2 git-svn multi-glob fix and extensionMarcus Griep, Aug 7, 2008
  4. 1/2 Fix multi-glob assertion in git-svnMarcus Griep, Aug 7, 2008
  5. 2/2 git-svn: Allow deep branch names by supporting multi-globsMarcus Griep, Aug 7, 2008
  6. Eric WongAug 8, 2008
  7. 1/3 Fix multi-glob assertion in git-svnEric Wong, Aug 8, 2008
  8. Junio C HamanoAug 8, 2008
  9. Eric WongAug 9, 2008
  10. Junio C HamanoAug 9, 2008
  11. 2/3 git-svn: Allow deep branch names by supporting multi-globsEric Wong, Aug 8, 2008
  12. 3/3 git-svn: wrap long lines in a few placesEric Wong, Aug 8, 2008
  13. 1/3 Fix multi-glob assertion in git-svnEric Wong, Aug 8, 2008
  14. 2/3 git-svn: Allow deep branch names by supporting multi-globsEric Wong, Aug 8, 2008

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.