cleanups: Remove unused vars from combine-diff.c
[git/gitweb.git] / git-rm.sh
blobfda4541c766cb1606402259cc1a6e0281105732f
1 #!/bin/sh
3 USAGE='[-f] [-n] [-v] [--] <file>...'
4 SUBDIRECTORY_OK='Yes'
5 . git-sh-setup
7 remove_files=
8 show_only=
9 verbose=
10 while : ; do
11 case "$1" in
12 -f)
13 remove_files=true
15 -n)
16 show_only=true
18 -v)
19 verbose=--verbose
21 --)
22 shift; break
24 -*)
25 usage
28 break
30 esac
31 shift
32 done
34 # This is typo-proofing. If some paths match and some do not, we want
35 # to do nothing.
36 case "$#" in
37 0) ;;
39 git-ls-files --error-unmatch -- "$@" >/dev/null || {
40 echo >&2 "Maybe you misspelled it?"
41 exit 1
44 esac
46 if test -f "$GIT_DIR/info/exclude"
47 then
48 git-ls-files -z \
49 --exclude-from="$GIT_DIR/info/exclude" \
50 --exclude-per-directory=.gitignore -- "$@"
51 else
52 git-ls-files -z \
53 --exclude-per-directory=.gitignore -- "$@"
54 fi |
55 case "$show_only,$remove_files" in
56 true,*)
57 xargs -0 echo
59 *,true)
60 xargs -0 sh -c "
61 while [ \$# -gt 0 ]; do
62 file=\$1; shift
63 rm -- \"\$file\" && git-update-index --remove $verbose \"\$file\"
64 done
65 " inline
68 git-update-index --force-remove $verbose -z --stdin
70 esac