]>
Commit | Line | Data |
---|---|---|
e440fc58 AM |
1 | #!/bin/sh |
2 | ||
3 | test_description='commit --pathspec-from-file' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_tick | |
8 | ||
9 | test_expect_success setup ' | |
10 | test_commit file0 && | |
11 | git tag checkpoint && | |
12 | ||
13 | echo A >fileA.t && | |
14 | echo B >fileB.t && | |
15 | echo C >fileC.t && | |
16 | echo D >fileD.t && | |
17 | git add fileA.t fileB.t fileC.t fileD.t | |
18 | ' | |
19 | ||
20 | restore_checkpoint () { | |
21 | git reset --soft checkpoint | |
22 | } | |
23 | ||
24 | verify_expect () { | |
25 | git diff-tree --no-commit-id --name-status -r HEAD >actual && | |
26 | test_cmp expect actual | |
27 | } | |
28 | ||
29 | test_expect_success '--pathspec-from-file from stdin' ' | |
30 | restore_checkpoint && | |
31 | ||
32 | echo fileA.t | git commit --pathspec-from-file=- -m "Commit" && | |
33 | ||
34 | cat >expect <<-\EOF && | |
35 | A fileA.t | |
36 | EOF | |
37 | verify_expect | |
38 | ' | |
39 | ||
40 | test_expect_success '--pathspec-from-file from file' ' | |
41 | restore_checkpoint && | |
42 | ||
43 | echo fileA.t >list && | |
44 | git commit --pathspec-from-file=list -m "Commit" && | |
45 | ||
46 | cat >expect <<-\EOF && | |
47 | A fileA.t | |
48 | EOF | |
49 | verify_expect | |
50 | ' | |
51 | ||
52 | test_expect_success 'NUL delimiters' ' | |
53 | restore_checkpoint && | |
54 | ||
55 | printf "fileA.t\0fileB.t\0" | git commit --pathspec-from-file=- --pathspec-file-nul -m "Commit" && | |
56 | ||
57 | cat >expect <<-\EOF && | |
58 | A fileA.t | |
59 | A fileB.t | |
60 | EOF | |
61 | verify_expect | |
62 | ' | |
63 | ||
64 | test_expect_success 'LF delimiters' ' | |
65 | restore_checkpoint && | |
66 | ||
67 | printf "fileA.t\nfileB.t\n" | git commit --pathspec-from-file=- -m "Commit" && | |
68 | ||
69 | cat >expect <<-\EOF && | |
70 | A fileA.t | |
71 | A fileB.t | |
72 | EOF | |
73 | verify_expect | |
74 | ' | |
75 | ||
76 | test_expect_success 'no trailing delimiter' ' | |
77 | restore_checkpoint && | |
78 | ||
79 | printf "fileA.t\nfileB.t" | git commit --pathspec-from-file=- -m "Commit" && | |
80 | ||
81 | cat >expect <<-\EOF && | |
82 | A fileA.t | |
83 | A fileB.t | |
84 | EOF | |
85 | verify_expect | |
86 | ' | |
87 | ||
88 | test_expect_success 'CRLF delimiters' ' | |
89 | restore_checkpoint && | |
90 | ||
91 | printf "fileA.t\r\nfileB.t\r\n" | git commit --pathspec-from-file=- -m "Commit" && | |
92 | ||
93 | cat >expect <<-\EOF && | |
94 | A fileA.t | |
95 | A fileB.t | |
96 | EOF | |
97 | verify_expect | |
98 | ' | |
99 | ||
100 | test_expect_success 'quotes' ' | |
101 | restore_checkpoint && | |
102 | ||
568cabb2 AM |
103 | cat >list <<-\EOF && |
104 | "file\101.t" | |
105 | EOF | |
106 | ||
107 | git commit --pathspec-from-file=list -m "Commit" && | |
e440fc58 AM |
108 | |
109 | cat >expect <<-\EOF && | |
110 | A fileA.t | |
111 | EOF | |
112 | verify_expect expect | |
113 | ' | |
114 | ||
115 | test_expect_success 'quotes not compatible with --pathspec-file-nul' ' | |
116 | restore_checkpoint && | |
117 | ||
568cabb2 AM |
118 | cat >list <<-\EOF && |
119 | "file\101.t" | |
120 | EOF | |
121 | ||
e440fc58 AM |
122 | test_must_fail git commit --pathspec-from-file=list --pathspec-file-nul -m "Commit" |
123 | ' | |
124 | ||
125 | test_expect_success 'only touches what was listed' ' | |
126 | restore_checkpoint && | |
127 | ||
128 | printf "fileB.t\nfileC.t\n" | git commit --pathspec-from-file=- -m "Commit" && | |
129 | ||
130 | cat >expect <<-\EOF && | |
131 | A fileB.t | |
132 | A fileC.t | |
133 | EOF | |
134 | verify_expect | |
135 | ' | |
136 | ||
f94f7bd0 | 137 | test_expect_success 'error conditions' ' |
509efef7 | 138 | restore_checkpoint && |
f94f7bd0 AM |
139 | echo fileA.t >list && |
140 | >empty_list && | |
141 | ||
142 | test_must_fail git commit --pathspec-from-file=list --interactive -m "Commit" 2>err && | |
143 | test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && | |
144 | ||
145 | test_must_fail git commit --pathspec-from-file=list --patch -m "Commit" 2>err && | |
146 | test_i18ngrep -e "--pathspec-from-file is incompatible with --interactive/--patch" err && | |
147 | ||
148 | test_must_fail git commit --pathspec-from-file=list --all -m "Commit" 2>err && | |
149 | test_i18ngrep -e "--pathspec-from-file with -a does not make sense" err && | |
150 | ||
151 | test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err && | |
152 | test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && | |
153 | ||
154 | test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err && | |
155 | test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err && | |
156 | ||
157 | test_must_fail git commit --pathspec-from-file=empty_list --include -m "Commit" 2>err && | |
158 | test_i18ngrep -e "No paths with --include/--only does not make sense." err && | |
159 | ||
160 | test_must_fail git commit --pathspec-from-file=empty_list --only -m "Commit" 2>err && | |
161 | test_i18ngrep -e "No paths with --include/--only does not make sense." err | |
509efef7 AM |
162 | ' |
163 | ||
e440fc58 | 164 | test_done |