parse_pathspec: add special flag for max_depth feature
[gitweb.git] / builtin / clean.c
index f4b760bf3dcb2371da6ae9d77f2f8fb1c0fa9eb9..f955a4020425e2ecab24c750201d4c82d0a84a10 100644 (file)
@@ -153,8 +153,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        static const char **pathspec;
        struct strbuf buf = STRBUF_INIT;
        struct string_list exclude_list = STRING_LIST_INIT_NODUP;
+       struct exclude_list *el;
        const char *qname;
-       char *seen = NULL;
        struct option options[] = {
                OPT__QUIET(&quiet, N_("do not print names of files removed")),
                OPT__DRY_RUN(&dry_run, N_("dry run")),
@@ -205,17 +205,14 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        if (!ignored)
                setup_standard_excludes(&dir);
 
+       el = add_exclude_list(&dir, EXC_CMDL, "--exclude option");
        for (i = 0; i < exclude_list.nr; i++)
-               add_exclude(exclude_list.items[i].string, "", 0,
-                           &dir.exclude_list[EXC_CMDL]);
+               add_exclude(exclude_list.items[i].string, "", 0, el, -(i+1));
 
        pathspec = get_pathspec(prefix, argv);
 
        fill_directory(&dir, pathspec);
 
-       if (pathspec)
-               seen = xmalloc(argc > 0 ? argc : 1);
-
        for (i = 0; i < dir.nr; i++) {
                struct dir_entry *ent = dir.entries[i];
                int len, pos;
@@ -249,11 +246,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                if (lstat(ent->name, &st))
                        continue;
 
-               if (pathspec) {
-                       memset(seen, 0, argc > 0 ? argc : 1);
+               if (pathspec)
                        matches = match_pathspec(pathspec, ent->name, len,
-                                                0, seen);
-               }
+                                                0, NULL);
 
                if (S_ISDIR(st.st_mode)) {
                        strbuf_addstr(&directory, ent->name);
@@ -280,7 +275,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                        }
                }
        }
-       free(seen);
 
        strbuf_release(&directory);
        string_list_clear(&exclude_list, 0);