3 # Copyright (c) 2007 Michael Spang
6 test_description='git-clean basic tests'
10 git config clean.requireForce no
12 test_expect_success 'setup' '
15 touch src/part1.c Makefile &&
16 echo build >.gitignore &&
17 echo \*.o >>.gitignore &&
19 git-commit -m setup &&
20 touch src/part2.c README &&
25 test_expect_success 'git-clean' '
27 mkdir -p build docs &&
28 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
32 test -f src/part1.c &&
33 test -f src/part2.c &&
35 test ! -f src/part3.c &&
36 test -f docs/manual.txt &&
42 test_expect_success 'git-clean src/' '
44 mkdir -p build docs &&
45 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
49 test -f src/part1.c &&
50 test -f src/part2.c &&
52 test ! -f src/part3.c &&
53 test -f docs/manual.txt &&
59 test_expect_success 'git-clean src/ src/' '
61 mkdir -p build docs &&
62 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
63 git-clean src/ src/ &&
66 test -f src/part1.c &&
67 test -f src/part2.c &&
69 test ! -f src/part3.c &&
70 test -f docs/manual.txt &&
76 test_expect_success 'git-clean with prefix' '
78 mkdir -p build docs &&
79 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
80 (cd src/ && git-clean) &&
83 test -f src/part1.c &&
84 test -f src/part2.c &&
86 test ! -f src/part3.c &&
87 test -f docs/manual.txt &&
92 test_expect_success 'git-clean -d with prefix and path' '
94 mkdir -p build docs src/feature &&
95 touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
96 (cd src/ && git-clean -d feature/) &&
99 test -f src/part1.c &&
100 test -f src/part2.c &&
102 test -f src/part3.c &&
103 test ! -f src/feature/file.c &&
104 test -f docs/manual.txt &&
110 test_expect_success 'git-clean symbolic link' '
112 mkdir -p build docs &&
113 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
114 ln -s docs/manual.txt src/part4.c
118 test -f src/part1.c &&
119 test -f src/part2.c &&
121 test ! -f src/part3.c &&
122 test ! -f src/part4.c &&
123 test -f docs/manual.txt &&
129 test_expect_success 'git-clean with wildcard' '
131 touch a.clean b.clean other.c &&
132 git-clean "*.clean" &&
135 test -f src/part1.c &&
136 test -f src/part2.c &&
143 test_expect_success 'git-clean -n' '
145 mkdir -p build docs &&
146 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
150 test -f src/part1.c &&
151 test -f src/part2.c &&
153 test -f src/part3.c &&
154 test -f docs/manual.txt &&
160 test_expect_success 'git-clean -d' '
162 mkdir -p build docs &&
163 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
167 test -f src/part1.c &&
168 test -f src/part2.c &&
170 test ! -f src/part3.c &&
177 test_expect_success 'git-clean -d src/ examples/' '
179 mkdir -p build docs examples &&
180 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
181 git-clean -d src/ examples/ &&
184 test -f src/part1.c &&
185 test -f src/part2.c &&
187 test ! -f src/part3.c &&
188 test ! -f examples/1.c &&
189 test -f docs/manual.txt &&
195 test_expect_success 'git-clean -x' '
197 mkdir -p build docs &&
198 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
202 test -f src/part1.c &&
203 test -f src/part2.c &&
205 test ! -f src/part3.c &&
206 test -f docs/manual.txt &&
212 test_expect_success 'git-clean -d -x' '
214 mkdir -p build docs &&
215 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
219 test -f src/part1.c &&
220 test -f src/part2.c &&
222 test ! -f src/part3.c &&
229 test_expect_success 'git-clean -X' '
231 mkdir -p build docs &&
232 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
236 test -f src/part1.c &&
237 test -f src/part2.c &&
239 test -f src/part3.c &&
240 test -f docs/manual.txt &&
246 test_expect_success 'git-clean -d -X' '
248 mkdir -p build docs &&
249 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
253 test -f src/part1.c &&
254 test -f src/part2.c &&
256 test -f src/part3.c &&
257 test -f docs/manual.txt &&
263 test_expect_success 'clean.requireForce defaults to true' '
265 git config --unset clean.requireForce &&
270 test_expect_success 'clean.requireForce' '
272 git config clean.requireForce true &&
277 test_expect_success 'clean.requireForce and -n' '
279 mkdir -p build docs &&
280 touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
284 test -f src/part1.c &&
285 test -f src/part2.c &&
287 test -f src/part3.c &&
288 test -f docs/manual.txt &&
294 test_expect_success 'clean.requireForce and -f' '
298 test -f src/part1.c &&
299 test -f src/part2.c &&
301 test ! -f src/part3.c &&
302 test -f docs/manual.txt &&
308 test_expect_success 'core.excludesfile' '
310 echo excludes >excludes &&
311 echo included >included &&
312 git config core.excludesfile excludes &&
313 output=$(git clean -n excludes included 2>&1) &&
314 expr "$output" : ".*included" >/dev/null &&
315 ! expr "$output" : ".*excludes" >/dev/null