cocci: apply "pending" index-compatibility to "t/helper/*.c"
[git/debian.git] / t / t7526-commit-pathspec-file.sh
blobad011bb9f158034171c04e76722b183eece45576
1 #!/bin/sh
3 test_description='commit --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_tick
10 test_expect_success setup '
11 test_commit file0 &&
12 git tag checkpoint &&
14 echo A >fileA.t &&
15 echo B >fileB.t &&
16 echo C >fileC.t &&
17 echo D >fileD.t &&
18 git add fileA.t fileB.t fileC.t fileD.t
21 restore_checkpoint () {
22 git reset --soft checkpoint
25 verify_expect () {
26 git diff-tree --no-commit-id --name-status -r HEAD >actual &&
27 test_cmp expect actual
30 test_expect_success '--pathspec-from-file from stdin' '
31 restore_checkpoint &&
33 echo fileA.t | git commit --pathspec-from-file=- -m "Commit" &&
35 cat >expect <<-\EOF &&
36 A fileA.t
37 EOF
38 verify_expect
41 test_expect_success '--pathspec-from-file from file' '
42 restore_checkpoint &&
44 echo fileA.t >list &&
45 git commit --pathspec-from-file=list -m "Commit" &&
47 cat >expect <<-\EOF &&
48 A fileA.t
49 EOF
50 verify_expect
53 test_expect_success 'NUL delimiters' '
54 restore_checkpoint &&
56 printf "fileA.t\0fileB.t\0" | git commit --pathspec-from-file=- --pathspec-file-nul -m "Commit" &&
58 cat >expect <<-\EOF &&
59 A fileA.t
60 A fileB.t
61 EOF
62 verify_expect
65 test_expect_success 'LF delimiters' '
66 restore_checkpoint &&
68 printf "fileA.t\nfileB.t\n" | git commit --pathspec-from-file=- -m "Commit" &&
70 cat >expect <<-\EOF &&
71 A fileA.t
72 A fileB.t
73 EOF
74 verify_expect
77 test_expect_success 'no trailing delimiter' '
78 restore_checkpoint &&
80 printf "fileA.t\nfileB.t" | git commit --pathspec-from-file=- -m "Commit" &&
82 cat >expect <<-\EOF &&
83 A fileA.t
84 A fileB.t
85 EOF
86 verify_expect
89 test_expect_success 'CRLF delimiters' '
90 restore_checkpoint &&
92 printf "fileA.t\r\nfileB.t\r\n" | git commit --pathspec-from-file=- -m "Commit" &&
94 cat >expect <<-\EOF &&
95 A fileA.t
96 A fileB.t
97 EOF
98 verify_expect
101 test_expect_success 'quotes' '
102 restore_checkpoint &&
104 cat >list <<-\EOF &&
105 "file\101.t"
108 git commit --pathspec-from-file=list -m "Commit" &&
110 cat >expect <<-\EOF &&
111 A fileA.t
113 verify_expect expect
116 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
117 restore_checkpoint &&
119 cat >list <<-\EOF &&
120 "file\101.t"
123 test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit"
126 test_expect_success 'only touches what was listed' '
127 restore_checkpoint &&
129 printf "fileB.t\nfileC.t\n" | git commit --pathspec-from-file=- -m "Commit" &&
131 cat >expect <<-\EOF &&
132 A fileB.t
133 A fileC.t
135 verify_expect
138 test_expect_success 'error conditions' '
139 restore_checkpoint &&
140 echo fileA.t >list &&
141 >empty_list &&
143 test_must_fail git commit --pathspec-from-file=list --interactive -m "Commit" 2>err &&
144 test_i18ngrep -e "options .--pathspec-from-file. and .--interactive/--patch. cannot be used together" err &&
146 test_must_fail git commit --pathspec-from-file=list --patch -m "Commit" 2>err &&
147 test_i18ngrep -e "options .--pathspec-from-file. and .--interactive/--patch. cannot be used together" err &&
149 test_must_fail git commit --pathspec-from-file=list --all -m "Commit" 2>err &&
150 test_i18ngrep -e "options .--pathspec-from-file. and .-a. cannot be used together" err &&
152 test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err &&
153 test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
155 test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err &&
156 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
158 test_must_fail git commit --pathspec-from-file=empty_list --include -m "Commit" 2>err &&
159 test_i18ngrep -e "No paths with --include/--only does not make sense." err &&
161 test_must_fail git commit --pathspec-from-file=empty_list --only -m "Commit" 2>err &&
162 test_i18ngrep -e "No paths with --include/--only does not make sense." err
165 test_done