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 disabled
=$
(git config
--bool clean.requireForce
)
41 rmf
="echo Would remove"
42 rmrf
="echo Would remove"
43 rm_refuse
="echo Would not remove"
68 # requireForce used to default to false but now it defaults to true.
69 # IOW, lack of explicit "clean.requireForce = false" is taken as
70 # "clean.requireForce = true".
73 die
"clean.requireForce not set and -n or -f not given; refusing to clean"
76 die
"clean.requireForce set and -n or -f not given; refusing to clean"
80 case "$ignored,$ignoredonly" in
84 if [ -z "$ignored" ]; then
85 excl
="--exclude-per-directory=.gitignore"
86 excl_info
= excludes_file
=
87 if [ -f "$GIT_DIR/info/exclude" ]; then
88 excl_info
="--exclude-from=$GIT_DIR/info/exclude"
90 if cfg_excl
=$
(git config core.excludesfile
) && test -f "$cfg_excl"
92 excludes_file
="--exclude-from=$cfg_excl"
94 if [ "$ignoredonly" ]; then
95 excl
="$excl --ignored"
99 git ls-files
--others --directory \
100 $excl ${excl_info:+"$excl_info"} ${excludes_file:+"$excludes_file"} \
102 while read -r file; do
103 if [ -d "$file" -a ! -L "$file" ]; then
104 if [ -z "$cleandir" ]; then
108 $echo1 "Removing $file"
111 $echo1 "Removing $file"