summaryrefslogtreecommitdiff
path: root/git-add.sh
blob: 3d364db2517b6a19de6b8e26f6d61a86589c1fcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

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