X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-add.sh;h=3d364db2517b6a19de6b8e26f6d61a86589c1fcc;hb=d1c5f2a42d7b5c0e3d3862212dea1f09809c4963;hp=7d91eeb65705fba291b3baf0e006c9ec90f96276;hpb=215a7ad1ef790467a4cd3f0dcffbd6e5f04c38f7;p=git.git diff --git a/git-add.sh b/git-add.sh index 7d91eeb6..3d364db2 100755 --- a/git-add.sh +++ b/git-add.sh @@ -1,2 +1,32 @@ #!/bin/sh -git-update-index --add -- "$@" + +show_only= +verbose= +while : ; do + case "$1" in + -n) + show_only=true + verbose=true + ;; + -v) + verbose=true + ;; + *) + break + ;; + esac + shift +done + +GIT_DIR=$(git-rev-parse --git-dir) || exit +global_exclude= +if [ -f "$GIT_DIR/info/exclude" ]; then + global_exclude="--exclude-from=$GIT_DIR/info/exclude" +fi +for i in $(git-ls-files --others \ + $global_exclude --exclude-per-directory=.gitignore \ + "$@") +do + [ "$verbose" ] && echo " $i" + [ "$show_only" ] || git-update-index --add -- "$i" || exit +done