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

[PATCH v3 08/31] parse_pathspec: add PATHSPEC_EMPTY_MATCH_ALL

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 13, 2013, 12:35 UTC
Message-ID
<1358080539-17436-9-git-send-email-pclouds@gmail.com>
In-Reply-To
<1358080539-17436-1-git-send-email-pclouds@gmail.com>
We have two ways of dealing with empty pathspec:
1. limit it to current prefix
2. match the entire working directory

Some commands go with #1, some with #2. get_pathspec() and parse_pathspec() only supports #1. Make it support #2 too via PATHSPEC_EMPTY_MATCH_ALL flag.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 cache.h | 3 +++
 setup.c | 3 +++
 2 files changed, 6 insertions(+)
diff --git a/cache.h b/cache.h
index 1f51423..32231d8 100644
--- a/cache.h
+++ b/cache.h
@@ -503,6 +503,9 @@ struct pathspec {
 			    __FILE__, __LINE__, (ps)->magic & ~(mask)); \
 	} while (0)
 
+/* parse_pathspec flags */
+#define PATHSPEC_EMPTY_MATCH_ALL (1<<0) /* No args means match everything */
+
 extern int init_pathspec(struct pathspec *, const char **);
 extern void parse_pathspec(struct pathspec *pathspec, unsigned magic_mask,
 			   unsigned flags, const char *prefix,
diff --git a/setup.c b/setup.c
index 0c9fc75..d0b1d1f 100644
--- a/setup.c
+++ b/setup.c
@@ -289,6 +289,9 @@ void parse_pathspec(struct pathspec *pathspec,
 	if (!entry && !prefix)
 		return;
 
+	if (!*argv && (flags & PATHSPEC_EMPTY_MATCH_ALL))
+		return;
+
 	/* No arguments with prefix -> prefix pathspec */
 	if (!entry) {
 		static const char *raw[2];
-- 
1.8.0.rc2.23.g1fb49df
Previous: Nguyễn Thái Ngọc DuyNext: Martin von Zweigbergk
Message 11 of 37 in “nd/parse-pathspec”
  1. 00/31 nd/parse-pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  2. 01/31 clean: remove unused variable "seen"Nguyễn Thái Ngọc Duy, Jan 13, 2013
  3. 02/31 Add copy_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  4. 03/31 Add parse_pathspec() that converts cmdline args to struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  5. Martin von ZweigbergkJan 14, 2013
  6. Duy NguyenJan 14, 2013
  7. 04/31 parse_pathspec: save original pathspec for reportingNguyễn Thái Ngọc Duy, Jan 13, 2013
  8. 05/31 Export parse_pathspec() and convert some get_pathspec() callsNguyễn Thái Ngọc Duy, Jan 13, 2013
  9. 06/31 Guard against new pathspec magic in pathspec matching codeNguyễn Thái Ngọc Duy, Jan 13, 2013
  10. 07/31 clean: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  11. 08/31 parse_pathspec: add PATHSPEC_EMPTY_MATCH_ALLNguyễn Thái Ngọc Duy, Jan 13, 2013
  12. Martin von ZweigbergkJan 21, 2013
  13. Duy NguyenJan 22, 2013
  14. 09/31 commit: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  15. 10/31 status: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  16. 11/31 rerere: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  17. 12/31 checkout: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  18. 13/31 rm: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  19. 14/31 parse_pathspec: support stripping submodule trailing slashesNguyễn Thái Ngọc Duy, Jan 13, 2013
  20. 15/31 ls-files: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  21. 16/31 archive: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  22. 17/31 parse_pathspec: support stripping/checking submodule pathsNguyễn Thái Ngọc Duy, Jan 13, 2013
  23. 18/31 add: convert to use parse_pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  24. 19/31 Convert read_cache_preload() to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  25. 20/31 Convert unmerge_cache to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  26. 21/31 checkout: convert read_tree_some to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  27. 22/31 Convert report_path_error to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  28. 23/31 Convert refresh_index to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  29. 24/31 Convert {read,fill}_directory to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  30. 25/31 Convert add_files_to_cache to take struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  31. 26/31 Convert common_prefix() to use struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  32. 27/31 Remove diff_tree_{setup,release}_pathsNguyễn Thái Ngọc Duy, Jan 13, 2013
  33. 28/31 Remove init_pathspec() in favor of parse_pathspec()Nguyễn Thái Ngọc Duy, Jan 13, 2013
  34. 29/31 Remove match_pathspec() in favor of match_pathspec_depth()Nguyễn Thái Ngọc Duy, Jan 13, 2013
  35. 30/31 tree-diff: remove the use of pathspec's raw[] in follow-rename codepathNguyễn Thái Ngọc Duy, Jan 13, 2013
  36. 31/31 Rename field "raw" to "_raw" in struct pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  37. Junio C HamanoJan 13, 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.