convert run_add_interactive to use struct pathspec
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 5f86e467c4ca46afe597934ae091a56597a60b0e..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] == '/')
@@ -1599,6 +1605,7 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
                const char *path = paths[i];
 
                item->match = path;
+               item->original = path;
                item->len = strlen(path);
                item->flags = 0;
                if (limit_pathspec_to_literal()) {