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