git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 04/21] clean: convert to use parse_pathspec

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 11, 2013, 11:20 UTC
Message-ID
<1357903275-16804-5-git-send-email-pclouds@gmail.com>
In-Reply-To
<1357903275-16804-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/clean.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/builtin/clean.c b/builtin/clean.c
index 69c1cda..788ad8c 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -42,7 +42,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;
 	const char *qname;
@@ -101,12 +101,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 		add_exclude(exclude_list.items[i].string, "", 0,
 			    &dir.exclude_list[EXC_CMDL]);
 
-	pathspec = get_pathspec(prefix, argv);
+	parse_pathspec(&pathspec, PATHSPEC_FROMTOP, 0, prefix, argv);
 
-	fill_directory(&dir, pathspec);
+	fill_directory(&dir, pathspec.raw);
 
-	if (pathspec)
-		seen = xmalloc(argc > 0 ? argc : 1);
+	if (pathspec.nr)
+		seen = xmalloc(pathspec.nr);
 
 	for (i = 0; i < dir.nr; i++) {
 		struct dir_entry *ent = dir.entries[i];
@@ -141,10 +141,10 @@ 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);
-			matches = match_pathspec(pathspec, ent->name, len,
-						 0, seen);
+		if (pathspec.nr) {
+			memset(seen, 0, pathspec.nr);
+			matches = match_pathspec_depth(&pathspec, ent->name, len,
+						       0, seen);
 		}
 
 		if (S_ISDIR(st.st_mode)) {
@@ -169,7 +169,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 			}
 			strbuf_reset(&directory);
 		} else {
-			if (pathspec && !matches)
+			if (pathspec.nr && !matches)
 				continue;
 			qname = quote_path_relative(ent->name, -1, &buf, prefix);
 			if (show_only) {
-- 
1.8.0.rc2.23.g1fb49df
Previous: Duy NguyenNext: Nguyễn Thái Ngọc Duy
Message 7 of 27 in “nd/parse-pathspec reroll”
  1. 00/21 nd/parse-pathspec rerollNguyễn Thái Ngọc Duy, Jan 11, 2013
  2. 01/21 pathspec: save the non-wildcard length partNguyễn Thái Ngọc Duy, Jan 11, 2013
  3. 02/21 Add parse_pathspec() that converts cmdline args to struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  4. 03/21 Export parse_pathspec() and convert some get_pathspec() callsNguyễn Thái Ngọc Duy, Jan 11, 2013
  5. Matt KraaiJan 11, 2013
  6. Duy NguyenJan 12, 2013
  7. 04/21 clean: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  8. 05/21 commit: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  9. Martin von ZweigbergkJan 12, 2013
  10. 06/21 status: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  11. 07/21 rerere: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  12. 08/21 checkout: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  13. 09/21 rm: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  14. 10/21 ls-files: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  15. 11/21 archive: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  16. 12/21 add: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  17. 13/21 Convert read_cache_preload() to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  18. 14/21 Convert unmerge_cache to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  19. 15/21 checkout: convert read_tree_some to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  20. 16/21 Convert report_path_error to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  21. 17/21 Convert refresh_index to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  22. Nguyen Thai Ngoc DuyJan 11, 2013
  23. 18/21 Convert {read,fill}_directory to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  24. 19/21 Convert add_files_to_cache to take struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  25. 20/21 Convert more init_pathspec() to parse_pathspec()Nguyễn Thái Ngọc Duy, Jan 11, 2013
  26. 21/21 Rename field "raw" to "_raw" in struct pathspecNguyễn Thái Ngọc Duy, Jan 11, 2013
  27. 22/21 Convert the last use of match_pathspec() and remove itNguyễn Thái Ngọc Duy, Jan 11, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.