]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7301-clean-interactive.sh
The third batch
[thirdparty/git.git] / t / t7301-clean-interactive.sh
CommitLineData
db627fd5
JX
1#!/bin/sh
2
3test_description='git clean -i basic tests'
4
7615cf94 5TEST_PASSES_SANITIZE_LEAK=true
db627fd5 6. ./test-lib.sh
3c788e79 7. "$TEST_DIRECTORY"/lib-terminal.sh
db627fd5
JX
8
9test_expect_success 'setup' '
10
11 mkdir -p src &&
12 touch src/part1.c Makefile &&
13 echo build >.gitignore &&
14 echo \*.o >>.gitignore &&
15 git add . &&
16 git commit -m setup &&
17 touch src/part2.c README &&
18 git add .
19
20'
21
60838613 22test_expect_success 'git clean -i (c: clean hotkey)' '
db627fd5
JX
23
24 mkdir -p build docs &&
25 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
26 docs/manual.txt obj.o build/lib.so &&
27 echo c | git clean -i &&
9a90118d
VM
28 test_path_is_file Makefile &&
29 test_path_is_file README &&
30 test_path_is_file src/part1.c &&
31 test_path_is_file src/part2.c &&
32 test_path_is_missing a.out &&
33 test_path_is_file docs/manual.txt &&
34 test_path_is_missing src/part3.c &&
35 test_path_is_missing src/part3.h &&
36 test_path_is_missing src/part4.c &&
37 test_path_is_missing src/part4.h &&
38 test_path_is_file obj.o &&
39 test_path_is_file build/lib.so
db627fd5
JX
40
41'
42
60838613
JX
43test_expect_success 'git clean -i (cl: clean prefix)' '
44
45 mkdir -p build docs &&
46 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
47 docs/manual.txt obj.o build/lib.so &&
48 echo cl | git clean -i &&
9a90118d
VM
49 test_path_is_file Makefile &&
50 test_path_is_file README &&
51 test_path_is_file src/part1.c &&
52 test_path_is_file src/part2.c &&
53 test_path_is_missing a.out &&
54 test_path_is_file docs/manual.txt &&
55 test_path_is_missing src/part3.c &&
56 test_path_is_missing src/part3.h &&
57 test_path_is_missing src/part4.c &&
58 test_path_is_missing src/part4.h &&
59 test_path_is_file obj.o &&
60 test_path_is_file build/lib.so
60838613
JX
61
62'
63
db627fd5
JX
64test_expect_success 'git clean -i (quit)' '
65
66 mkdir -p build docs &&
67 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
68 docs/manual.txt obj.o build/lib.so &&
60838613 69 echo quit | git clean -i &&
9a90118d
VM
70 test_path_is_file Makefile &&
71 test_path_is_file README &&
72 test_path_is_file src/part1.c &&
73 test_path_is_file src/part2.c &&
74 test_path_is_file a.out &&
75 test_path_is_file docs/manual.txt &&
76 test_path_is_file src/part3.c &&
77 test_path_is_file src/part3.h &&
78 test_path_is_file src/part4.c &&
79 test_path_is_file src/part4.h &&
80 test_path_is_file obj.o &&
81 test_path_is_file build/lib.so
db627fd5
JX
82
83'
84
85test_expect_success 'git clean -i (Ctrl+D)' '
86
87 mkdir -p build docs &&
88 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
89 docs/manual.txt obj.o build/lib.so &&
90 echo "\04" | git clean -i &&
9a90118d
VM
91 test_path_is_file Makefile &&
92 test_path_is_file README &&
93 test_path_is_file src/part1.c &&
94 test_path_is_file src/part2.c &&
95 test_path_is_file a.out &&
96 test_path_is_file docs/manual.txt &&
97 test_path_is_file src/part3.c &&
98 test_path_is_file src/part3.h &&
99 test_path_is_file src/part4.c &&
100 test_path_is_file src/part4.h &&
101 test_path_is_file obj.o &&
102 test_path_is_file build/lib.so
db627fd5
JX
103
104'
105
106test_expect_success 'git clean -id (filter all)' '
107
108 mkdir -p build docs &&
109 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
110 docs/manual.txt obj.o build/lib.so &&
0590ff26 111 test_write_lines f "*" "" c |
db627fd5 112 git clean -id &&
9a90118d
VM
113 test_path_is_file Makefile &&
114 test_path_is_file README &&
115 test_path_is_file src/part1.c &&
116 test_path_is_file src/part2.c &&
117 test_path_is_file a.out &&
118 test_path_is_file docs/manual.txt &&
119 test_path_is_file src/part3.c &&
120 test_path_is_file src/part3.h &&
121 test_path_is_file src/part4.c &&
122 test_path_is_file src/part4.h &&
123 test_path_is_file obj.o &&
124 test_path_is_file build/lib.so
db627fd5
JX
125
126'
127
128test_expect_success 'git clean -id (filter patterns)' '
129
130 mkdir -p build docs &&
131 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
132 docs/manual.txt obj.o build/lib.so &&
0590ff26 133 test_write_lines f "part3.* *.out" "" c |
db627fd5 134 git clean -id &&
9a90118d
VM
135 test_path_is_file Makefile &&
136 test_path_is_file README &&
137 test_path_is_file src/part1.c &&
138 test_path_is_file src/part2.c &&
139 test_path_is_file a.out &&
140 test_path_is_missing docs/manual.txt &&
141 test_path_is_file src/part3.c &&
142 test_path_is_file src/part3.h &&
143 test_path_is_missing src/part4.c &&
144 test_path_is_missing src/part4.h &&
145 test_path_is_file obj.o &&
146 test_path_is_file build/lib.so
db627fd5
JX
147
148'
149
150test_expect_success 'git clean -id (filter patterns 2)' '
151
152 mkdir -p build docs &&
153 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
154 docs/manual.txt obj.o build/lib.so &&
0590ff26 155 test_write_lines f "* !*.out" "" c |
db627fd5 156 git clean -id &&
9a90118d
VM
157 test_path_is_file Makefile &&
158 test_path_is_file README &&
159 test_path_is_file src/part1.c &&
160 test_path_is_file src/part2.c &&
161 test_path_is_missing a.out &&
162 test_path_is_file docs/manual.txt &&
163 test_path_is_file src/part3.c &&
164 test_path_is_file src/part3.h &&
165 test_path_is_file src/part4.c &&
166 test_path_is_file src/part4.h &&
167 test_path_is_file obj.o &&
168 test_path_is_file build/lib.so
db627fd5
JX
169
170'
171
172test_expect_success 'git clean -id (select - all)' '
173
174 mkdir -p build docs &&
175 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
176 docs/manual.txt obj.o build/lib.so &&
0590ff26 177 test_write_lines s "*" "" c |
db627fd5 178 git clean -id &&
9a90118d
VM
179 test_path_is_file Makefile &&
180 test_path_is_file README &&
181 test_path_is_file src/part1.c &&
182 test_path_is_file src/part2.c &&
183 test_path_is_missing a.out &&
184 test_path_is_missing docs/manual.txt &&
185 test_path_is_missing src/part3.c &&
186 test_path_is_missing src/part3.h &&
187 test_path_is_missing src/part4.c &&
188 test_path_is_missing src/part4.h &&
189 test_path_is_file obj.o &&
190 test_path_is_file build/lib.so
db627fd5
JX
191
192'
193
194test_expect_success 'git clean -id (select - none)' '
195
196 mkdir -p build docs &&
197 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
198 docs/manual.txt obj.o build/lib.so &&
0590ff26 199 test_write_lines s "" c |
db627fd5 200 git clean -id &&
9a90118d
VM
201 test_path_is_file Makefile &&
202 test_path_is_file README &&
203 test_path_is_file src/part1.c &&
204 test_path_is_file src/part2.c &&
205 test_path_is_file a.out &&
206 test_path_is_file docs/manual.txt &&
207 test_path_is_file src/part3.c &&
208 test_path_is_file src/part3.h &&
209 test_path_is_file src/part4.c &&
210 test_path_is_file src/part4.h &&
211 test_path_is_file obj.o &&
212 test_path_is_file build/lib.so
db627fd5
JX
213
214'
215
216test_expect_success 'git clean -id (select - number)' '
217
218 mkdir -p build docs &&
219 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
220 docs/manual.txt obj.o build/lib.so &&
0590ff26 221 test_write_lines s 3 "" c |
db627fd5 222 git clean -id &&
9a90118d
VM
223 test_path_is_file Makefile &&
224 test_path_is_file README &&
225 test_path_is_file src/part1.c &&
226 test_path_is_file src/part2.c &&
227 test_path_is_file a.out &&
228 test_path_is_file docs/manual.txt &&
229 test_path_is_missing src/part3.c &&
230 test_path_is_file src/part3.h &&
231 test_path_is_file src/part4.c &&
232 test_path_is_file src/part4.h &&
233 test_path_is_file obj.o &&
234 test_path_is_file build/lib.so
db627fd5
JX
235
236'
237
238test_expect_success 'git clean -id (select - number 2)' '
239
240 mkdir -p build docs &&
241 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
242 docs/manual.txt obj.o build/lib.so &&
0590ff26 243 test_write_lines s "2 3" 5 "" c |
db627fd5 244 git clean -id &&
9a90118d
VM
245 test_path_is_file Makefile &&
246 test_path_is_file README &&
247 test_path_is_file src/part1.c &&
248 test_path_is_file src/part2.c &&
249 test_path_is_file a.out &&
250 test_path_is_missing docs/manual.txt &&
251 test_path_is_missing src/part3.c &&
252 test_path_is_file src/part3.h &&
253 test_path_is_missing src/part4.c &&
254 test_path_is_file src/part4.h &&
255 test_path_is_file obj.o &&
256 test_path_is_file build/lib.so
db627fd5
JX
257
258'
259
260test_expect_success 'git clean -id (select - number 3)' '
261
262 mkdir -p build docs &&
263 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
264 docs/manual.txt obj.o build/lib.so &&
0590ff26 265 test_write_lines s "3,4 5" "" c |
db627fd5 266 git clean -id &&
9a90118d
VM
267 test_path_is_file Makefile &&
268 test_path_is_file README &&
269 test_path_is_file src/part1.c &&
270 test_path_is_file src/part2.c &&
271 test_path_is_file a.out &&
272 test_path_is_file docs/manual.txt &&
273 test_path_is_missing src/part3.c &&
274 test_path_is_missing src/part3.h &&
275 test_path_is_missing src/part4.c &&
276 test_path_is_file src/part4.h &&
277 test_path_is_file obj.o &&
278 test_path_is_file build/lib.so
db627fd5
JX
279
280'
281
60838613
JX
282test_expect_success 'git clean -id (select - filenames)' '
283
284 mkdir -p build docs &&
285 touch a.out foo.txt bar.txt baz.txt &&
0590ff26 286 test_write_lines s "a.out fo ba bar" "" c |
60838613 287 git clean -id &&
9a90118d
VM
288 test_path_is_file Makefile &&
289 test_path_is_missing a.out &&
290 test_path_is_missing foo.txt &&
291 test_path_is_missing bar.txt &&
292 test_path_is_file baz.txt &&
60838613
JX
293 rm baz.txt
294
295'
296
db627fd5
JX
297test_expect_success 'git clean -id (select - range)' '
298
299 mkdir -p build docs &&
300 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
301 docs/manual.txt obj.o build/lib.so &&
0590ff26 302 test_write_lines s "1,3-4" 2 "" c |
db627fd5 303 git clean -id &&
9a90118d
VM
304 test_path_is_file Makefile &&
305 test_path_is_file README &&
306 test_path_is_file src/part1.c &&
307 test_path_is_file src/part2.c &&
308 test_path_is_missing a.out &&
309 test_path_is_missing src/part3.c &&
310 test_path_is_missing src/part3.h &&
311 test_path_is_file src/part4.c &&
312 test_path_is_file src/part4.h &&
313 test_path_is_missing docs/manual.txt &&
314 test_path_is_file obj.o &&
315 test_path_is_file build/lib.so
db627fd5
JX
316
317'
318
319test_expect_success 'git clean -id (select - range 2)' '
320
321 mkdir -p build docs &&
322 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
323 docs/manual.txt obj.o build/lib.so &&
0590ff26 324 test_write_lines s "4- 1" "" c |
db627fd5 325 git clean -id &&
9a90118d
VM
326 test_path_is_file Makefile &&
327 test_path_is_file README &&
328 test_path_is_file src/part1.c &&
329 test_path_is_file src/part2.c &&
330 test_path_is_missing a.out &&
331 test_path_is_file docs/manual.txt &&
332 test_path_is_file src/part3.c &&
333 test_path_is_missing src/part3.h &&
334 test_path_is_missing src/part4.c &&
335 test_path_is_missing src/part4.h &&
336 test_path_is_file obj.o &&
337 test_path_is_file build/lib.so
db627fd5
JX
338
339'
340
341test_expect_success 'git clean -id (inverse select)' '
342
343 mkdir -p build docs &&
344 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
345 docs/manual.txt obj.o build/lib.so &&
0590ff26 346 test_write_lines s "*" "-5- 1 -2" "" c |
db627fd5 347 git clean -id &&
9a90118d
VM
348 test_path_is_file Makefile &&
349 test_path_is_file README &&
350 test_path_is_file src/part1.c &&
351 test_path_is_file src/part2.c &&
352 test_path_is_missing a.out &&
353 test_path_is_file docs/manual.txt &&
354 test_path_is_missing src/part3.c &&
355 test_path_is_missing src/part3.h &&
356 test_path_is_file src/part4.c &&
357 test_path_is_file src/part4.h &&
358 test_path_is_file obj.o &&
359 test_path_is_file build/lib.so
db627fd5
JX
360
361'
362
363test_expect_success 'git clean -id (ask)' '
364
365 mkdir -p build docs &&
366 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
367 docs/manual.txt obj.o build/lib.so &&
0590ff26 368 test_write_lines a Y y no yes bad "" |
db627fd5 369 git clean -id &&
9a90118d
VM
370 test_path_is_file Makefile &&
371 test_path_is_file README &&
372 test_path_is_file src/part1.c &&
373 test_path_is_file src/part2.c &&
374 test_path_is_missing a.out &&
375 test_path_is_missing docs/manual.txt &&
376 test_path_is_file src/part3.c &&
377 test_path_is_missing src/part3.h &&
378 test_path_is_file src/part4.c &&
379 test_path_is_file src/part4.h &&
380 test_path_is_file obj.o &&
381 test_path_is_file build/lib.so
db627fd5
JX
382
383'
384
385test_expect_success 'git clean -id (ask - Ctrl+D)' '
386
387 mkdir -p build docs &&
388 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
389 docs/manual.txt obj.o build/lib.so &&
0590ff26 390 test_write_lines a Y no yes "\04" |
db627fd5 391 git clean -id &&
9a90118d
VM
392 test_path_is_file Makefile &&
393 test_path_is_file README &&
394 test_path_is_file src/part1.c &&
395 test_path_is_file src/part2.c &&
396 test_path_is_missing a.out &&
397 test_path_is_file docs/manual.txt &&
398 test_path_is_missing src/part3.c &&
399 test_path_is_file src/part3.h &&
400 test_path_is_file src/part4.c &&
401 test_path_is_file src/part4.h &&
402 test_path_is_file obj.o &&
403 test_path_is_file build/lib.so
db627fd5
JX
404
405'
406
407test_expect_success 'git clean -id with prefix and path (filter)' '
408
409 mkdir -p build docs &&
410 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
411 docs/manual.txt obj.o build/lib.so &&
0590ff26
ES
412 (cd build/ &&
413 test_write_lines f docs "*.h" "" c |
db627fd5 414 git clean -id ..) &&
9a90118d
VM
415 test_path_is_file Makefile &&
416 test_path_is_file README &&
417 test_path_is_file src/part1.c &&
418 test_path_is_file src/part2.c &&
419 test_path_is_missing a.out &&
420 test_path_is_file docs/manual.txt &&
421 test_path_is_missing src/part3.c &&
422 test_path_is_file src/part3.h &&
423 test_path_is_missing src/part4.c &&
424 test_path_is_file src/part4.h &&
425 test_path_is_file obj.o &&
426 test_path_is_file build/lib.so
db627fd5
JX
427
428'
429
430test_expect_success 'git clean -id with prefix and path (select by name)' '
431
432 mkdir -p build docs &&
433 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
434 docs/manual.txt obj.o build/lib.so &&
0590ff26
ES
435 (cd build/ &&
436 test_write_lines s ../docs/ ../src/part3.c ../src/part4.c "" c |
db627fd5 437 git clean -id ..) &&
9a90118d
VM
438 test_path_is_file Makefile &&
439 test_path_is_file README &&
440 test_path_is_file src/part1.c &&
441 test_path_is_file src/part2.c &&
442 test_path_is_file a.out &&
443 test_path_is_missing docs/manual.txt &&
444 test_path_is_missing src/part3.c &&
445 test_path_is_file src/part3.h &&
446 test_path_is_missing src/part4.c &&
447 test_path_is_file src/part4.h &&
448 test_path_is_file obj.o &&
449 test_path_is_file build/lib.so
db627fd5
JX
450
451'
452
453test_expect_success 'git clean -id with prefix and path (ask)' '
454
455 mkdir -p build docs &&
456 touch a.out src/part3.c src/part3.h src/part4.c src/part4.h \
457 docs/manual.txt obj.o build/lib.so &&
0590ff26
ES
458 (cd build/ &&
459 test_write_lines a Y y no yes bad "" |
db627fd5 460 git clean -id ..) &&
9a90118d
VM
461 test_path_is_file Makefile &&
462 test_path_is_file README &&
463 test_path_is_file src/part1.c &&
464 test_path_is_file src/part2.c &&
465 test_path_is_missing a.out &&
466 test_path_is_missing docs/manual.txt &&
467 test_path_is_file src/part3.c &&
468 test_path_is_missing src/part3.h &&
469 test_path_is_file src/part4.c &&
470 test_path_is_file src/part4.h &&
471 test_path_is_file obj.o &&
472 test_path_is_file build/lib.so
db627fd5
JX
473
474'
475
3c788e79 476test_expect_success TTY 'git clean -i paints the header in HEADER color' '
512f41cf
JH
477 >a.out &&
478 echo q |
aebd2350 479 test_terminal git clean -i |
512f41cf
JH
480 test_decode_color |
481 head -n 1 >header &&
482 # not i18ngrep
483 grep "^<BOLD>" header
484'
485
db627fd5 486test_done