git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ammon Riley <ammon.riley@gmail.com>
To: git@vger.kernel.org
Cc: Ammon Riley <ammon.riley@gmail.com>
Subject: [PATCH] Make git-svn branch patterns match complete URL
Date: Thu, 30 Aug 2012 15:53:57 -0700	[thread overview]
Message-ID: <1346367237-28242-1-git-send-email-ammon.riley@gmail.com> (raw)

When using the {word,[...]} style of configuration for tags and branches,
it appears the intent is to only match whole path parts, since the words
in the {} pattern are meta-character quoted.

When the pattern word appears in the beginning or middle of the url,
it's matched completely, since the left side, pattern, and (non-empty)
right side are joined together with path separators.

However, when the pattern word appears at the end of the URL, the
right side is an empty pattern, and the resulting regex matches
more than just the specified pattern.

For example, if you specify something along the lines of

    branches = branches/project/{release_1,release_2}

and your repository also contains "branches/project/release_1_2", you
will also get the release_1_2 branch.  By restricting the match regex
with anchors, this is avoided.

Signed-off-by: Ammon Riley <ammon.riley@gmail.com>
---
Tested with Subversion 1.6; applies against maint, and master.

 perl/Git/SVN/GlobSpec.pm      | 4 +++-
 t/t9154-git-svn-fancy-glob.sh | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm
index 96cfd98..c95f5d7 100644
--- a/perl/Git/SVN/GlobSpec.pm
+++ b/perl/Git/SVN/GlobSpec.pm
@@ -44,7 +44,9 @@ sub new {
 	my $right = join('/', @right);
 	$re = join('/', @patterns);
 	$re = join('\/',
-		   grep(length, quotemeta($left), "($re)", quotemeta($right)));
+		   grep(length, quotemeta($left),
+                                "($re)(?=/|\$)",
+                                quotemeta($right)));
 	my $left_re = qr/^\/\Q$left\E(\/|$)/;
 	bless { left => $left, right => $right, left_regex => $left_re,
 	        regex => qr/$re/, glob => $glob, depth => $depth }, $class;
diff --git a/t/t9154-git-svn-fancy-glob.sh b/t/t9154-git-svn-fancy-glob.sh
index a6a56a6..b780e0e 100755
--- a/t/t9154-git-svn-fancy-glob.sh
+++ b/t/t9154-git-svn-fancy-glob.sh
@@ -21,6 +21,15 @@ test_expect_success 'add red branch' "
 	test_must_fail git rev-parse refs/remotes/blue
 	"
 
+test_expect_success 'add gre branch' "
+	GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
+	git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&
+	git svn fetch &&
+	git rev-parse refs/remotes/red &&
+	test_must_fail git rev-parse refs/remotes/green &&
+	test_must_fail git rev-parse refs/remotes/blue
+	"
+
 test_expect_success 'add green branch' "
 	GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
 	git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&
-- 
1.7.11.3

             reply	other threads:[~2012-08-30 22:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 22:53 Ammon Riley [this message]
     [not found] ` <7vtxv02vta.fsf@alter.siamese.dyndns.org>
2012-09-14 21:45   ` [PATCH] Make git-svn branch patterns match complete URL 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=1346367237-28242-1-git-send-email-ammon.riley@gmail.com \
    --to=ammon.riley@gmail.com \
    --cc=git@vger.kernel.org \
    /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).