git-svn: add support for prefixed globs in config
PATCH v2 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,...}
Signed-off-by Victor Leschuk <[email protected]>
---
Changes from v1:
* 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