]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wildmatch.c
wildmatch: fix "**" special case
[thirdparty/git.git] / wildmatch.c
index 3972e26e83a5131f746399deaa32835c7c9915cb..5f976e91d84f099bab8f8b89f261ccd39d132ceb 100644 (file)
@@ -58,6 +58,7 @@ typedef unsigned char uchar;
 static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 {
        uchar p_ch;
+       const uchar *pattern = p;
 
        for ( ; (p_ch = *p) != '\0'; text++, p++) {
                int matched, special;
@@ -87,7 +88,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
                        if (*++p == '*') {
                                const uchar *prev_p = p - 2;
                                while (*++p == '*') {}
-                               if ((prev_p == text || *prev_p == '/') ||
+                               if ((prev_p < pattern || *prev_p == '/') &&
                                    (*p == '\0' || *p == '/' ||
                                     (p[0] == '\\' && p[1] == '/'))) {
                                        /*