[PATCH] Detect misspelled pathspec to git-add

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, February 15, 2006 - 2:14 am

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


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Detect misspelled pathspec to git-add, Junio C Hamano, (Wed Feb 15, 2:14 am)
Re: [PATCH] Detect misspelled pathspec to git-add, Johannes Schindelin, (Wed Feb 15, 3:45 am)