{"thread":{"id":"31391","subject":"[PATCH] Make git-svn branch patterns match complete URL","startedAt":"2012-08-30T22:53:57Z","lastAt":"2012-09-14T21:45:08Z","messageCount":2,"participants":["Ammon Riley","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"198132","messageId":"1346367237-28242-1-git-send-email-ammon.riley@gmail.com","threadId":"31391","inReplyTo":null,"subject":"[PATCH] Make git-svn branch patterns match complete URL","fromName":"Ammon Riley","fromEmail":"ammon.riley@gmail.com","sentAt":"2012-08-30T22:53:57Z","receivedAt":"2012-08-30T22:53:57Z","isPatch":true,"sender":{"key":"ammon.riley@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1801261?v=4"},"body":"When using the {word,[...]} style of configuration for tags and branches,\nit appears the intent is to only match whole path parts, since the words\nin the {} pattern are meta-character quoted.\n\nWhen the pattern word appears in the beginning or middle of the url,\nit's matched completely, since the left side, pattern, and (non-empty)\nright side are joined together with path separators.\n\nHowever, when the pattern word appears at the end of the URL, the\nright side is an empty pattern, and the resulting regex matches\nmore than just the specified pattern.\n\nFor example, if you specify something along the lines of\n\n    branches = branches/project/{release_1,release_2}\n\nand your repository also contains \"branches/project/release_1_2\", you\nwill also get the release_1_2 branch.  By restricting the match regex\nwith anchors, this is avoided.\n\nSigned-off-by: Ammon Riley <ammon.riley@gmail.com>\n---\nTested with Subversion 1.6; applies against maint, and master.\n\n perl/Git/SVN/GlobSpec.pm      | 4 +++-\n t/t9154-git-svn-fancy-glob.sh | 9 +++++++++\n 2 files changed, 12 insertions(+), 1 deletion(-)\n\ndiff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm\nindex 96cfd98..c95f5d7 100644\n--- a/perl/Git/SVN/GlobSpec.pm\n+++ b/perl/Git/SVN/GlobSpec.pm\n@@ -44,7 +44,9 @@ sub new {\n \tmy $right = join('/', @right);\n \t$re = join('/', @patterns);\n \t$re = join('\\/',\n-\t\t   grep(length, quotemeta($left), \"($re)\", quotemeta($right)));\n+\t\t   grep(length, quotemeta($left),\n+                                \"($re)(?=/|\\$)\",\n+                                quotemeta($right)));\n \tmy $left_re = qr/^\\/\\Q$left\\E(\\/|$)/;\n \tbless { left => $left, right => $right, left_regex => $left_re,\n \t        regex => qr/$re/, glob => $glob, depth => $depth }, $class;\ndiff --git a/t/t9154-git-svn-fancy-glob.sh b/t/t9154-git-svn-fancy-glob.sh\nindex a6a56a6..b780e0e 100755\n--- a/t/t9154-git-svn-fancy-glob.sh\n+++ b/t/t9154-git-svn-fancy-glob.sh\n@@ -21,6 +21,15 @@ test_expect_success 'add red branch' \"\n \ttest_must_fail git rev-parse refs/remotes/blue\n \t\"\n \n+test_expect_success 'add gre branch' \"\n+\tGIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&\n+\tgit config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&\n+\tgit svn fetch &&\n+\tgit rev-parse refs/remotes/red &&\n+\ttest_must_fail git rev-parse refs/remotes/green &&\n+\ttest_must_fail git rev-parse refs/remotes/blue\n+\t\"\n+\n test_expect_success 'add green branch' \"\n \tGIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&\n \tgit config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&\n-- \n1.7.11.3\n"},{"id":"199077","messageId":"20120914214508.GA16293@dcvr.yhbt.net","threadId":"31391","inReplyTo":"7vtxv02vta.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Make git-svn branch patterns match complete URL","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2012-09-14T21:45:08Z","receivedAt":"2012-09-14T21:45:08Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Any comment from \"git svn\" stakeholders on this one?\n\nLooks good to me.\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\nPushed to master of git://bogomips.org/git-svn.git\n(commit 059058765ea2b0abd88001ea1f0f866daf7d0e4c)\n\n  Ammon Riley (1):\n        Make git-svn branch patterns match complete URL\n\n  Robert Luberda (1):\n        t9164: Add missing quotes in test\n\n  Steven Walter (2):\n        git-svn.perl: consider all ranges for a given merge, instead of only tip-by-tip\n        git-svn.perl: keep processing all commits in parents_exclude\n\nWill followup on some other pending patches soon...\n"}]}