3 test_description
='restore --pathspec-from-file'
9 test_expect_success setup
'
18 git add dir1 fileA.t fileB.t fileC.t fileD.t &&
19 git commit -m "files 1" &&
26 git add dir1 fileA.t fileB.t fileC.t fileD.t &&
27 git commit -m "files 2" &&
32 restore_checkpoint
() {
33 git
reset --hard checkpoint
37 git status
--porcelain --untracked-files=no
-- dir1 fileA.t fileB.t fileC.t fileD.t
>actual
&&
38 test_cmp expect actual
41 test_expect_success
'--pathspec-from-file from stdin' '
44 echo fileA.t | git restore --pathspec-from-file=- --source=HEAD^1 &&
46 cat >expect <<-\EOF &&
52 test_expect_success
'--pathspec-from-file from file' '
56 git restore --pathspec-from-file=list --source=HEAD^1 &&
58 cat >expect <<-\EOF &&
64 test_expect_success
'NUL delimiters' '
67 printf "fileA.t\0fileB.t\0" | git restore --pathspec-from-file=- --pathspec-file-nul --source=HEAD^1 &&
69 cat >expect <<-\EOF &&
76 test_expect_success
'LF delimiters' '
79 printf "fileA.t\nfileB.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
81 cat >expect <<-\EOF &&
88 test_expect_success
'no trailing delimiter' '
91 printf "fileA.t\nfileB.t" | git restore --pathspec-from-file=- --source=HEAD^1 &&
93 cat >expect <<-\EOF &&
100 test_expect_success
'CRLF delimiters' '
101 restore_checkpoint &&
103 printf "fileA.t\r\nfileB.t\r\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
105 cat >expect <<-\EOF &&
112 test_expect_success
'quotes' '
113 restore_checkpoint &&
119 git restore --pathspec-from-file=list --source=HEAD^1 &&
121 cat >expect <<-\EOF &&
127 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
128 restore_checkpoint &&
134 test_must_fail git restore --pathspec-from-file=list --pathspec-file-nul --source=HEAD^1
137 test_expect_success
'only touches what was listed' '
138 restore_checkpoint &&
140 printf "fileB.t\nfileC.t\n" | git restore --pathspec-from-file=- --source=HEAD^1 &&
142 cat >expect <<-\EOF &&
149 test_expect_success
'error conditions' '
150 restore_checkpoint &&
151 echo fileA.t >list &&
154 test_must_fail git restore --pathspec-from-file=list --patch --source=HEAD^1 2>err &&
155 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
157 test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
158 test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
160 test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
161 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
163 test_must_fail git restore --pathspec-from-file=empty_list --source=HEAD^1 2>err &&
164 test_i18ngrep -e "you must specify path(s) to restore" err
167 test_expect_success
'wildcard pathspec matches file in subdirectory' '
168 restore_checkpoint &&
170 echo "*file" | git restore --pathspec-from-file=- --source=HEAD^1 &&
171 cat >expect <<-\EOF &&