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