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

[PATCH] Detect misspelled pathspec to git-add

From
Junio C Hamano <junkio@cox.net>
Date
Feb 15, 2006, 09:14 UTC
Message-ID
<7v1wy5m19t.fsf@assigned-by-dhcp.cox.net>

This is in the same spirit as an earlier patch for git-commit. It does an extra ls-files to avoid complaining when a fully tracked directory name is given on the command line (otherwise --others restriction would say the pathspec does not match).

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * I noticed this when I accidentally said "git add /a/b/c"
   when I meant "git add a/b/c", and I did not notice it until
   I said "git commit" which said "Nothing to commit."
   It does one extra ls-files only if any pathspec is given; I
   am hoping this slight performance hit is tolerated.  I think
   people who does "git add ." all the time to mean "add
   everything I added anywhere since I did git add last time"
   deserve it ;-).
   Comments?
 git-add.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
ca28a7e03232b9a3b66df8519d9ee827882c83c1
diff --git a/git-add.sh b/git-add.sh
index f719b4b..13fad82 100755
--- a/git-add.sh
+++ b/git-add.sh
@@ -24,6 +24,17 @@ while : ; do
   shift
 done
 
+# Check misspelled pathspec
+case "$#" in
+0)	;;
+*)
+	git-ls-files --error-unmatch --others --cached -- "$@" >/dev/null || {
+		echo >&2 "Maybe you misspelled it?"
+		exit 1
+	}
+	;;
+esac
+
 if test -f "$GIT_DIR/info/exclude"
 then
 	git-ls-files -z \
-- 
1.2.0.gcfba7
Next: Johannes Schindelin
Message 1 of 2 in “Detect misspelled pathspec to git-add”
  1. Detect misspelled pathspec to git-addJunio C Hamano, Feb 15, 2006
  2. Johannes SchindelinFeb 15, 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.