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

Re: git ls-files --error-unmatch weirdness

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Aug 12, 2011, 14:17 UTC
Message-ID
<CACsJy8D0-SqSY0q2hJ0+w_NeT_s0Uza=Bi8-y37EKWE2VZhYeQ@mail.gmail.com>
In-Reply-To
<20110812132436.GA12147@goldbirke>
2011/8/12 SZEDER Gábor <szeder@ira.uka.de>:
> So, the same 'git ls-files' command is OK when run at the top of the
> worktree, but errors out in a subdirectory.  What's going on?  Is this
> a bug?  If not, why not?

report_path_error() in ls-files.c is meant to check pathspecs given by user. However when in a subdir, get_pathspec() automatically adds a pathspec (that is prefix). This new pathspec confuses report_path_error(). The following patch may help (possibly corrupted because I paste in gmail, but you get the idea)

diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 0e98bff..e0611ac 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -545,7 +545,8 @@ int cmd_ls_files(int argc, const char **argv,
const char *cmd_prefix)
 	max_prefix_len = max_prefix ? strlen(max_prefix) : 0;

 	/* Treat unmatching pathspec elements as errors */
-	if (pathspec && error_unmatch) {
+	if (pathspec && error_unmatch &&
+	    (!prefix || pathspec[1])) {
 		int num;
 		for (num = 0; pathspec[num]; num++)
 			;
-- 
Duy
Previous: SZEDER GáborNext: Junio C Hamano
Message 2 of 3 in “git ls-files --error-unmatch weirdness”
  1. SZEDER GáborAug 12, 2011
  2. Nguyen Thai Ngoc DuyAug 12, 2011
  3. Junio C HamanoAug 12, 2011

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.