]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wildmatch.c
wildmatch: make a special case for "*/" with FNM_PATHNAME
[thirdparty/git.git] / wildmatch.c
index 536470b79493784935c9c125473453bb3921b5d8..bb425220b07bbc2c35d2d7ec28b13fd6c53b4ac4 100644 (file)
@@ -117,6 +117,18 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
                                                return WM_NOMATCH;
                                }
                                return WM_MATCH;
+                       } else if (!match_slash && *p == '/') {
+                               /*
+                                * _one_ asterisk followed by a slash
+                                * with WM_PATHNAME matches the next
+                                * directory
+                                */
+                               const char *slash = strchr((char*)text, '/');
+                               if (!slash)
+                                       return WM_NOMATCH;
+                               text = (const uchar*)slash;
+                               /* the slash is consumed by the top-level for loop */
+                               break;
                        }
                        while (1) {
                                if (t_ch == '\0')