From 893d839970c0f966bee17cdf63895a62e670e0ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 14 Jul 2013 15:35:37 +0700 Subject: [PATCH] clean: convert to use parse_pathspec MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/clean.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/builtin/clean.c b/builtin/clean.c index f955a40204..fdd4980b12 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -13,6 +13,7 @@ #include "refs.h" #include "string-list.h" #include "quote.h" +#include "pathspec.h" static int force = -1; /* unset */ @@ -150,7 +151,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT; struct strbuf directory = STRBUF_INIT; struct dir_struct dir; - static const char **pathspec; + struct pathspec pathspec; struct strbuf buf = STRBUF_INIT; struct string_list exclude_list = STRING_LIST_INIT_NODUP; struct exclude_list *el; @@ -209,9 +210,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix) for (i = 0; i < exclude_list.nr; i++) add_exclude(exclude_list.items[i].string, "", 0, el, -(i+1)); - pathspec = get_pathspec(prefix, argv); + parse_pathspec(&pathspec, 0, + PATHSPEC_PREFER_CWD, + prefix, argv); - fill_directory(&dir, pathspec); + fill_directory(&dir, pathspec.raw); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; @@ -246,9 +249,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix) if (lstat(ent->name, &st)) continue; - if (pathspec) - matches = match_pathspec(pathspec, ent->name, len, - 0, NULL); + if (pathspec.nr) + matches = match_pathspec_depth(&pathspec, ent->name, + len, 0, NULL); if (S_ISDIR(st.st_mode)) { strbuf_addstr(&directory, ent->name); @@ -262,7 +265,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) } strbuf_reset(&directory); } else { - if (pathspec && !matches) + if (pathspec.nr && !matches) continue; res = dry_run ? 0 : unlink(ent->name); if (res) { -- 2.11.4.GIT