git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcus Griep <marcus@griep.us>
To: Git Mailing List <git@vger.kernel.org>
Cc: Eric Wong <normalperson@yhbt.net>,
	Junio C Hamano <gitster@pobox.com>,
	Marcus Griep <marcus@griep.us>
Subject: [PATCH v2 1/2] Fix multi-glob assertion in git-svn
Date: Thu,  7 Aug 2008 11:34:01 -0400	[thread overview]
Message-ID: <1218123242-26260-2-git-send-email-marcus@griep.us> (raw)
In-Reply-To: <1218123242-26260-1-git-send-email-marcus@griep.us>

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

Signed-off-by: Marcus Griep <marcus@griep.us>
---
 git-svn.perl            |    5 +++--
 t/t9108-git-svn-glob.sh |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index df0ed90..5974a06 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4912,14 +4912,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..ef6d88e 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -83,4 +83,23 @@ 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 &> stderr.three &&
+	cmp expect.three stderr.three
+	'
+
 test_done
-- 
1.6.0.rc2.4.g39f8

  reply	other threads:[~2008-08-07 15:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 19:58 [PATCH 2/2] git-svn: Allow deep branch names by supporting multi-globs Marcus Griep
2008-08-07  9:00 ` Eric Wong
2008-08-07 15:34   ` [PATCH v2 0/2] git-svn multi-glob fix and extension Marcus Griep
2008-08-07 15:34     ` Marcus Griep [this message]
2008-08-07 15:34       ` [PATCH v2 2/2] git-svn: Allow deep branch names by supporting multi-globs Marcus Griep
2008-08-08  8:40     ` [PATCH v2 0/2] git-svn multi-glob fix and extension Eric Wong
2008-08-08  8:41       ` [PATCH 1/3] Fix multi-glob assertion in git-svn Eric Wong
2008-08-08  9:41         ` Junio C Hamano
2008-08-09  7:28           ` Eric Wong
2008-08-09  7:48             ` Junio C Hamano
2008-08-08  8:41       ` [PATCH 2/3] git-svn: Allow deep branch names by supporting multi-globs Eric Wong
2008-08-08  8:41       ` [PATCH 3/3] git-svn: wrap long lines in a few places Eric Wong
2008-08-08  8:56       ` [PATCH 1/3] Fix multi-glob assertion in git-svn Eric Wong
2008-08-08  8:57       ` [PATCH 2/3] git-svn: Allow deep branch names by supporting multi-globs Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218123242-26260-2-git-send-email-marcus@griep.us \
    --to=marcus@griep.us \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).