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.'
23 disabled="`git-config --bool clean.requireForce`"
26 rm_refuse="echo Not removing"
29 while case "$#" in 0) break ;; esac
40 rmf="echo Would remove"
41 rmrf="echo Would remove"
42 rm_refuse="echo Would not remove"
67 if [ "$disabled" = true ]; then
68 echo "clean.requireForce set and -n or -f not given; refusing to clean"
72 case "$ignored,$ignoredonly" in
76 if [ -z "$ignored" ]; then
77 excl="--exclude-per-directory=.gitignore"
78 if [ -f "$GIT_DIR/info/exclude" ]; then
79 excl_info="--exclude-from=$GIT_DIR/info/exclude"
81 if [ "$ignoredonly" ]; then
82 excl="$excl --ignored"
86 git-ls-files --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
87 while read -r file; do
88 if [ -d "$file" -a ! -L "$file" ]; then
89 if [ -z "$cleandir" ]; then
93 $echo1 "Removing $file"
96 $echo1 "Removing $file"