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

[PATCH 7/9] ls-files: add --narrow-match=spec option to test narrow matching

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 15, 2008, 14:26 UTC
Message-ID
<20080815142656.GA10750@laptop>
In-Reply-To
<cover.1218807249.git.pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin-ls-files.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index bcb1536..0064f73 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -29,6 +29,7 @@ static const char **pathspec;
 static int error_unmatch;
 static char *ps_matched;
 static const char *with_tree;
+static const char *narrow_spec;
 
 static const char *tag_cached = "";
 static const char *tag_unmerged = "";
@@ -219,6 +220,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
 	write_name_quoted(ce->name + offset, stdout, line_terminator);
 }
 
+int match_narrow_spec(const char *spec_, const char *path); /* unpack-trees.c */
 static void show_files(struct dir_struct *dir, const char *prefix)
 {
 	int i;
@@ -248,6 +250,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
 				continue;
 			if (show_checkout && ce_no_checkout(ce))
 				continue;
+			if (narrow_spec && !match_narrow_spec(narrow_spec, ce->name))
+				continue;
 			show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
 		}
 	}
@@ -429,7 +433,7 @@ static const char ls_files_usage[] =
 	"git ls-files [-z] [-t] [-v] (--[cached|checkout|deleted|others|stage|unmerged|killed|modified])* "
 	"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
 	"[ --exclude-per-directory=<filename> ] [--exclude-standard] "
-	"[--full-name] [--abbrev] [--] [<file>]*";
+	"[--narrow-match=narrowspec] [--full-name] [--abbrev] [--] [<file>]*";
 
 int cmd_ls_files(int argc, const char **argv, const char *prefix)
 {
@@ -472,6 +476,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 			show_checkout = 1;
 			continue;
 		}
+		if (!prefixcmp(arg, "--narrow-match=")) {
+			narrow_spec = arg+15;
+			continue;
+		}
 		if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
 			show_deleted = 1;
 			continue;
-- 
1.6.0.rc3.250.g8dd0
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 7 of 9 in “Introduce CE_NO_CHECKOUT bit”
  1. 1/9 Introduce CE_NO_CHECKOUT bitNguyễn Thái Ngọc Duy, Aug 15, 2008
  2. 2/9 update-index: add --checkout/--no-checkout options to update CE_NO_CHECKOUT bitNguyễn Thái Ngọc Duy, Aug 15, 2008
  3. 3/9 ls-files: add --checkout option to show checked out filesNguyễn Thái Ngọc Duy, Aug 15, 2008
  4. 4/9 Prevent diff machinery from examining worktree outside narrow checkoutNguyễn Thái Ngọc Duy, Aug 15, 2008
  5. 5/9 Clear CE_NO_CHECKOUT on checked out entries.Nguyễn Thái Ngọc Duy, Aug 15, 2008
  6. 6/9 Add support for narrow checkout in unpack_trees()Nguyễn Thái Ngọc Duy, Aug 15, 2008
  7. 7/9 ls-files: add --narrow-match=spec option to test narrow matchingNguyễn Thái Ngọc Duy, Aug 15, 2008
  8. 8/9 clone: support narrow checkout with --path optionNguyễn Thái Ngọc Duy, Aug 15, 2008
  9. 9/9 checkout: add new options to support narrow checkoutNguyễn Thái Ngọc Duy, Aug 15, 2008

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.