Merge branch 'ew/rev-abbrev' into next
[debian-git.git] / git-add.sh
blobd6a4bc7d092f619d3c9dd20507c6659e13f82a3c
1 #!/bin/sh
3 USAGE='[-n] [-v] <file>...'
4 SUBDIRECTORY_OK='Yes'
5 . git-sh-setup
7 show_only=
8 verbose=
9 while : ; do
10 case "$1" in
11 -n)
12 show_only=true
14 -v)
15 verbose=--verbose
17 --)
18 shift
19 break
21 -*)
22 usage
25 break
27 esac
28 shift
29 done
31 # Check misspelled pathspec
32 case "$#" in
33 0) ;;
35 git-ls-files --error-unmatch --others --cached -- "$@" >/dev/null || {
36 echo >&2 "Maybe you misspelled it?"
37 exit 1
40 esac
42 if test -f "$GIT_DIR/info/exclude"
43 then
44 git-ls-files -z \
45 --exclude-from="$GIT_DIR/info/exclude" \
46 --others --exclude-per-directory=.gitignore -- "$@"
47 else
48 git-ls-files -z \
49 --others --exclude-per-directory=.gitignore -- "$@"
50 fi |
51 case "$show_only" in
52 true)
53 xargs -0 echo ;;
55 git-update-index --add $verbose -z --stdin ;;
56 esac