kill limit_pathspec_to_literal() as it's only used by parse_pathspec()
[gitweb.git] / tree-walk.c
index 6e30ef9d048c62c11a92aa5b0ee6df2d227776e6..37b157ed6e2c90d3ae24e39e944237a7c75d8bf2 100644 (file)
@@ -3,6 +3,7 @@
 #include "unpack-trees.h"
 #include "dir.h"
 #include "tree.h"
+#include "pathspec.h"
 
 static const char *get_mode(const char *str, unsigned int *modep)
 {
@@ -635,8 +636,12 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
        enum interesting never_interesting = ps->has_wildcard ?
                entry_not_interesting : all_entries_not_interesting;
 
+       GUARD_PATHSPEC(ps, PATHSPEC_FROMTOP | PATHSPEC_MAXDEPTH);
+
        if (!ps->nr) {
-               if (!ps->recursive || ps->max_depth == -1)
+               if (!ps->recursive ||
+                   !(ps->magic & PATHSPEC_MAXDEPTH) ||
+                   ps->max_depth == -1)
                        return all_entries_interesting;
                return within_depth(base->buf + base_offset, baselen,
                                    !!S_ISDIR(entry->mode),
@@ -657,7 +662,9 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
                        if (!match_dir_prefix(base_str, match, matchlen))
                                goto match_wildcards;
 
-                       if (!ps->recursive || ps->max_depth == -1)
+                       if (!ps->recursive ||
+                           !(ps->magic & PATHSPEC_MAXDEPTH) ||
+                           ps->max_depth == -1)
                                return all_entries_interesting;
 
                        return within_depth(base_str + matchlen + 1,