]>
Commit | Line | Data |
---|---|---|
367c9886 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
6 | test_description='git-status' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
10 | test_expect_success 'setup' ' | |
11 | : > tracked && | |
12 | : > modified && | |
13 | mkdir dir1 && | |
14 | : > dir1/tracked && | |
15 | : > dir1/modified && | |
16 | mkdir dir2 && | |
17 | : > dir1/tracked && | |
18 | : > dir1/modified && | |
19 | git add . && | |
ff58b9aa JK |
20 | |
21 | git status >output && | |
22 | ||
367c9886 JS |
23 | test_tick && |
24 | git commit -m initial && | |
25 | : > untracked && | |
26 | : > dir1/untracked && | |
27 | : > dir2/untracked && | |
28 | echo 1 > dir1/modified && | |
29 | echo 2 > dir2/modified && | |
30 | echo 3 > dir2/added && | |
31 | git add dir2/added | |
32 | ' | |
33 | ||
ff58b9aa JK |
34 | test_expect_success 'status (1)' ' |
35 | ||
aadbe44f | 36 | grep "use \"git rm --cached <file>\.\.\.\" to unstage" output |
ff58b9aa JK |
37 | |
38 | ' | |
39 | ||
367c9886 JS |
40 | cat > expect << \EOF |
41 | # On branch master | |
42 | # Changes to be committed: | |
43 | # (use "git reset HEAD <file>..." to unstage) | |
44 | # | |
45 | # new file: dir2/added | |
46 | # | |
47 | # Changed but not updated: | |
48 | # (use "git add <file>..." to update what will be committed) | |
49 | # | |
50 | # modified: dir1/modified | |
51 | # | |
52 | # Untracked files: | |
53 | # (use "git add <file>..." to include in what will be committed) | |
54 | # | |
55 | # dir1/untracked | |
56 | # dir2/modified | |
57 | # dir2/untracked | |
58 | # expect | |
59 | # output | |
60 | # untracked | |
61 | EOF | |
62 | ||
ff58b9aa | 63 | test_expect_success 'status (2)' ' |
367c9886 JS |
64 | |
65 | git status > output && | |
3af82863 | 66 | test_cmp expect output |
367c9886 JS |
67 | |
68 | ' | |
69 | ||
6c2ce048 MSO |
70 | cat >expect <<EOF |
71 | # On branch master | |
72 | # Changes to be committed: | |
73 | # (use "git reset HEAD <file>..." to unstage) | |
74 | # | |
75 | # new file: dir2/added | |
76 | # | |
77 | # Changed but not updated: | |
78 | # (use "git add <file>..." to update what will be committed) | |
79 | # | |
80 | # modified: dir1/modified | |
81 | # | |
82 | # Untracked files not listed (use -u option to show untracked files) | |
83 | EOF | |
84 | test_expect_success 'status -uno' ' | |
85 | mkdir dir3 && | |
86 | : > dir3/untracked1 && | |
87 | : > dir3/untracked2 && | |
88 | git status -uno >output && | |
89 | test_cmp expect output | |
90 | ' | |
91 | ||
d6293d1f MSO |
92 | test_expect_success 'status (status.showUntrackedFiles no)' ' |
93 | git config status.showuntrackedfiles no | |
94 | git status >output && | |
95 | test_cmp expect output | |
96 | ' | |
97 | ||
4bfee30a MSO |
98 | cat >expect <<EOF |
99 | # On branch master | |
100 | # Changes to be committed: | |
101 | # (use "git reset HEAD <file>..." to unstage) | |
102 | # | |
103 | # new file: dir2/added | |
104 | # | |
105 | # Changed but not updated: | |
106 | # (use "git add <file>..." to update what will be committed) | |
107 | # | |
108 | # modified: dir1/modified | |
109 | # | |
110 | # Untracked files: | |
111 | # (use "git add <file>..." to include in what will be committed) | |
112 | # | |
113 | # dir1/untracked | |
114 | # dir2/modified | |
115 | # dir2/untracked | |
116 | # dir3/ | |
117 | # expect | |
118 | # output | |
119 | # untracked | |
120 | EOF | |
121 | test_expect_success 'status -unormal' ' | |
4bfee30a MSO |
122 | git status -unormal >output && |
123 | test_cmp expect output | |
124 | ' | |
125 | ||
d6293d1f MSO |
126 | test_expect_success 'status (status.showUntrackedFiles normal)' ' |
127 | git config status.showuntrackedfiles normal | |
128 | git status >output && | |
129 | test_cmp expect output | |
130 | ' | |
131 | ||
4bfee30a MSO |
132 | cat >expect <<EOF |
133 | # On branch master | |
134 | # Changes to be committed: | |
135 | # (use "git reset HEAD <file>..." to unstage) | |
136 | # | |
137 | # new file: dir2/added | |
138 | # | |
139 | # Changed but not updated: | |
140 | # (use "git add <file>..." to update what will be committed) | |
141 | # | |
142 | # modified: dir1/modified | |
143 | # | |
144 | # Untracked files: | |
145 | # (use "git add <file>..." to include in what will be committed) | |
146 | # | |
147 | # dir1/untracked | |
148 | # dir2/modified | |
149 | # dir2/untracked | |
150 | # dir3/untracked1 | |
151 | # dir3/untracked2 | |
152 | # expect | |
153 | # output | |
154 | # untracked | |
155 | EOF | |
156 | test_expect_success 'status -uall' ' | |
157 | git status -uall >output && | |
d6293d1f MSO |
158 | test_cmp expect output |
159 | ' | |
160 | test_expect_success 'status (status.showUntrackedFiles all)' ' | |
161 | git config status.showuntrackedfiles all | |
162 | git status >output && | |
4bfee30a | 163 | rm -rf dir3 && |
d6293d1f | 164 | git config --unset status.showuntrackedfiles && |
4bfee30a MSO |
165 | test_cmp expect output |
166 | ' | |
167 | ||
367c9886 JS |
168 | cat > expect << \EOF |
169 | # On branch master | |
170 | # Changes to be committed: | |
171 | # (use "git reset HEAD <file>..." to unstage) | |
172 | # | |
173 | # new file: ../dir2/added | |
174 | # | |
175 | # Changed but not updated: | |
176 | # (use "git add <file>..." to update what will be committed) | |
177 | # | |
69e74918 | 178 | # modified: modified |
367c9886 JS |
179 | # |
180 | # Untracked files: | |
181 | # (use "git add <file>..." to include in what will be committed) | |
182 | # | |
183 | # untracked | |
184 | # ../dir2/modified | |
185 | # ../dir2/untracked | |
186 | # ../expect | |
187 | # ../output | |
188 | # ../untracked | |
189 | EOF | |
190 | ||
191 | test_expect_success 'status with relative paths' ' | |
192 | ||
193 | (cd dir1 && git status) > output && | |
3af82863 | 194 | test_cmp expect output |
367c9886 JS |
195 | |
196 | ' | |
197 | ||
46f721c8 JK |
198 | cat > expect << \EOF |
199 | # On branch master | |
200 | # Changes to be committed: | |
201 | # (use "git reset HEAD <file>..." to unstage) | |
202 | # | |
203 | # new file: dir2/added | |
204 | # | |
205 | # Changed but not updated: | |
206 | # (use "git add <file>..." to update what will be committed) | |
207 | # | |
208 | # modified: dir1/modified | |
209 | # | |
210 | # Untracked files: | |
211 | # (use "git add <file>..." to include in what will be committed) | |
212 | # | |
213 | # dir1/untracked | |
214 | # dir2/modified | |
215 | # dir2/untracked | |
216 | # expect | |
217 | # output | |
218 | # untracked | |
219 | EOF | |
220 | ||
221 | test_expect_success 'status without relative paths' ' | |
222 | ||
223 | git config status.relativePaths false | |
224 | (cd dir1 && git status) > output && | |
3af82863 | 225 | test_cmp expect output |
46f721c8 JK |
226 | |
227 | ' | |
228 | ||
959ba670 JK |
229 | cat <<EOF >expect |
230 | # On branch master | |
231 | # Changes to be committed: | |
232 | # (use "git reset HEAD <file>..." to unstage) | |
233 | # | |
234 | # modified: dir1/modified | |
235 | # | |
236 | # Untracked files: | |
237 | # (use "git add <file>..." to include in what will be committed) | |
238 | # | |
239 | # dir1/untracked | |
240 | # dir2/ | |
241 | # expect | |
242 | # output | |
243 | # untracked | |
244 | EOF | |
245 | test_expect_success 'status of partial commit excluding new file in index' ' | |
246 | git status dir1/modified >output && | |
82ebb0b6 | 247 | test_cmp expect output |
959ba670 JK |
248 | ' |
249 | ||
e5e4a7f2 PY |
250 | test_expect_success 'setup status submodule summary' ' |
251 | test_create_repo sm && ( | |
252 | cd sm && | |
253 | >foo && | |
254 | git add foo && | |
255 | git commit -m "Add foo" | |
256 | ) && | |
257 | git add sm | |
258 | ' | |
259 | ||
260 | cat >expect <<EOF | |
261 | # On branch master | |
262 | # Changes to be committed: | |
263 | # (use "git reset HEAD <file>..." to unstage) | |
264 | # | |
265 | # new file: dir2/added | |
266 | # new file: sm | |
267 | # | |
268 | # Changed but not updated: | |
269 | # (use "git add <file>..." to update what will be committed) | |
270 | # | |
271 | # modified: dir1/modified | |
272 | # | |
273 | # Untracked files: | |
274 | # (use "git add <file>..." to include in what will be committed) | |
275 | # | |
276 | # dir1/untracked | |
277 | # dir2/modified | |
278 | # dir2/untracked | |
279 | # expect | |
280 | # output | |
281 | # untracked | |
282 | EOF | |
283 | test_expect_success 'status submodule summary is disabled by default' ' | |
284 | git status >output && | |
285 | test_cmp expect output | |
286 | ' | |
287 | ||
288 | head=$(cd sm && git rev-parse --short=7 --verify HEAD) | |
289 | ||
290 | cat >expect <<EOF | |
291 | # On branch master | |
292 | # Changes to be committed: | |
293 | # (use "git reset HEAD <file>..." to unstage) | |
294 | # | |
295 | # new file: dir2/added | |
296 | # new file: sm | |
297 | # | |
298 | # Changed but not updated: | |
299 | # (use "git add <file>..." to update what will be committed) | |
300 | # | |
301 | # modified: dir1/modified | |
302 | # | |
303 | # Modified submodules: | |
304 | # | |
305 | # * sm 0000000...$head (1): | |
306 | # > Add foo | |
307 | # | |
308 | # Untracked files: | |
309 | # (use "git add <file>..." to include in what will be committed) | |
310 | # | |
311 | # dir1/untracked | |
312 | # dir2/modified | |
313 | # dir2/untracked | |
314 | # expect | |
315 | # output | |
316 | # untracked | |
317 | EOF | |
318 | test_expect_success 'status submodule summary' ' | |
319 | git config status.submodulesummary 10 && | |
320 | git status >output && | |
321 | test_cmp expect output | |
322 | ' | |
323 | ||
324 | ||
325 | cat >expect <<EOF | |
326 | # On branch master | |
327 | # Changed but not updated: | |
328 | # (use "git add <file>..." to update what will be committed) | |
329 | # | |
330 | # modified: dir1/modified | |
331 | # | |
332 | # Untracked files: | |
333 | # (use "git add <file>..." to include in what will be committed) | |
334 | # | |
335 | # dir1/untracked | |
336 | # dir2/modified | |
337 | # dir2/untracked | |
338 | # expect | |
339 | # output | |
340 | # untracked | |
341 | no changes added to commit (use "git add" and/or "git commit -a") | |
342 | EOF | |
343 | test_expect_success 'status submodule summary (clean submodule)' ' | |
344 | git commit -m "commit submodule" && | |
345 | git config status.submodulesummary 10 && | |
346 | test_must_fail git status >output && | |
347 | test_cmp expect output | |
348 | ' | |
349 | ||
350 | cat >expect <<EOF | |
351 | # On branch master | |
352 | # Changes to be committed: | |
353 | # (use "git reset HEAD^1 <file>..." to unstage) | |
354 | # | |
355 | # new file: dir2/added | |
356 | # new file: sm | |
357 | # | |
358 | # Changed but not updated: | |
359 | # (use "git add <file>..." to update what will be committed) | |
360 | # | |
361 | # modified: dir1/modified | |
362 | # | |
363 | # Modified submodules: | |
364 | # | |
365 | # * sm 0000000...$head (1): | |
366 | # > Add foo | |
367 | # | |
368 | # Untracked files: | |
369 | # (use "git add <file>..." to include in what will be committed) | |
370 | # | |
371 | # dir1/untracked | |
372 | # dir2/modified | |
373 | # dir2/untracked | |
374 | # expect | |
375 | # output | |
376 | # untracked | |
377 | EOF | |
378 | test_expect_success 'status submodule summary (--amend)' ' | |
379 | git config status.submodulesummary 10 && | |
380 | git status --amend >output && | |
381 | test_cmp expect output | |
382 | ' | |
383 | ||
367c9886 | 384 | test_done |