From e4e5dd94e6eea4b50d8baed8b6b8cc50f6c8eae4 Mon Sep 17 00:00:00 2001 From: Victor Leschuk Date: Mon, 11 Jan 2016 17:25:58 +0300 Subject: git-svn: loosen config globs limitations Expand the area of globs applicability for branches and tags in git-svn. It is now possible to use globs like 'a*e', or 'release_*'. This allows users to avoid long lines in config like: branches = branches/{release_20,release_21,release_22,...} In favor of: branches = branches/release_* [ew: amended commit message, minor formatting and style fixes] Signed-off-by: Victor Leschuk Signed-off-by: Eric Wong --- perl/Git/SVN/GlobSpec.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'perl/Git') diff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm index c95f5d76ca..4775026c5d 100644 --- a/perl/Git/SVN/GlobSpec.pm +++ b/perl/Git/SVN/GlobSpec.pm @@ -11,16 +11,20 @@ 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 "*") { + my $nstars = $part =~ tr/*//; + if ($nstars > 1) { + die "Only one '*' is allowed in a pattern: '$part'\n"; + } + if ($part =~ /(.*)\*(.*)/) { die $die_msg if $state eq "right"; + my ($l, $r) = ($1, $2); $state = "pattern"; - push(@patterns, "[^/]*"); + my $pat = quotemeta($l) . '[^/]*' . quotemeta($r); + push(@patterns, $pat); } elsif ($pattern_ok && $part =~ /^\{(.*)\}$/) { die $die_msg if $state eq "right"; $state = "pattern"; -- cgit v1.2.3