3 test_description
='add --pathspec-from-file'
5 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success setup
'
18 restore_checkpoint
() {
23 git status
--porcelain --untracked-files=no
-- fileA.t fileB.t fileC.t fileD.t
>actual
&&
24 test_cmp expect actual
27 test_expect_success
'--pathspec-from-file from stdin' '
30 echo fileA.t | git add --pathspec-from-file=- &&
32 cat >expect <<-\EOF &&
38 test_expect_success
'--pathspec-from-file from file' '
42 git add --pathspec-from-file=list &&
44 cat >expect <<-\EOF &&
50 test_expect_success
'NUL delimiters' '
53 printf "fileA.t\0fileB.t\0" | git add --pathspec-from-file=- --pathspec-file-nul &&
55 cat >expect <<-\EOF &&
62 test_expect_success
'LF delimiters' '
65 printf "fileA.t\nfileB.t\n" | git add --pathspec-from-file=- &&
67 cat >expect <<-\EOF &&
74 test_expect_success
'no trailing delimiter' '
77 printf "fileA.t\nfileB.t" | git add --pathspec-from-file=- &&
79 cat >expect <<-\EOF &&
86 test_expect_success
'CRLF delimiters' '
89 printf "fileA.t\r\nfileB.t\r\n" | git add --pathspec-from-file=- &&
91 cat >expect <<-\EOF &&
98 test_expect_success
'quotes' '
105 git add --pathspec-from-file=list &&
107 cat >expect <<-\EOF &&
113 test_expect_success
'quotes not compatible with --pathspec-file-nul' '
114 restore_checkpoint &&
120 test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
123 test_expect_success
'only touches what was listed' '
124 restore_checkpoint &&
126 printf "fileB.t\nfileC.t\n" | git add --pathspec-from-file=- &&
128 cat >expect <<-\EOF &&
135 test_expect_success
'error conditions' '
136 restore_checkpoint &&
137 echo fileA.t >list &&
140 test_must_fail git add --pathspec-from-file=list --interactive 2>err &&
141 test_i18ngrep -e "options .--pathspec-from-file. and .--interactive/--patch. cannot be used together" err &&
143 test_must_fail git add --pathspec-from-file=list --patch 2>err &&
144 test_i18ngrep -e "options .--pathspec-from-file. and .--interactive/--patch. cannot be used together" err &&
146 test_must_fail git add --pathspec-from-file=list --edit 2>err &&
147 test_i18ngrep -e "options .--pathspec-from-file. and .--edit. cannot be used together" err &&
149 test_must_fail git add --pathspec-from-file=list -- fileA.t 2>err &&
150 test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
152 test_must_fail git add --pathspec-file-nul 2>err &&
153 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
155 # This case succeeds, but still prints to stderr
156 git add --pathspec-from-file=empty_list 2>err &&
157 test_i18ngrep -e "Nothing specified, nothing added." err