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 &&
25 test_cmp expect actual
28 test_expect_success '--pathspec-from-file from stdin' '
32 echo fileA.t | git reset --pathspec-from-file=- &&
34 cat >expect <<-\EOF &&
40 test_expect_success '--pathspec-from-file from file' '
45 git reset --pathspec-from-file=list &&
47 cat >expect <<-\EOF &&
53 test_expect_success 'NUL delimiters' '
56 git rm fileA.t fileB.t &&
57 printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul &&
59 cat >expect <<-\EOF &&
66 test_expect_success 'LF delimiters' '
69 git rm fileA.t fileB.t &&
70 printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- &&
72 cat >expect <<-\EOF &&
79 test_expect_success 'no trailing delimiter' '
82 git rm fileA.t fileB.t &&
83 printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- &&
85 cat >expect <<-\EOF &&
92 test_expect_success 'CRLF delimiters' '
95 git rm fileA.t fileB.t &&
96 printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- &&
98 cat >expect <<-\EOF &&
105 test_expect_success 'quotes' '
106 restore_checkpoint &&
109 printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
111 cat >expect <<-\EOF &&
117 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
118 restore_checkpoint &&
121 printf "\"file\\101.t\"" >list &&
122 # Note: "git reset" has not yet learned to fail on wrong pathspecs
123 git reset --pathspec-from-file=list --pathspec-file-nul &&
125 cat >expect <<-\EOF &&
128 test_must_fail verify_expect
131 test_expect_success 'only touches what was listed' '
132 restore_checkpoint &&
134 git rm fileA.t fileB.t fileC.t fileD.t &&
135 printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- &&
137 cat >expect <<-\EOF &&
146 test_expect_success 'error conditions' '
147 restore_checkpoint &&
148 echo fileA.t >list &&
151 test_must_fail git reset --pathspec-from-file=list --patch 2>err &&
152 test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
154 test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
155 test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
157 test_must_fail git reset --pathspec-file-nul 2>err &&
158 test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err &&
160 test_must_fail git reset --soft --pathspec-from-file=list 2>err &&
161 test_i18ngrep -e "fatal: Cannot do soft reset with paths" err &&
163 test_must_fail git reset --hard --pathspec-from-file=list 2>err &&
164 test_i18ngrep -e "fatal: Cannot do hard reset with paths" err