]> git.ipfire.org Git - thirdparty/git.git/blob - git-rm.sh
Merge branch 'ml/cvsserver'
[thirdparty/git.git] / git-rm.sh
1 #!/bin/sh
2
3 USAGE='[-f] [-n] [-v] [--] <file>...'
4 SUBDIRECTORY_OK='Yes'
5 . git-sh-setup
6
7 remove_files=
8 show_only=
9 verbose=
10 while : ; do
11 case "$1" in
12 -f)
13 remove_files=true
14 ;;
15 -n)
16 show_only=true
17 ;;
18 -v)
19 verbose=--verbose
20 ;;
21 --)
22 shift; break
23 ;;
24 -*)
25 usage
26 ;;
27 *)
28 break
29 ;;
30 esac
31 shift
32 done
33
34 # This is typo-proofing. If some paths match and some do not, we want
35 # to do nothing.
36 case "$#" in
37 0) ;;
38 *)
39 git-ls-files --error-unmatch -- "$@" >/dev/null || {
40 echo >&2 "Maybe you misspelled it?"
41 exit 1
42 }
43 ;;
44 esac
45
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
58 ;;
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
66 ;;
67 *)
68 git-update-index --force-remove $verbose -z --stdin
69 ;;
70 esac