3 test_description='git clean -i basic tests'
7 test_expect_success 'setup' '
10 touch src/part1.c Makefile &&
11 echo build >.gitignore &&
12 echo \*.o >>.gitignore &&
14 git commit -m setup &&
15 touch src/part2.c README &&
20 test_expect_success 'git clean -i (clean)' '
22 mkdir -p build docs &&
23 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
24 docs/manual.txt obj.o build/lib.so &&
25 echo c | git clean -i &&
28 test -f src/part1.c &&
29 test -f src/part2.c &&
31 test -f docs/manual.txt &&
32 test ! -f src/part3.c &&
33 test ! -f src/part3.h &&
34 test ! -f src/part4.c &&
35 test ! -f src/part4.h &&
41 test_expect_success 'git clean -i (quit)' '
43 mkdir -p build docs &&
44 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
45 docs/manual.txt obj.o build/lib.so &&
46 echo q | git clean -i &&
49 test -f src/part1.c &&
50 test -f src/part2.c &&
52 test -f docs/manual.txt &&
53 test -f src/part3.c &&
54 test -f src/part3.h &&
55 test -f src/part4.c &&
56 test -f src/part4.h &&
62 test_expect_success 'git clean -i (Ctrl+D)' '
64 mkdir -p build docs &&
65 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
66 docs/manual.txt obj.o build/lib.so &&
67 echo "\04" | git clean -i &&
70 test -f src/part1.c &&
71 test -f src/part2.c &&
73 test -f docs/manual.txt &&
74 test -f src/part3.c &&
75 test -f src/part3.h &&
76 test -f src/part4.c &&
77 test -f src/part4.h &&
83 test_expect_success 'git clean -id (filter all)' '
85 mkdir -p build docs &&
86 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
87 docs/manual.txt obj.o build/lib.so &&
88 (echo f; echo "*"; echo; echo c) | \
92 test -f src/part1.c &&
93 test -f src/part2.c &&
95 test -f docs/manual.txt &&
96 test -f src/part3.c &&
97 test -f src/part3.h &&
98 test -f src/part4.c &&
99 test -f src/part4.h &&
105 test_expect_success 'git clean -id (filter patterns)' '
107 mkdir -p build docs &&
108 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
109 docs/manual.txt obj.o build/lib.so &&
110 (echo f; echo "part3.* *.out"; echo; echo c) | \
114 test -f src/part1.c &&
115 test -f src/part2.c &&
117 test ! -f docs/manual.txt &&
118 test -f src/part3.c &&
119 test -f src/part3.h &&
120 test ! -f src/part4.c &&
121 test ! -f src/part4.h &&
127 test_expect_success 'git clean -id (filter patterns 2)' '
129 mkdir -p build docs &&
130 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
131 docs/manual.txt obj.o build/lib.so &&
132 (echo f; echo "* !*.out"; echo; echo c) | \
136 test -f src/part1.c &&
137 test -f src/part2.c &&
139 test -f docs/manual.txt &&
140 test -f src/part3.c &&
141 test -f src/part3.h &&
142 test -f src/part4.c &&
143 test -f src/part4.h &&
149 test_expect_success 'git clean -id (select - all)' '
151 mkdir -p build docs &&
152 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
153 docs/manual.txt obj.o build/lib.so &&
154 (echo s; echo "*"; echo; echo c) | \
158 test -f src/part1.c &&
159 test -f src/part2.c &&
161 test ! -f docs/manual.txt &&
162 test ! -f src/part3.c &&
163 test ! -f src/part3.h &&
164 test ! -f src/part4.c &&
165 test ! -f src/part4.h &&
171 test_expect_success 'git clean -id (select - none)' '
173 mkdir -p build docs &&
174 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
175 docs/manual.txt obj.o build/lib.so &&
176 (echo s; echo; echo c) | \
180 test -f src/part1.c &&
181 test -f src/part2.c &&
183 test -f docs/manual.txt &&
184 test -f src/part3.c &&
185 test -f src/part3.h &&
186 test -f src/part4.c &&
187 test -f src/part4.h &&
193 test_expect_success 'git clean -id (select - number)' '
195 mkdir -p build docs &&
196 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
197 docs/manual.txt obj.o build/lib.so &&
198 (echo s; echo 3; echo; echo c) | \
202 test -f src/part1.c &&
203 test -f src/part2.c &&
205 test -f docs/manual.txt &&
206 test ! -f src/part3.c &&
207 test -f src/part3.h &&
208 test -f src/part4.c &&
209 test -f src/part4.h &&
215 test_expect_success 'git clean -id (select - number 2)' '
217 mkdir -p build docs &&
218 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
219 docs/manual.txt obj.o build/lib.so &&
220 (echo s; echo 2 3; echo 5; echo; echo c) | \
224 test -f src/part1.c &&
225 test -f src/part2.c &&
227 test ! -f docs/manual.txt &&
228 test ! -f src/part3.c &&
229 test -f src/part3.h &&
230 test ! -f src/part4.c &&
231 test -f src/part4.h &&
237 test_expect_success 'git clean -id (select - number 3)' '
239 mkdir -p build docs &&
240 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
241 docs/manual.txt obj.o build/lib.so &&
242 (echo s; echo 3,4 5; echo; echo c) | \
246 test -f src/part1.c &&
247 test -f src/part2.c &&
249 test -f docs/manual.txt &&
250 test ! -f src/part3.c &&
251 test ! -f src/part3.h &&
252 test ! -f src/part4.c &&
253 test -f src/part4.h &&
259 test_expect_success 'git clean -id (select - range)' '
261 mkdir -p build docs &&
262 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
263 docs/manual.txt obj.o build/lib.so &&
264 (echo s; echo 1,3-4; echo 2; echo; echo c) | \
268 test -f src/part1.c &&
269 test -f src/part2.c &&
271 test ! -f src/part3.c &&
272 test ! -f src/part3.h &&
273 test -f src/part4.c &&
274 test -f src/part4.h &&
275 test ! -f docs/manual.txt &&
281 test_expect_success 'git clean -id (select - range 2)' '
283 mkdir -p build docs &&
284 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
285 docs/manual.txt obj.o build/lib.so &&
286 (echo s; echo 4- 1; echo; echo c) | \
290 test -f src/part1.c &&
291 test -f src/part2.c &&
293 test -f docs/manual.txt &&
294 test -f src/part3.c &&
295 test ! -f src/part3.h &&
296 test ! -f src/part4.c &&
297 test ! -f src/part4.h &&
303 test_expect_success 'git clean -id (inverse select)' '
305 mkdir -p build docs &&
306 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
307 docs/manual.txt obj.o build/lib.so &&
308 (echo s; echo "*"; echo -5- 1 -2; echo; echo c) | \
312 test -f src/part1.c &&
313 test -f src/part2.c &&
315 test -f docs/manual.txt &&
316 test ! -f src/part3.c &&
317 test ! -f src/part3.h &&
318 test -f src/part4.c &&
319 test -f src/part4.h &&
325 test_expect_success 'git clean -id (ask)' '
327 mkdir -p build docs &&
328 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
329 docs/manual.txt obj.o build/lib.so &&
330 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
334 test -f src/part1.c &&
335 test -f src/part2.c &&
337 test ! -f docs/manual.txt &&
338 test -f src/part3.c &&
339 test ! -f src/part3.h &&
340 test -f src/part4.c &&
341 test -f src/part4.h &&
347 test_expect_success 'git clean -id (ask - Ctrl+D)' '
349 mkdir -p build docs &&
350 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
351 docs/manual.txt obj.o build/lib.so &&
352 (echo a; echo Y; echo no; echo yes; echo "\04") | \
356 test -f src/part1.c &&
357 test -f src/part2.c &&
359 test -f docs/manual.txt &&
360 test ! -f src/part3.c &&
361 test -f src/part3.h &&
362 test -f src/part4.c &&
363 test -f src/part4.h &&
369 test_expect_success 'git clean -id with prefix and path (filter)' '
371 mkdir -p build docs &&
372 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
373 docs/manual.txt obj.o build/lib.so &&
375 (echo f; echo "docs"; echo "*.h"; echo ; echo c) | \
379 test -f src/part1.c &&
380 test -f src/part2.c &&
382 test -f docs/manual.txt &&
383 test ! -f src/part3.c &&
384 test -f src/part3.h &&
385 test ! -f src/part4.c &&
386 test -f src/part4.h &&
392 test_expect_success 'git clean -id with prefix and path (select by name)' '
394 mkdir -p build docs &&
395 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
396 docs/manual.txt obj.o build/lib.so &&
398 (echo s; echo "../docs/"; echo "../src/part3.c"; \
399 echo "../src/part4.c"; echo; echo c) | \
403 test -f src/part1.c &&
404 test -f src/part2.c &&
406 test ! -f docs/manual.txt &&
407 test ! -f src/part3.c &&
408 test -f src/part3.h &&
409 test ! -f src/part4.c &&
410 test -f src/part4.h &&
416 test_expect_success 'git clean -id with prefix and path (ask)' '
418 mkdir -p build docs &&
419 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
420 docs/manual.txt obj.o build/lib.so &&
422 (echo a; echo Y; echo y; echo no; echo yes; echo bad; echo) | \
426 test -f src/part1.c &&
427 test -f src/part2.c &&
429 test ! -f docs/manual.txt &&
430 test -f src/part3.c &&
431 test ! -f src/part3.h &&
432 test -f src/part4.c &&
433 test -f src/part4.h &&