clean: require -f to do damage by default
This makes the clean.requireForce configuration default to true. Too many people are burned by typing "git clean" by mistake when they meant to say "make clean". Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 1, 2007 at 17:32 UTC
562ca192f94496611583688beb3725603ce51f89
4 files changed
+22
-9
Documentation/config.txt
+2
-2
@@ -338,8 +338,8 @@ branch.<name>.merge::
338
`.` (a period) for branch.<name>.remote.
339
340
clean.requireForce::
341
- A boolean to make git-clean do nothing unless given -f or -n. Defaults
342
- to false.
341
+ A boolean to make git-clean do nothing unless given -f
342
+ or -n. Defaults to true.
343
344
color.branch::
345
A boolean to enable/disable color in the output of
git-clean.sh
+5
-1
@@ -20,12 +20,16 @@ require_work_tree
20
ignored=
21
ignoredonly=
22
cleandir=
23
-disabled="`git config --bool clean.requireForce`"
23
rmf="rm -f --"
24
rmrf="rm -rf --"
25
rm_refuse="echo Not removing"
26
echo1="echo"
27
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)
32
+
33
while test $# != 0
34
do
35
case "$1" in
t/t7201-co.sh
+6
-6
@@ -77,7 +77,7 @@ test_expect_success "checkout with dirty tree without -m" '
77
test_expect_success "checkout -m with dirty tree" '
78
79
git checkout -f master &&
80
- git clean &&
80
+ git clean -f &&
81
82
fill 0 1 2 3 4 5 6 7 8 >one &&
83
git checkout -m side &&
@@ -99,7 +99,7 @@ test_expect_success "checkout -m with dirty tree" '
99
100
test_expect_success "checkout -m with dirty tree, renamed" '
101
102
- git checkout -f master && git clean &&
102
+ git checkout -f master && git clean -f &&
103
104
fill 1 2 3 4 5 7 8 >one &&
105
if git checkout renamer
@@ -121,7 +121,7 @@ test_expect_success "checkout -m with dirty tree, renamed" '
121
122
test_expect_success 'checkout -m with merge conflict' '
123
124
- git checkout -f master && git clean &&
124
+ git checkout -f master && git clean -f &&
125
126
fill 1 T 3 4 5 6 S 8 >one &&
127
if git checkout renamer
@@ -144,7 +144,7 @@ test_expect_success 'checkout -m with merge conflict' '
144
145
test_expect_success 'checkout to detach HEAD' '
146
147
- git checkout -f renamer && git clean &&
147
+ git checkout -f renamer && git clean -f &&
148
git checkout renamer^ &&
149
H=$(git rev-parse --verify HEAD) &&
150
M=$(git show-ref -s --verify refs/heads/master) &&
@@ -160,7 +160,7 @@ test_expect_success 'checkout to detach HEAD' '
160
161
test_expect_success 'checkout to detach HEAD with branchname^' '
162
163
- git checkout -f master && git clean &&
163
+ git checkout -f master && git clean -f &&
164
git checkout renamer^ &&
165
H=$(git rev-parse --verify HEAD) &&
166
M=$(git show-ref -s --verify refs/heads/master) &&
@@ -176,7 +176,7 @@ test_expect_success 'checkout to detach HEAD with branchname^' '
176
177
test_expect_success 'checkout to detach HEAD with HEAD^0' '
178
179
- git checkout -f master && git clean &&
179
+ git checkout -f master && git clean -f &&
180
git checkout HEAD^0 &&
181
H=$(git rev-parse --verify HEAD) &&
182
M=$(git show-ref -s --verify refs/heads/master) &&
t/t7300-clean.sh
+9
@@ -7,6 +7,8 @@ test_description='git-clean basic tests'
7
8
. ./test-lib.sh
9
10
+git config clean.requireForce no
11
+
12
test_expect_success 'setup' '
13
14
mkdir -p src &&
@@ -139,6 +141,13 @@ test_expect_success 'git-clean -d -X' '
141
142
'
143
144
+test_expect_success 'clean.requireForce defaults to true' '
145
+
146
+ git config --unset clean.requireForce &&
147
+ ! git-clean
148
+
149
+'
150
+
151
test_expect_success 'clean.requireForce' '
152
153
git config clean.requireForce true &&