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

[PATCH] ls-files: clarify what --error-unmatch matches

From
CSChristian Sagstetter <christian.sagstetter@gmail.com>
Date
Dec 3, 2026, 13:41 UTC
Message-ID
<CAFsHQ-bMu=9X=j7m3rDm6y6Ax4hxN4vYV2eUoh1F9Lx5HebpVA@mail.gmail.com>

The manual and short help describe --error-unmatch as a check for index membership. With --others, an untracked file satisfies the check. With --modified, a tracked file with no unstaged changes causes the command to exit with status 1.

Describe the check in terms of the paths selected by the other options. Both cases are covered by t3005 and t3010.

Signed-off-by: Christian Sagstetter <christian.sagstetter@gmail.com>
---
 Documentation/git-ls-files.adoc | 5 +++--
 builtin/ls-files.c              | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-ls-files.adoc b/Documentation/git-ls-files.adoc
index 14ebad8b71..87b3b7f5e3 100644
--- a/Documentation/git-ls-files.adoc
+++ b/Documentation/git-ls-files.adoc
@@ -129,8 +129,9 @@ OPTIONS
 	in each directory, and the user's global exclusion file.

 --error-unmatch::
-	If any <file> does not appear in the index, treat this as an
-	error (return 1).
+	If any <file> argument matches no path selected by the other
+	options, report an error and exit with status 1. For example,
+	`--others` checks for matches among untracked files.

 --with-tree=<tree-ish>::
 	When using --error-unmatch to expand the user supplied
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b044520f9e..af403b3f5e 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -651,7 +651,7 @@ int cmd_ls_files(int argc,
 		OPT_BOOL(0, "recurse-submodules", &recurse_submodules,
 			N_("recurse through submodules")),
 		OPT_BOOL(0, "error-unmatch", &error_unmatch,
-			N_("if any <file> is not in the index, treat this as an error")),
+			N_("report an error if any pathspec matches no selected path")),
 		OPT_STRING(0, "with-tree", &with_tree, N_("tree-ish"),
 			N_("pretend that paths removed since <tree-ish> are still present")),
 		OPT__ABBREV(&abbrev),

base-commit: 566b6997dd4710b625c0882cf10a7443bf52d183
-- 
2.53.0
Message 1 of 1 in “ls-files: clarify what --error-unmatch matches”
  1. ls-files: clarify what --error-unmatch matchesChristian Sagstetter, Dec 3, 2026

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.