3 test_description
='reset --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success setup
'
16 git commit --include . -m "Commit" &&
20 restore_checkpoint
() {
21 git
reset --hard checkpoint
25 git status
--porcelain -- fileA.t fileB.t fileC.t fileD.t
>actual
&&
28 ! test_cmp expect actual
30 test_cmp expect actual
34 test_expect_success
'--pathspec-from-file from stdin' '
38 echo fileA.t | git reset --pathspec-from-file=- &&
40 cat >expect <<-\EOF &&
46 test_expect_success
'--pathspec-from-file from file' '
51 git reset --pathspec-from-file=list &&
53 cat >expect <<-\EOF &&
59 test_expect_success
'NUL delimiters' '
62 git rm fileA.t fileB.t &&
63 printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul &&
65 cat >expect <<-\EOF &&
72 test_expect_success
'LF delimiters' '
75 git rm fileA.t fileB.t &&
76 printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- &&
78 cat >expect <<-\EOF &&
85 test_expect_success
'no trailing delimiter' '
88 git rm fileA.t fileB.t &&
89 printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- &&
91 cat >expect <<-\EOF &&
98 test_expect_success
'CRLF delimiters' '
101 git rm fileA.t fileB.t &&
102 printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- &&
104 cat >expect <<-\EOF &&
111 test_expect_success
'quotes' '
112 restore_checkpoint &&
119 git reset --pathspec-from-file=list &&
121 cat >expect <<-\EOF &&
127 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
128 restore_checkpoint &&
134 # Note: "git reset" has not yet learned to fail on wrong pathspecs
135 git reset --pathspec-from-file=list --pathspec-file-nul &&
137 cat >expect <<-\EOF &&
143 test_expect_success
'only touches what was listed' '
144 restore_checkpoint &&
146 git rm fileA.t fileB.t fileC.t fileD.t &&
147 printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- &&
149 cat >expect <<-\EOF &&
158 test_expect_success
'error conditions' '
159 restore_checkpoint &&
160 echo fileA.t >list &&
163 test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
164 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
166 test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
167 test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
169 test_must_fail git reset --pathspec-file-nul 2>err &&
170 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
172 test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
173 test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
175 test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
176 test_i18ngrep -e "fatal: Cannot do hard reset with paths" err