checkout-index: work from subdirectory.
[tgit.git] / git-add.sh
blobb5fe46aa20865d6785390fd22406d32b00a77845
1 #!/bin/sh
3 usage() {
4 die "usage: git add [-n] [-v] <file>..."
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 usage
21 break
23 esac
24 shift
25 done
27 GIT_DIR=$(git-rev-parse --git-dir) || exit
29 if test -f "$GIT_DIR/info/exclude"
30 then
31 git-ls-files -z \
32 --exclude-from="$GIT_DIR/info/exclude" \
33 --others --exclude-per-directory=.gitignore -- "$@"
34 else
35 git-ls-files -z \
36 --others --exclude-per-directory=.gitignore -- "$@"
37 fi |
38 case "$show_only" in
39 true)
40 xargs -0 echo ;;
42 git-update-index --add $verbose -z --stdin ;;
43 esac