clean: require -f to do damage by default
[git/git.git] / t / t7300-clean.sh
CommitLineData
ec0e0f25
MS
1#!/bin/sh
2#
3# Copyright (c) 2007 Michael Spang
4#
5
6test_description='git-clean basic tests'
7
8. ./test-lib.sh
9
562ca192
JH
10git config clean.requireForce no
11
ec0e0f25
MS
12test_expect_success 'setup' '
13
14 mkdir -p src &&
15 touch src/part1.c Makefile &&
16 echo build >.gitignore &&
17 echo \*.o >>.gitignore &&
5be60078 18 git add . &&
ec0e0f25
MS
19 git-commit -m setup &&
20 touch src/part2.c README &&
5be60078 21 git add .
ec0e0f25
MS
22
23'
24
25test_expect_success 'git-clean' '
26
27 mkdir -p build docs &&
28 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
29 git-clean &&
30 test -f Makefile &&
31 test -f README &&
32 test -f src/part1.c &&
33 test -f src/part2.c &&
34 test ! -f a.out &&
35 test ! -f src/part3.c &&
36 test -f docs/manual.txt &&
37 test -f obj.o &&
38 test -f build/lib.so
39
40'
41
42test_expect_success 'git-clean -n' '
43
44 mkdir -p build docs &&
45 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
46 git-clean -n &&
47 test -f Makefile &&
48 test -f README &&
49 test -f src/part1.c &&
50 test -f src/part2.c &&
51 test -f a.out &&
52 test -f src/part3.c &&
53 test -f docs/manual.txt &&
54 test -f obj.o &&
55 test -f build/lib.so
56
57'
58
59test_expect_success 'git-clean -d' '
60
61 mkdir -p build docs &&
62 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
63 git-clean -d &&
64 test -f Makefile &&
65 test -f README &&
66 test -f src/part1.c &&
67 test -f src/part2.c &&
68 test ! -f a.out &&
69 test ! -f src/part3.c &&
70 test ! -d docs &&
71 test -f obj.o &&
72 test -f build/lib.so
73
74'
75
76test_expect_success 'git-clean -x' '
77
78 mkdir -p build docs &&
79 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
80 git-clean -x &&
81 test -f Makefile &&
82 test -f README &&
83 test -f src/part1.c &&
84 test -f src/part2.c &&
85 test ! -f a.out &&
86 test ! -f src/part3.c &&
87 test -f docs/manual.txt &&
88 test ! -f obj.o &&
89 test -f build/lib.so
90
91'
92
93test_expect_success 'git-clean -d -x' '
94
95 mkdir -p build docs &&
96 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
97 git-clean -d -x &&
98 test -f Makefile &&
99 test -f README &&
100 test -f src/part1.c &&
101 test -f src/part2.c &&
102 test ! -f a.out &&
103 test ! -f src/part3.c &&
104 test ! -d docs &&
105 test ! -f obj.o &&
106 test ! -d build
107
108'
109
110test_expect_success 'git-clean -X' '
111
112 mkdir -p build docs &&
113 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
114 git-clean -X &&
115 test -f Makefile &&
116 test -f README &&
117 test -f src/part1.c &&
118 test -f src/part2.c &&
119 test -f a.out &&
120 test -f src/part3.c &&
121 test -f docs/manual.txt &&
122 test ! -f obj.o &&
123 test -f build/lib.so
124
125'
126
127test_expect_success 'git-clean -d -X' '
128
129 mkdir -p build docs &&
130 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
131 git-clean -d -X &&
132 test -f Makefile &&
133 test -f README &&
134 test -f src/part1.c &&
135 test -f src/part2.c &&
136 test -f a.out &&
137 test -f src/part3.c &&
138 test -f docs/manual.txt &&
139 test ! -f obj.o &&
140 test ! -d build
141
142'
143
562ca192
JH
144test_expect_success 'clean.requireForce defaults to true' '
145
146 git config --unset clean.requireForce &&
147 ! git-clean
148
149'
150
ec0e0f25
MS
151test_expect_success 'clean.requireForce' '
152
5be60078 153 git config clean.requireForce true &&
ec0e0f25
MS
154 ! git-clean
155
156'
157
158test_expect_success 'clean.requireForce and -n' '
159
160 mkdir -p build docs &&
161 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
162 git-clean -n &&
163 test -f Makefile &&
164 test -f README &&
165 test -f src/part1.c &&
166 test -f src/part2.c &&
167 test -f a.out &&
168 test -f src/part3.c &&
169 test -f docs/manual.txt &&
170 test -f obj.o &&
171 test -f build/lib.so
172
173'
174
175test_expect_success 'clean.requireForce and -f' '
176
177 git-clean -f &&
178 test -f README &&
179 test -f src/part1.c &&
180 test -f src/part2.c &&
181 test ! -f a.out &&
182 test ! -f src/part3.c &&
183 test -f docs/manual.txt &&
184 test -f obj.o &&
185 test -f build/lib.so
186
187'
188
189test_done