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