]> git.ipfire.org Git - thirdparty/git.git/blame - git-rm.sh
SubmittingPatches: The download location of External Editor has moved
[thirdparty/git.git] / git-rm.sh
CommitLineData
d4a1cab5
CW
1#!/bin/sh
2
3USAGE='[-f] [-n] [-v] [--] <file>...'
4SUBDIRECTORY_OK='Yes'
5. git-sh-setup
6
d4a1cab5
CW
7remove_files=
8show_only=
9verbose=
10while : ; do
11 case "$1" in
12 -f)
13 remove_files=true
d4a1cab5
CW
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
32done
33
34# This is typo-proofing. If some paths match and some do not, we want
35# to do nothing.
36case "$#" in
370) ;;
38*)
39 git-ls-files --error-unmatch -- "$@" >/dev/null || {
40 echo >&2 "Maybe you misspelled it?"
41 exit 1
42 }
43 ;;
44esac
45
3844cdc8
CW
46if test -f "$GIT_DIR/info/exclude"
47then
48 git-ls-files -z \
49 --exclude-from="$GIT_DIR/info/exclude" \
d4a1cab5 50 --exclude-per-directory=.gitignore -- "$@"
3844cdc8
CW
51else
52 git-ls-files -z \
53 --exclude-per-directory=.gitignore -- "$@"
54fi |
55case "$show_only,$remove_files" in
56true,*)
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
d4a1cab5
CW
66 ;;
67*)
3844cdc8 68 git-update-index --force-remove $verbose -z --stdin
d4a1cab5
CW
69 ;;
70esac