Add new git-rm command with documentation
[git/jrn.git] / git-rm.sh
blob0a3f546683c11b1057209317fff1ab40fe847f81
1 #!/bin/sh
3 USAGE='[-f] [-n] [-v] [--] <file>...'
4 SUBDIRECTORY_OK='Yes'
5 . git-sh-setup
7 index_remove_option=--force-remove
8 remove_files=
9 show_only=
10 verbose=
11 while : ; do
12 case "$1" in
13 -f)
14 remove_files=true
15 index_remote_option=--force
17 -n)
18 show_only=true
20 -v)
21 verbose=--verbose
23 --)
24 shift; break
26 -*)
27 usage
30 break
32 esac
33 shift
34 done
36 # This is typo-proofing. If some paths match and some do not, we want
37 # to do nothing.
38 case "$#" in
39 0) ;;
41 git-ls-files --error-unmatch -- "$@" >/dev/null || {
42 echo >&2 "Maybe you misspelled it?"
43 exit 1
46 esac
48 files=$(
49 if test -f "$GIT_DIR/info/exclude" ; then
50 git-ls-files \
51 --exclude-from="$GIT_DIR/info/exclude" \
52 --exclude-per-directory=.gitignore -- "$@"
53 else
54 git-ls-files \
55 --exclude-per-directory=.gitignore -- "$@"
56 fi | sort | uniq
59 case "$show_only" in
60 true)
61 echo $files
64 [[ "$remove_files" = "true" ]] && rm -- $files
65 git-update-index $index_remove_option $verbose $files
67 esac