Add clean.requireForce option, and add -f option to git-clean to override it
Add a new configuration option clean.requireForce. If set, git-clean will refuse to run, unless forced with the new -f option, or not acting due to -n. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Josh Triplett committed
Apr 23, 2007 at 17:18 UTC
2122591b3b5c6d93d3052a3151afcfa3146ede84
4 files changed
+22
-2
Documentation/config.txt
+4
@@ -300,6 +300,10 @@ branch.<name>.merge::
300
branch.<name>.merge to the desired branch, and use the special setting
301
`.` (a period) for branch.<name>.remote.
302
303
+clean.requireForce::
304
+ A boolean to make git-clean do nothing unless given -f or -n. Defaults
305
+ to false.
306
+
307
color.branch::
308
A boolean to enable/disable color in the output of
309
gitlink:git-branch[1]. May be set to `true` (or `always`),
Documentation/git-clean.txt
+5
-1
@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
8
SYNOPSIS
9
--------
10
[verse]
11
-'git-clean' [-d] [-n] [-q] [-x | -X] [--] <paths>...
11
+'git-clean' [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...
12
13
DESCRIPTION
14
-----------
@@ -25,6 +25,10 @@ OPTIONS
25
-d::
26
Remove untracked directories in addition to untracked files.
27
28
+-f::
29
+ If the git configuration specifies clean.forceRequire as true,
30
+ git-clean will refuse to run unless given -f or -n.
31
+
32
-n::
33
Don't actually remove anything, just show what would be done.
34
contrib/completion/git-completion.bash
+1
@@ -790,6 +790,7 @@ _git_config ()
790
core.legacyHeaders
791
core.packedGitWindowSize
792
core.packedGitLimit
793
+ clean.requireForce
794
color.branch
795
color.branch.current
796
color.branch.local
git-clean.sh
+12
-1
@@ -3,9 +3,10 @@
3
# Copyright (c) 2005-2006 Pavel Roskin
4
#
5
6
-USAGE="[-d] [-n] [-q] [-x | -X] [--] <paths>..."
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
@@ -19,6 +20,7 @@ require_work_tree
20
ignored=
21
ignoredonly=
22
cleandir=
23
+disabled="`git-config --bool clean.requireForce`"
24
rmf="rm -f --"
25
rmrf="rm -rf --"
26
rm_refuse="echo Not removing"
@@ -30,7 +32,11 @@ do
32
-d)
33
cleandir=1
34
;;
35
+ -f)
36
+ disabled=
37
+ ;;
38
-n)
39
+ disabled=
40
rmf="echo Would remove"
41
rmrf="echo Would remove"
42
rm_refuse="echo Would not remove"
@@ -58,6 +64,11 @@ do
64
shift
65
done
66
67
+if [ "$disabled" = true ]; then
68
+ echo "clean.requireForce set and -n or -f not given; refusing to clean"
69
+ exit 1
70
+fi
71
+
72
case "$ignored,$ignoredonly" in
73
1,1) usage;;
74
esac