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

[PATCH] ls-files: Give hints when errors happen.

From
Andreas Ericsson <ae@op5.se>
Date
Nov 30, 2006, 11:28 UTC
Message-ID
<20061130115908.942AF5BA19@nox.op5.se>

Without this patch "git commit file.c file2.c" produces the not so stellar output:

	error: pathspec 'file.c' did not match any.
	error: pathspec 'file2.c' did not match any.
With this patch, the output is changed to:
	error: pathspec 'file.c' did not match any file(s) known to git.
	error: pathspec 'file2.c' did not match any file(s) known to git.
	Did you forget to 'git add'?
Signed-off-by: Andreas Ericsson <ae@op5.se>
---
 builtin-ls-files.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index ad8c41e..bc79ce4 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -487,10 +487,14 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 		for (num = 0; pathspec[num]; num++) {
 			if (ps_matched[num])
 				continue;
-			error("pathspec '%s' did not match any.",
+			error("pathspec '%s' did not match any file(s) known to git.",
 			      pathspec[num] + prefix_offset);
 			errors++;
 		}
+
+		if (errors)
+			fprintf(stderr, "Did you forget to 'git add'?\n");
+
 		return errors ? 1 : 0;
 	}
 
-- 
1.4.4.1.GIT
Message 1 of 1 in “ls-files: Give hints when errors happen.”
  1. ls-files: Give hints when errors happen.Andreas Ericsson, Nov 30, 2006

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.