X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-add.sh;h=4bf41281d5554f9b1da103b0360eebc411a435eb;hb=23d61f8343282643c830e1c446962b213dbcc09a;hp=7d91eeb65705fba291b3baf0e006c9ec90f96276;hpb=215a7ad1ef790467a4cd3f0dcffbd6e5f04c38f7;p=git.git diff --git a/git-add.sh b/git-add.sh index 7d91eeb6..4bf41281 100755 --- a/git-add.sh +++ b/git-add.sh @@ -1,2 +1,36 @@ #!/bin/sh -git-update-index --add -- "$@" + +show_only= +verbose= +while : ; do + case "$1" in + -n) + show_only=true + ;; + -v) + verbose=--verbose + ;; + *) + break + ;; + esac + shift +done + +GIT_DIR=$(git-rev-parse --git-dir) || exit + +if test -f "$GIT_DIR/info/exclude" +then + git-ls-files -z \ + --exclude-from="$GIT_DIR/info/exclude" \ + --others --exclude-per-directory=.gitignore -- "$@" +else + git-ls-files -z \ + --others --exclude-per-directory=.gitignore -- "$@" +fi | +case "$show_only" in +true) + xargs -0 echo ;; +*) + git-update-index --add $verbose -z --stdin ;; +esac