]> git.ipfire.org Git - thirdparty/git.git/blobdiff - tree-walk.c
Merge branch 'pb/doc-sequence-editor-configuration'
[thirdparty/git.git] / tree-walk.c
index bb0ad34c5457d3b812663fb41ece1804fff6ef7a..0160294712b4c91a02f950af377d8fdf6fa4491b 100644 (file)
@@ -851,7 +851,14 @@ static int match_entry(const struct pathspec_item *item,
        if (matchlen > pathlen) {
                if (match[pathlen] != '/')
                        return 0;
-               if (!S_ISDIR(entry->mode) && !S_ISGITLINK(entry->mode))
+               /*
+                * Reject non-directories as partial pathnames, except
+                * when match is a submodule with a trailing slash and
+                * nothing else (to handle 'submod/' and 'submod'
+                * uniformly).
+                */
+               if (!S_ISDIR(entry->mode) &&
+                   (!S_ISGITLINK(entry->mode) || matchlen > pathlen + 1))
                        return 0;
        }