use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t3704-add-pathspec-file.sh
blob3cfdb669b7a5a1bc4b915abb0c880f067bfbd7b9
1 #!/bin/sh
3 test_description='add --pathspec-from-file'
5 . ./test-lib.sh
7 test_tick
9 test_expect_success setup '
10 test_commit file0 &&
11 echo A >fileA.t &&
12 echo B >fileB.t &&
13 echo C >fileC.t &&
14 echo D >fileD.t
17 restore_checkpoint () {
18 git reset
21 verify_expect () {
22 git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
23 test_cmp expect actual
26 test_expect_success '--pathspec-from-file from stdin' '
27 restore_checkpoint &&
29 echo fileA.t | git add --pathspec-from-file=- &&
31 cat >expect <<-\EOF &&
32 A fileA.t
33 EOF
34 verify_expect
37 test_expect_success '--pathspec-from-file from file' '
38 restore_checkpoint &&
40 echo fileA.t >list &&
41 git add --pathspec-from-file=list &&
43 cat >expect <<-\EOF &&
44 A fileA.t
45 EOF
46 verify_expect
49 test_expect_success 'NUL delimiters' '
50 restore_checkpoint &&
52 printf "fileA.t\0fileB.t\0" | git add --pathspec-from-file=- --pathspec-file-nul &&
54 cat >expect <<-\EOF &&
55 A fileA.t
56 A fileB.t
57 EOF
58 verify_expect
61 test_expect_success 'LF delimiters' '
62 restore_checkpoint &&
64 printf "fileA.t\nfileB.t\n" | git add --pathspec-from-file=- &&
66 cat >expect <<-\EOF &&
67 A fileA.t
68 A fileB.t
69 EOF
70 verify_expect
73 test_expect_success 'no trailing delimiter' '
74 restore_checkpoint &&
76 printf "fileA.t\nfileB.t" | git add --pathspec-from-file=- &&
78 cat >expect <<-\EOF &&
79 A fileA.t
80 A fileB.t
81 EOF
82 verify_expect
85 test_expect_success 'CRLF delimiters' '
86 restore_checkpoint &&
88 printf "fileA.t\r\nfileB.t\r\n" | git add --pathspec-from-file=- &&
90 cat >expect <<-\EOF &&
91 A fileA.t
92 A fileB.t
93 EOF
94 verify_expect
97 test_expect_success 'quotes' '
98 restore_checkpoint &&
100 printf "\"file\\101.t\"" | git add --pathspec-from-file=- &&
102 cat >expect <<-\EOF &&
103 A fileA.t
105 verify_expect
108 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
109 restore_checkpoint &&
111 printf "\"file\\101.t\"" >list &&
112 test_must_fail git add --pathspec-from-file=list --pathspec-file-nul
115 test_expect_success 'only touches what was listed' '
116 restore_checkpoint &&
118 printf "fileB.t\nfileC.t\n" | git add --pathspec-from-file=- &&
120 cat >expect <<-\EOF &&
121 A fileB.t
122 A fileC.t
124 verify_expect
127 test_done