3 test_description
='reset --pathspec-from-file'
9 test_expect_success setup
'
15 git commit --include . -m "Commit" &&
19 restore_checkpoint
() {
20 git
reset --hard checkpoint
24 git status
--porcelain -- fileA.t fileB.t fileC.t fileD.t
>actual
&&
27 ! test_cmp expect actual
29 test_cmp expect actual
33 test_expect_success
'--pathspec-from-file from stdin' '
37 echo fileA.t | git reset --pathspec-from-file=- &&
39 cat >expect <<-\EOF &&
45 test_expect_success
'--pathspec-from-file from file' '
50 git reset --pathspec-from-file=list &&
52 cat >expect <<-\EOF &&
58 test_expect_success
'NUL delimiters' '
61 git rm fileA.t fileB.t &&
62 printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul &&
64 cat >expect <<-\EOF &&
71 test_expect_success
'LF delimiters' '
74 git rm fileA.t fileB.t &&
75 printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- &&
77 cat >expect <<-\EOF &&
84 test_expect_success
'no trailing delimiter' '
87 git rm fileA.t fileB.t &&
88 printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- &&
90 cat >expect <<-\EOF &&
97 test_expect_success
'CRLF delimiters' '
100 git rm fileA.t fileB.t &&
101 printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- &&
103 cat >expect <<-\EOF &&
110 test_expect_success
'quotes' '
111 restore_checkpoint &&
118 git reset --pathspec-from-file=list &&
120 cat >expect <<-\EOF &&
126 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
127 restore_checkpoint &&
133 # Note: "git reset" has not yet learned to fail on wrong pathspecs
134 git reset --pathspec-from-file=list --pathspec-file-nul &&
136 cat >expect <<-\EOF &&
142 test_expect_success
'only touches what was listed' '
143 restore_checkpoint &&
145 git rm fileA.t fileB.t fileC.t fileD.t &&
146 printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- &&
148 cat >expect <<-\EOF &&
157 test_expect_success
'error conditions' '
158 restore_checkpoint &&
159 echo fileA.t >list &&
162 test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
163 test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
165 test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
166 test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
168 test_must_fail git reset --pathspec-file-nul 2>err &&
169 test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
171 test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
172 test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
174 test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
175 test_i18ngrep -e "fatal: Cannot do hard reset with paths" err