3 # Copyright (c) 2005-2006 Pavel Roskin
6 USAGE
="[-d] [-f] [-n] [-q] [-x | -X] [--] <paths>..."
7 LONG_USAGE
='Clean untracked files from the working directory
8 -d remove directories as well
9 -f override clean.requireForce and clean anyway
10 -n don'\''t remove anything, just show what would be done
11 -q be quiet, only report errors
12 -x remove ignored files as well
13 -X remove only ignored files
14 When optional <paths>... arguments are given, the paths
15 affected are further limited to those that match them.'
25 rm_refuse
="echo Not removing"
28 # requireForce used to default to false but now it defaults to true.
29 # IOW, lack of explicit "clean.requireForce = false" is taken as
30 # "clean.requireForce = true".
31 disabled
=$
(git config
--bool clean.requireForce ||
echo true
)
44 rmf
="echo Would remove"
45 rmrf
="echo Would remove"
46 rm_refuse
="echo Would not remove"
71 if [ "$disabled" = true
]; then
72 echo "clean.requireForce set and -n or -f not given; refusing to clean"
76 case "$ignored,$ignoredonly" in
80 if [ -z "$ignored" ]; then
81 excl
="--exclude-per-directory=.gitignore"
82 if [ -f "$GIT_DIR/info/exclude" ]; then
83 excl_info
="--exclude-from=$GIT_DIR/info/exclude"
85 if [ "$ignoredonly" ]; then
86 excl
="$excl --ignored"
90 git ls-files
--others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
91 while read -r file; do
92 if [ -d "$file" -a ! -L "$file" ]; then
93 if [ -z "$cleandir" ]; then
97 $echo1 "Removing $file"
100 $echo1 "Removing $file"