]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wildmatch.c
wildmatch: make /**/ match zero or more directories
[thirdparty/git.git] / wildmatch.c
index 85bc0df8f814f18f9b10f9eccea0620ae8d9b9bc..3972e26e83a5131f746399deaa32835c7c9915cb 100644 (file)
@@ -90,6 +90,18 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
                                if ((prev_p == text || *prev_p == '/') ||
                                    (*p == '\0' || *p == '/' ||
                                     (p[0] == '\\' && p[1] == '/'))) {
+                                       /*
+                                        * Assuming we already match 'foo/' and are at
+                                        * <star star slash>, just assume it matches
+                                        * nothing and go ahead match the rest of the
+                                        * pattern with the remaining string. This
+                                        * helps make foo/<*><*>/bar (<> because
+                                        * otherwise it breaks C comment syntax) match
+                                        * both foo/bar and foo/a/bar.
+                                        */
+                                       if (p[0] == '/' &&
+                                           dowild(p + 1, text, force_lower_case) == MATCH)
+                                               return MATCH;
                                        special = TRUE;
                                } else
                                        return ABORT_MALFORMED;