git-svn: add support for prefixed globs in config
PATCH v3 1/1 git-svn: add support for prefixed globs in config
Introduce prefixed globs for branches and tags in git-svn. Globs like 'release_*' allow users to avoid long lines in config like:
branches = branches/{release_20,release_21,release_22,...}
---
Changes from v1 (in v2 I forgot to switch from `` to $() ):
* Joined implementation and test in one patch
* Fixed test code style according to current coding style guide
Documentation/git-svn.txt | 5 ++ perl/Git/SVN/GlobSpec.pm | 9 ++- t/t9168-git-svn-prefixed-glob.sh | 136 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 5 deletions(-) create mode 100755 t/t9168-git-svn-prefixed-glob.sh
Documentation/git-svn.txt +5 -0
@@ -1034,6 +1034,7 @@ listed below are allowed: url = http://server.org/svn fetch = trunk/project-a:refs/remotes/project-a/trunk branches = branches/*/project-a:refs/remotes/project-a/branches/* + branches = branches/release_*:refs/remotes/project-a/branches/release_* tags = tags/*/project-a:refs/remotes/project-a/tags/* ------------------------------------------------------------------------
@@ -1044,6 +1045,10 @@ independent path component (surrounded by '/' or EOL). This type of configuration is not automatically created by 'init' and should be manually entered with a text-editor or using 'git config'. +Also note that prefixed globs (e.g. 'release_*') match everything after prefix +but do not match exact prefix. For example: +'release_*' will match 'release_1' or 'release_v1' but will not match 'release_'. + It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:
perl/Git/SVN/GlobSpec.pm +4 -5
@@ -11,16 +11,15 @@ sub new { my $die_msg = "Only one set of wildcard directories " . "(e.g. '*' or '*/*/*') is supported: '$glob'\n"; for my $part (split(m|/|, $glob)) { - if ($part =~ /\*/ && $part ne "*") { - die "Invalid pattern in '$glob': $part\n"; - } elsif ($pattern_ok && $part =~ /[{}]/ && + if ($pattern_ok && $part =~ /[{}]/ && $part !~ /^\{[^{}]+\}/) { die "Invalid pattern in '$glob': $part\n"; } - if ($part eq "*") { + if ($part =~ /(\w*)\*/) { die $die_msg if $state eq "right"; $state = "pattern"; - push(@patterns, "[^/]*"); + my $pat = $1 ? "${1}[^/]+" : "[^/]*"; + push(@patterns, $pat); } elsif ($pattern_ok && $part =~ /^\{(.*)\}$/) { die $die_msg if $state eq "right"; $state = "pattern";
t/t9168-git-svn-prefixed-glob.sh new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.7.0.rc0.21.gb793f61
Quoted 15 lines · Victor Leschuk
t/t9168-git-svn-prefixed-glob.sh new file +12
-0@@ -0,0 +1,136 @@ +#!/bin/sh +test_description='git svn globbing refspecs with prefixed globs' +. ./lib-git-svn.sh + +cat >expect.end <<EOF +the end +hi +start a new branch +initial +EOF + +test_expect_success 'test refspec prefixed globbing' '
<snip>
t/t9168-git-svn-prefixed-glob.sh line 61
Quoted 3 lines
t/t9168-git-svn-prefixed-glob.sh new file +3
-0+echo try to try >expect.two && +echo nothing to see here >>expect.two && +cat expect.end >>expect.two
What happens when the cat fails?
Should probably be folded into the subsequent test case. (I used to write tests with "set -e", but it's not descriptive as far as failure goes).
t/t9168-git-svn-prefixed-glob.sh line 116
Quoted 7 lines
t/t9168-git-svn-prefixed-glob.sh new file +5
-0+test_expect_success 'test left-hand-side only prefixed globbing' ' + git config --add svn-remote.two.url "$svnrepo" && +echo "Only one set of wildcard directories" \ + "(e.g. '*' or '*/*/*') is supported: 'branches/b_*/t/*'" >expect.four && +echo "" >>expect.four
Same with echo...
Quoted 1 line
+test_expect_success 'test disallow prefixed multi-globs' '