X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-add.sh;h=d6a4bc7d092f619d3c9dd20507c6659e13f82a3c;hb=1b9bc5a7b7434d771726011613a00cb202bd9f44;hp=a8498c729ab3188bd21dd6a54ddc77d4c34ac48a;hpb=caf4f582b2bb4d5582540aa49d29749b2600cd03;p=git.git diff --git a/git-add.sh b/git-add.sh index a8498c72..d6a4bc7d 100755 --- a/git-add.sh +++ b/git-add.sh @@ -1,5 +1,9 @@ #!/bin/sh +USAGE='[-n] [-v] ...' +SUBDIRECTORY_OK='Yes' +. git-sh-setup + show_only= verbose= while : ; do @@ -10,6 +14,13 @@ while : ; do -v) verbose=--verbose ;; + --) + shift + break + ;; + -*) + usage + ;; *) break ;; @@ -17,16 +28,25 @@ while : ; do shift done -GIT_DIR=$(git-rev-parse --git-dir) || exit +# 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 \ --exclude-from="$GIT_DIR/info/exclude" \ - --others --exclude-per-directory=.gitignore "$@" + --others --exclude-per-directory=.gitignore -- "$@" else git-ls-files -z \ - --others --exclude-per-directory=.gitignore "$@" + --others --exclude-per-directory=.gitignore -- "$@" fi | case "$show_only" in true)