Merge branch 'cl/config-regexp-docfix' into maint-2.46
[git/gitster.git] / t / t3601-rm-pathspec-file.sh
blob7cef12981c4be0b611f70fe021d5960f1ad4e5a8
1 #!/bin/sh
3 test_description='rm --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_tick
10 test_expect_success setup '
11 echo A >fileA.t &&
12 echo B >fileB.t &&
13 echo C >fileC.t &&
14 echo D >fileD.t &&
15 git add fileA.t fileB.t fileC.t fileD.t &&
16 git commit -m "files" &&
18 git tag checkpoint
21 restore_checkpoint () {
22 git reset --hard checkpoint
25 verify_expect () {
26 git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
27 test_cmp expect actual
30 test_expect_success 'simplest' '
31 restore_checkpoint &&
33 cat >expect <<-\EOF &&
34 D fileA.t
35 EOF
37 echo fileA.t | git rm --pathspec-from-file=- &&
38 verify_expect
41 test_expect_success '--pathspec-file-nul' '
42 restore_checkpoint &&
44 cat >expect <<-\EOF &&
45 D fileA.t
46 D fileB.t
47 EOF
49 printf "fileA.t\0fileB.t\0" | git rm --pathspec-from-file=- --pathspec-file-nul &&
50 verify_expect
53 test_expect_success 'only touches what was listed' '
54 restore_checkpoint &&
56 cat >expect <<-\EOF &&
57 D fileB.t
58 D fileC.t
59 EOF
61 printf "fileB.t\nfileC.t\n" | git rm --pathspec-from-file=- &&
62 verify_expect
65 test_expect_success 'error conditions' '
66 restore_checkpoint &&
67 echo fileA.t >list &&
69 test_must_fail git rm --pathspec-from-file=list -- fileA.t 2>err &&
70 test_grep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
72 test_must_fail git rm --pathspec-file-nul 2>err &&
73 test_grep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
75 >empty_list &&
76 test_must_fail git rm --pathspec-from-file=empty_list 2>err &&
77 test_grep -e "No pathspec was given. Which files should I remove?" err
80 test_done