git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] git-svn: add support for prefixed globs in config

From
EWEric Wong <normalperson@yhbt.net>
Date
Jan 5, 2016, 08:15 UTC
Message-ID
<20160105081513.GA32695@dcvr.yhbt.net>
In-Reply-To
<xmqq60zfehyb.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Victor Leschuk <vleschuk@gmail.com> writes:
> > +	branches = branches/release_*:refs/remotes/project-a/branches/release_*
> 
> Hmph, if you are going this route, I wonder if there is a reason to
> limit yourself only to "prefix".  Would allowing something like this:
> 
> 	branches = branches/pre*post:refs/remotes/project-a/branches/*
> 
> i.e., loosening the rule to allow at most one asterisk anywhere on
> the left hand side of the colon, and require the same number of
> asterisks as the left hand side has on the right hand side of the
> colon, be too lax and hurt the users?
Seems doable.  Not sure about the consequences, yet...

I also think the $1 truthiness check was unnecessary and even problematic if we need to encounter a "0" as a path component. And using the path component will need to be quoted as we do below with the brace case (showing with diff -U6)

Perhaps this? (untested)
diff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm
index a136090..7961a78 100644
--- a/perl/Git/SVN/GlobSpec.pm
+++ b/perl/Git/SVN/GlobSpec.pm
@@ -12,16 +12,17 @@ sub new {
 				"(e.g. '*' or '*/*/*') is supported: '$glob'\n";
 	for my $part (split(m|/|, $glob)) {
 		if ($pattern_ok && $part =~ /[{}]/ &&
 			 $part !~ /^\{[^{}]+\}/) {
 			die "Invalid pattern in '$glob': $part\n";
 		}
-		if ($part =~ /(\w*)\*/) {
+		if ($part =~ /(\w*)\*(\w*)/) {
+			my ($l, $r) = ($1, $2);
 			die $die_msg if $state eq "right";
 			$state = "pattern";
-			my $pat = $1 ? "${1}[^/]+" : "[^/]*";
+			my $pat = quotemeta($l) . '[^/]*'. quotemeta($r);
 			push(@patterns, $pat);
 		} elsif ($pattern_ok && $part =~ /^\{(.*)\}$/) {
 			die $die_msg if $state eq "right";
 			$state = "pattern";
 			my $p = quotemeta($1);
 			$p =~ s/\\,/|/g;
-- 
EW
Previous: Junio C HamanoNext: Victor Leschuk
Message 3 of 4 in “git-svn: add support for prefixed globs in config”
  1. git-svn: add support for prefixed globs in configVictor Leschuk, Dec 30, 2015
  2. Junio C HamanoDec 30, 2015
  3. Eric WongJan 5, 2016
  4. Victor LeschukJan 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.