3 test_description
='checkout --pathspec-from-file'
9 test_expect_success setup
'
16 git add fileA.t fileB.t fileC.t fileD.t &&
17 git commit -m "files 1" &&
23 git add fileA.t fileB.t fileC.t fileD.t &&
24 git commit -m "files 2" &&
29 restore_checkpoint
() {
30 git
reset --hard checkpoint
34 git status
--porcelain --untracked-files=no
-- fileA.t fileB.t fileC.t fileD.t
>actual
&&
35 test_cmp expect actual
38 test_expect_success
'--pathspec-from-file from stdin' '
41 echo fileA.t | git checkout --pathspec-from-file=- HEAD^1 &&
43 cat >expect <<-\EOF &&
49 test_expect_success
'--pathspec-from-file from file' '
53 git checkout --pathspec-from-file=list HEAD^1 &&
55 cat >expect <<-\EOF &&
61 test_expect_success
'NUL delimiters' '
64 printf "fileA.t\0fileB.t\0" | git checkout --pathspec-from-file=- --pathspec-file-nul HEAD^1 &&
66 cat >expect <<-\EOF &&
73 test_expect_success
'LF delimiters' '
76 printf "fileA.t\nfileB.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
78 cat >expect <<-\EOF &&
85 test_expect_success
'no trailing delimiter' '
88 printf "fileA.t\nfileB.t" | git checkout --pathspec-from-file=- HEAD^1 &&
90 cat >expect <<-\EOF &&
97 test_expect_success
'CRLF delimiters' '
100 printf "fileA.t\r\nfileB.t\r\n" | git checkout --pathspec-from-file=- HEAD^1 &&
102 cat >expect <<-\EOF &&
109 test_expect_success
'quotes' '
110 restore_checkpoint &&
116 git checkout --pathspec-from-file=list HEAD^1 &&
118 cat >expect <<-\EOF &&
124 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
125 restore_checkpoint &&
131 test_must_fail git checkout --pathspec-from-file=list --pathspec-file-nul HEAD^1
134 test_expect_success
'only touches what was listed' '
135 restore_checkpoint &&
137 printf "fileB.t\nfileC.t\n" | git checkout --pathspec-from-file=- HEAD^1 &&
139 cat >expect <<-\EOF &&
146 test_expect_success
'error conditions' '
147 restore_checkpoint &&
148 echo fileA.t >list &&
150 test_must_fail git checkout --pathspec-from-file=list --detach 2>err &&
151 test_i18ngrep -e "--pathspec-from-file is incompatible with --detach" err &&
153 test_must_fail git checkout --pathspec-from-file=list --patch 2>err &&
154 test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err &&
156 test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
157 test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
159 test_must_fail git checkout --pathspec-file-nul 2>err &&
160 test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err