Fourth batch
[git/raj.git] / t / t3601-rm-pathspec-file.sh
blob7de21f8bcff1c5cf713c69e3ed1c8ff9a41c10a8
1 #!/bin/sh
3 test_description='rm --pathspec-from-file'
5 . ./test-lib.sh
7 test_tick
9 test_expect_success setup '
10 echo A >fileA.t &&
11 echo B >fileB.t &&
12 echo C >fileC.t &&
13 echo D >fileD.t &&
14 git add fileA.t fileB.t fileC.t fileD.t &&
15 git commit -m "files" &&
17 git tag checkpoint
20 restore_checkpoint () {
21 git reset --hard checkpoint
24 verify_expect () {
25 git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
26 test_cmp expect actual
29 test_expect_success 'simplest' '
30 restore_checkpoint &&
32 cat >expect <<-\EOF &&
33 D fileA.t
34 EOF
36 echo fileA.t | git rm --pathspec-from-file=- &&
37 verify_expect
40 test_expect_success '--pathspec-file-nul' '
41 restore_checkpoint &&
43 cat >expect <<-\EOF &&
44 D fileA.t
45 D fileB.t
46 EOF
48 printf "fileA.t\0fileB.t\0" | git rm --pathspec-from-file=- --pathspec-file-nul &&
49 verify_expect
52 test_expect_success 'only touches what was listed' '
53 restore_checkpoint &&
55 cat >expect <<-\EOF &&
56 D fileB.t
57 D fileC.t
58 EOF
60 printf "fileB.t\nfileC.t\n" | git rm --pathspec-from-file=- &&
61 verify_expect
64 test_expect_success 'error conditions' '
65 restore_checkpoint &&
66 echo fileA.t >list &&
68 test_must_fail git rm --pathspec-from-file=list -- fileA.t 2>err &&
69 test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
71 test_must_fail git rm --pathspec-file-nul 2>err &&
72 test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
74 >empty_list &&
75 test_must_fail git rm --pathspec-from-file=empty_list 2>err &&
76 test_i18ngrep -e "No pathspec was given. Which files should I remove?" err
79 test_done