Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: What's cooking in git.git (Oct 2012, #01; Tue, 2)

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:54:57
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

On Thu, Oct 04, 2012 at 09:39:02AM -0700, Junio C Hamano wrote:
Assuming that we do want to match "x/y" with "x/**/y", I suspect
that "'**' matches anything including a slash" would not give us
that semantics. Is it something we can easily fix in the wildmatch
code?
Something like this may suffice. Lightly tested with "git add -n".
Reading the code, I think we can even distinguish "match zero or more
directories" and "match one or more directories" with "/**/" and maybe
"/***/". Right now **, ***, ****... are the same. So are /**/, /***/,
/****/...

-- 8< --
diff --git a/wildmatch.c b/wildmatch.c
index f153f8a..81eadc8 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -98,8 +98,12 @@ static int dowild(const uchar *p, const uchar *text,
 	    continue;
 	  case '*':
 	    if (*++p == '*') {
+		int slashstarstar = p[-2] == '/';
 		while (*++p == '*') {}
 		special = TRUE;
+		if (slashstarstar && *p == '/' &&
+		    dowild(p + 1, text, a, force_lower_case) == TRUE)
+		    return TRUE;
 	    } else
 		special = FALSE;
 	    if (*p == '\0') {
-- 8< --
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help