status: convert to use parse_pathspec
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 308028e5b16df77e22e87cf339a461676c7f4c1b..19978d3d59753a810503cf6dbac9eacb0f16c474 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -340,8 +340,12 @@ int match_pathspec_depth(const struct pathspec *ps,
 {
        int i, retval = 0;
 
+       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 MATCHED_RECURSIVELY;
 
                if (within_depth(name, namelen, 0, ps->max_depth))
@@ -358,7 +362,9 @@ int match_pathspec_depth(const struct pathspec *ps,
                if (seen && seen[i] == MATCHED_EXACTLY)
                        continue;
                how = match_pathspec_item(ps->items+i, prefix, name, namelen);
-               if (ps->recursive && ps->max_depth != -1 &&
+               if (ps->recursive &&
+                   (ps->magic & PATHSPEC_MAXDEPTH) &&
+                   ps->max_depth != -1 &&
                    how && how != MATCHED_FNMATCH) {
                        int len = ps->items[i].len;
                        if (name[len] == '/')