3 test_description
='checkout --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success setup
'
17 git add fileA.t fileB.t fileC.t fileD.t &&
18 git commit -m "files 1" &&
24 git add fileA.t fileB.t fileC.t fileD.t &&
25 git commit -m "files 2" &&
30 restore_checkpoint
() {
31 git
reset --hard checkpoint
35 git status
--porcelain --untracked-files=no
-- fileA.t fileB.t fileC.t fileD.t
>actual
&&
36 test_cmp expect actual
39 test_expect_success
'--pathspec-from-file from stdin' '
42 echo fileA.t | git checkout --pathspec-from-file=- HEAD^1 &&
44 cat >expect <<-\EOF &&
50 test_expect_success
'--pathspec-from-file from file' '
54 git checkout --pathspec-from-file=list HEAD^1 &&
56 cat >expect <<-\EOF &&
62 test_expect_success
'NUL delimiters' '
65 printf "fileA.t\0fileB.t\0" | git checkout --pathspec-from-file=- --pathspec-file-nul HEAD^1 &&
67 cat >expect <<-\EOF &&
74 test_expect_success
'LF delimiters' '
77 printf "fileA.t\nfileB.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
79 cat >expect <<-\EOF &&
86 test_expect_success
'no trailing delimiter' '
89 printf "fileA.t\nfileB.t" | git checkout --pathspec-from-file=- HEAD^1 &&
91 cat >expect <<-\EOF &&
98 test_expect_success
'CRLF delimiters' '
101 printf "fileA.t\r\nfileB.t\r\n" | git checkout --pathspec-from-file=- HEAD^1 &&
103 cat >expect <<-\EOF &&
110 test_expect_success
'quotes' '
111 restore_checkpoint &&
117 git checkout --pathspec-from-file=list HEAD^1 &&
119 cat >expect <<-\EOF &&
125 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
126 restore_checkpoint &&
132 test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
135 test_expect_success
'only touches what was listed' '
136 restore_checkpoint &&
138 printf "fileB.t\nfileC.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
140 cat >expect <<-\EOF &&
147 test_expect_success
'error conditions' '
148 restore_checkpoint &&
149 echo fileA.t >list &&
151 test_must_fail git checkout --pathspec-from-file=list --detach 2>err &&
152 test_i18ngrep -e "options .--pathspec-from-file. and .--detach. cannot be used together" err &&
154 test_must_fail git checkout --pathspec-from-file=list --patch 2>err &&
155 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
157 test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
158 test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
160 test_must_fail git checkout --pathspec-file-nul 2>err &&
161 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err