3 test_description
='commit --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success setup
'
18 git add fileA.t fileB.t fileC.t fileD.t
21 restore_checkpoint
() {
22 git
reset --soft checkpoint
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' '
33 echo fileA.t | git commit --pathspec-from-file=- -m "Commit" &&
35 cat >expect <<-\EOF &&
41 test_expect_success
'--pathspec-from-file from file' '
45 git commit --pathspec-from-file=list -m "Commit" &&
47 cat >expect <<-\EOF &&
53 test_expect_success
'NUL delimiters' '
56 printf "fileA.t\0fileB.t\0" | git commit --pathspec-from-file=- --pathspec-file-nul -m "Commit" &&
58 cat >expect <<-\EOF &&
65 test_expect_success
'LF delimiters' '
68 printf "fileA.t\nfileB.t\n" | git commit --pathspec-from-file=- -m "Commit" &&
70 cat >expect <<-\EOF &&
77 test_expect_success
'no trailing delimiter' '
80 printf "fileA.t\nfileB.t" | git commit --pathspec-from-file=- -m "Commit" &&
82 cat >expect <<-\EOF &&
89 test_expect_success
'CRLF delimiters' '
92 printf "fileA.t\r\nfileB.t\r\n" | git commit --pathspec-from-file=- -m "Commit" &&
94 cat >expect <<-\EOF &&
101 test_expect_success
'quotes' '
102 restore_checkpoint &&
108 git commit --pathspec-from-file=list -m "Commit" &&
110 cat >expect <<-\EOF &&
116 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
117 restore_checkpoint &&
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 &&
138 test_expect_success
'error conditions' '
139 restore_checkpoint &&
140 echo fileA.t >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 is incompatible with pathspec arguments" err &&
155 test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err &&
156 test_i18ngrep -e "--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