summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-add.sh32
1 files changed, 31 insertions, 1 deletions
diff --git a/git-add.sh b/git-add.sh
index 7d91eeb..3d364db 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