]>
Commit | Line | Data |
---|---|---|
367c9886 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
47a528ad | 6 | test_description='git status' |
367c9886 JS |
7 | |
8 | . ./test-lib.sh | |
9 | ||
5d3dd915 | 10 | test_expect_success 'status -h in broken repository' ' |
6a38ef2c | 11 | git config --global advice.statusuoption false && |
5d3dd915 NTND |
12 | mkdir broken && |
13 | test_when_finished "rm -fr broken" && | |
14 | ( | |
15 | cd broken && | |
16 | git init && | |
17 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && | |
18 | test_expect_code 129 git status -h >usage 2>&1 | |
19 | ) && | |
cc6658e7 | 20 | test_i18ngrep "[Uu]sage" broken/usage |
5d3dd915 NTND |
21 | ' |
22 | ||
23 | test_expect_success 'commit -h in broken repository' ' | |
24 | mkdir broken && | |
25 | test_when_finished "rm -fr broken" && | |
26 | ( | |
27 | cd broken && | |
28 | git init && | |
29 | echo "[status] showuntrackedfiles = CORRUPT" >>.git/config && | |
30 | test_expect_code 129 git commit -h >usage 2>&1 | |
31 | ) && | |
cc6658e7 | 32 | test_i18ngrep "[Uu]sage" broken/usage |
5d3dd915 NTND |
33 | ' |
34 | ||
367c9886 | 35 | test_expect_success 'setup' ' |
68cfc6f5 MG |
36 | : >tracked && |
37 | : >modified && | |
367c9886 | 38 | mkdir dir1 && |
68cfc6f5 MG |
39 | : >dir1/tracked && |
40 | : >dir1/modified && | |
367c9886 | 41 | mkdir dir2 && |
68cfc6f5 MG |
42 | : >dir1/tracked && |
43 | : >dir1/modified && | |
367c9886 | 44 | git add . && |
ff58b9aa JK |
45 | |
46 | git status >output && | |
47 | ||
367c9886 JS |
48 | test_tick && |
49 | git commit -m initial && | |
68cfc6f5 MG |
50 | : >untracked && |
51 | : >dir1/untracked && | |
52 | : >dir2/untracked && | |
53 | echo 1 >dir1/modified && | |
54 | echo 2 >dir2/modified && | |
55 | echo 3 >dir2/added && | |
367c9886 JS |
56 | git add dir2/added |
57 | ' | |
58 | ||
cc6658e7 JH |
59 | test_expect_success 'status (1)' ' |
60 | test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output | |
ff58b9aa JK |
61 | ' |
62 | ||
323d0530 NTND |
63 | test_expect_success 'status --column' ' |
64 | COLUMNS=50 git status --column="column dense" >output && | |
65 | cat >expect <<\EOF && | |
66 | # On branch master | |
67 | # Changes to be committed: | |
68 | # (use "git reset HEAD <file>..." to unstage) | |
69 | # | |
70 | # new file: dir2/added | |
71 | # | |
72 | # Changes not staged for commit: | |
73 | # (use "git add <file>..." to update what will be committed) | |
74 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
75 | # | |
76 | # modified: dir1/modified | |
77 | # | |
78 | # Untracked files: | |
79 | # (use "git add <file>..." to include in what will be committed) | |
80 | # | |
81 | # dir1/untracked dir2/untracked untracked | |
82 | # dir2/modified output | |
83 | EOF | |
b354f11b | 84 | test_i18ncmp expect output |
323d0530 NTND |
85 | ' |
86 | ||
68cfc6f5 | 87 | cat >expect <<\EOF |
367c9886 JS |
88 | # On branch master |
89 | # Changes to be committed: | |
90 | # (use "git reset HEAD <file>..." to unstage) | |
91 | # | |
92 | # new file: dir2/added | |
93 | # | |
8009d83c | 94 | # Changes not staged for commit: |
367c9886 | 95 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 96 | # (use "git checkout -- <file>..." to discard changes in working directory) |
367c9886 JS |
97 | # |
98 | # modified: dir1/modified | |
99 | # | |
100 | # Untracked files: | |
101 | # (use "git add <file>..." to include in what will be committed) | |
102 | # | |
103 | # dir1/untracked | |
104 | # dir2/modified | |
105 | # dir2/untracked | |
106 | # expect | |
107 | # output | |
108 | # untracked | |
109 | EOF | |
110 | ||
cc6658e7 | 111 | test_expect_success 'status (2)' ' |
68cfc6f5 | 112 | git status >output && |
cc6658e7 | 113 | test_i18ncmp expect output |
367c9886 JS |
114 | ' |
115 | ||
18f3b5a9 MG |
116 | cat >expect <<\EOF |
117 | # On branch master | |
118 | # Changes to be committed: | |
119 | # new file: dir2/added | |
120 | # | |
8009d83c | 121 | # Changes not staged for commit: |
18f3b5a9 MG |
122 | # modified: dir1/modified |
123 | # | |
124 | # Untracked files: | |
125 | # dir1/untracked | |
126 | # dir2/modified | |
127 | # dir2/untracked | |
128 | # expect | |
129 | # output | |
130 | # untracked | |
131 | EOF | |
132 | ||
cc6658e7 | 133 | test_expect_success 'status (advice.statusHints false)' ' |
c63659dd | 134 | test_config advice.statusHints false && |
18f3b5a9 | 135 | git status >output && |
cc6658e7 | 136 | test_i18ncmp expect output |
18f3b5a9 MG |
137 | |
138 | ' | |
139 | ||
68cfc6f5 | 140 | cat >expect <<\EOF |
14ed05dd MG |
141 | M dir1/modified |
142 | A dir2/added | |
143 | ?? dir1/untracked | |
144 | ?? dir2/modified | |
145 | ?? dir2/untracked | |
146 | ?? expect | |
147 | ?? output | |
148 | ?? untracked | |
149 | EOF | |
150 | ||
46077fa5 | 151 | test_expect_success 'status -s' ' |
14ed05dd | 152 | |
68cfc6f5 | 153 | git status -s >output && |
14ed05dd MG |
154 | test_cmp expect output |
155 | ||
156 | ' | |
157 | ||
150b493a JH |
158 | test_expect_success 'status with gitignore' ' |
159 | { | |
160 | echo ".gitignore" && | |
161 | echo "expect" && | |
162 | echo "output" && | |
163 | echo "untracked" | |
164 | } >.gitignore && | |
165 | ||
166 | cat >expect <<-\EOF && | |
167 | M dir1/modified | |
168 | A dir2/added | |
169 | ?? dir2/modified | |
170 | EOF | |
171 | git status -s >output && | |
172 | test_cmp expect output && | |
173 | ||
174 | cat >expect <<-\EOF && | |
175 | M dir1/modified | |
176 | A dir2/added | |
177 | ?? dir2/modified | |
178 | !! .gitignore | |
179 | !! dir1/untracked | |
180 | !! dir2/untracked | |
181 | !! expect | |
182 | !! output | |
183 | !! untracked | |
184 | EOF | |
185 | git status -s --ignored >output && | |
186 | test_cmp expect output && | |
187 | ||
188 | cat >expect <<-\EOF && | |
189 | # On branch master | |
190 | # Changes to be committed: | |
191 | # (use "git reset HEAD <file>..." to unstage) | |
192 | # | |
193 | # new file: dir2/added | |
194 | # | |
50cebdad | 195 | # Changes not staged for commit: |
150b493a JH |
196 | # (use "git add <file>..." to update what will be committed) |
197 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
198 | # | |
199 | # modified: dir1/modified | |
200 | # | |
201 | # Untracked files: | |
202 | # (use "git add <file>..." to include in what will be committed) | |
203 | # | |
204 | # dir2/modified | |
205 | # Ignored files: | |
206 | # (use "git add -f <file>..." to include in what will be committed) | |
207 | # | |
208 | # .gitignore | |
209 | # dir1/untracked | |
210 | # dir2/untracked | |
211 | # expect | |
212 | # output | |
213 | # untracked | |
214 | EOF | |
215 | git status --ignored >output && | |
ca0f515d | 216 | test_i18ncmp expect output |
150b493a JH |
217 | ' |
218 | ||
219 | test_expect_success 'status with gitignore (nothing untracked)' ' | |
220 | { | |
221 | echo ".gitignore" && | |
222 | echo "expect" && | |
223 | echo "dir2/modified" && | |
224 | echo "output" && | |
225 | echo "untracked" | |
226 | } >.gitignore && | |
227 | ||
228 | cat >expect <<-\EOF && | |
229 | M dir1/modified | |
230 | A dir2/added | |
231 | EOF | |
232 | git status -s >output && | |
233 | test_cmp expect output && | |
234 | ||
235 | cat >expect <<-\EOF && | |
236 | M dir1/modified | |
237 | A dir2/added | |
238 | !! .gitignore | |
239 | !! dir1/untracked | |
240 | !! dir2/modified | |
241 | !! dir2/untracked | |
242 | !! expect | |
243 | !! output | |
244 | !! untracked | |
245 | EOF | |
246 | git status -s --ignored >output && | |
247 | test_cmp expect output && | |
248 | ||
249 | cat >expect <<-\EOF && | |
250 | # On branch master | |
251 | # Changes to be committed: | |
252 | # (use "git reset HEAD <file>..." to unstage) | |
253 | # | |
254 | # new file: dir2/added | |
255 | # | |
50cebdad | 256 | # Changes not staged for commit: |
150b493a JH |
257 | # (use "git add <file>..." to update what will be committed) |
258 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
259 | # | |
260 | # modified: dir1/modified | |
261 | # | |
262 | # Ignored files: | |
263 | # (use "git add -f <file>..." to include in what will be committed) | |
264 | # | |
265 | # .gitignore | |
266 | # dir1/untracked | |
267 | # dir2/modified | |
268 | # dir2/untracked | |
269 | # expect | |
270 | # output | |
271 | # untracked | |
272 | EOF | |
273 | git status --ignored >output && | |
ca0f515d | 274 | test_i18ncmp expect output |
150b493a JH |
275 | ' |
276 | ||
277 | rm -f .gitignore | |
278 | ||
46077fa5 MG |
279 | cat >expect <<\EOF |
280 | ## master | |
281 | M dir1/modified | |
282 | A dir2/added | |
283 | ?? dir1/untracked | |
284 | ?? dir2/modified | |
285 | ?? dir2/untracked | |
286 | ?? expect | |
287 | ?? output | |
288 | ?? untracked | |
289 | EOF | |
290 | ||
291 | test_expect_success 'status -s -b' ' | |
292 | ||
293 | git status -s -b >output && | |
294 | test_cmp expect output | |
295 | ||
296 | ' | |
297 | ||
a5985237 JK |
298 | test_expect_success 'status -s -z -b' ' |
299 | tr "\\n" Q <expect >expect.q && | |
300 | mv expect.q expect && | |
301 | git status -s -z -b >output && | |
302 | nul_to_q <output >output.q && | |
303 | mv output.q output && | |
304 | test_cmp expect output | |
305 | ' | |
306 | ||
355ec7a1 ÆAB |
307 | test_expect_success 'setup dir3' ' |
308 | mkdir dir3 && | |
309 | : >dir3/untracked1 && | |
310 | : >dir3/untracked2 | |
311 | ' | |
312 | ||
6c2ce048 MSO |
313 | cat >expect <<EOF |
314 | # On branch master | |
315 | # Changes to be committed: | |
316 | # (use "git reset HEAD <file>..." to unstage) | |
317 | # | |
318 | # new file: dir2/added | |
319 | # | |
8009d83c | 320 | # Changes not staged for commit: |
6c2ce048 | 321 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 322 | # (use "git checkout -- <file>..." to discard changes in working directory) |
6c2ce048 MSO |
323 | # |
324 | # modified: dir1/modified | |
325 | # | |
326 | # Untracked files not listed (use -u option to show untracked files) | |
327 | EOF | |
cc6658e7 | 328 | test_expect_success 'status -uno' ' |
6c2ce048 | 329 | git status -uno >output && |
cc6658e7 | 330 | test_i18ncmp expect output |
6c2ce048 MSO |
331 | ' |
332 | ||
cc6658e7 | 333 | test_expect_success 'status (status.showUntrackedFiles no)' ' |
c63659dd | 334 | test_config status.showuntrackedfiles no && |
d6293d1f | 335 | git status >output && |
cc6658e7 | 336 | test_i18ncmp expect output |
d6293d1f MSO |
337 | ' |
338 | ||
18f3b5a9 MG |
339 | cat >expect <<EOF |
340 | # On branch master | |
341 | # Changes to be committed: | |
342 | # new file: dir2/added | |
343 | # | |
8009d83c | 344 | # Changes not staged for commit: |
18f3b5a9 MG |
345 | # modified: dir1/modified |
346 | # | |
980bde38 | 347 | # Untracked files not listed |
18f3b5a9 | 348 | EOF |
cc6658e7 | 349 | test_expect_success 'status -uno (advice.statusHints false)' ' |
c63659dd | 350 | test_config advice.statusHints false && |
18f3b5a9 | 351 | git status -uno >output && |
cc6658e7 | 352 | test_i18ncmp expect output |
18f3b5a9 | 353 | ' |
18f3b5a9 | 354 | |
14ed05dd MG |
355 | cat >expect << EOF |
356 | M dir1/modified | |
357 | A dir2/added | |
358 | EOF | |
359 | test_expect_success 'status -s -uno' ' | |
14ed05dd MG |
360 | git status -s -uno >output && |
361 | test_cmp expect output | |
362 | ' | |
363 | ||
364 | test_expect_success 'status -s (status.showUntrackedFiles no)' ' | |
365 | git config status.showuntrackedfiles no | |
366 | git status -s >output && | |
367 | test_cmp expect output | |
368 | ' | |
369 | ||
4bfee30a MSO |
370 | cat >expect <<EOF |
371 | # On branch master | |
372 | # Changes to be committed: | |
373 | # (use "git reset HEAD <file>..." to unstage) | |
374 | # | |
375 | # new file: dir2/added | |
376 | # | |
8009d83c | 377 | # Changes not staged for commit: |
4bfee30a | 378 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 379 | # (use "git checkout -- <file>..." to discard changes in working directory) |
4bfee30a MSO |
380 | # |
381 | # modified: dir1/modified | |
382 | # | |
383 | # Untracked files: | |
384 | # (use "git add <file>..." to include in what will be committed) | |
385 | # | |
386 | # dir1/untracked | |
387 | # dir2/modified | |
388 | # dir2/untracked | |
389 | # dir3/ | |
390 | # expect | |
391 | # output | |
392 | # untracked | |
393 | EOF | |
cc6658e7 | 394 | test_expect_success 'status -unormal' ' |
4bfee30a | 395 | git status -unormal >output && |
cc6658e7 | 396 | test_i18ncmp expect output |
4bfee30a MSO |
397 | ' |
398 | ||
cc6658e7 | 399 | test_expect_success 'status (status.showUntrackedFiles normal)' ' |
c63659dd | 400 | test_config status.showuntrackedfiles normal |
d6293d1f | 401 | git status >output && |
cc6658e7 | 402 | test_i18ncmp expect output |
d6293d1f MSO |
403 | ' |
404 | ||
14ed05dd MG |
405 | cat >expect <<EOF |
406 | M dir1/modified | |
407 | A dir2/added | |
408 | ?? dir1/untracked | |
409 | ?? dir2/modified | |
410 | ?? dir2/untracked | |
411 | ?? dir3/ | |
412 | ?? expect | |
413 | ?? output | |
414 | ?? untracked | |
415 | EOF | |
416 | test_expect_success 'status -s -unormal' ' | |
14ed05dd MG |
417 | git status -s -unormal >output && |
418 | test_cmp expect output | |
419 | ' | |
420 | ||
421 | test_expect_success 'status -s (status.showUntrackedFiles normal)' ' | |
422 | git config status.showuntrackedfiles normal | |
423 | git status -s >output && | |
424 | test_cmp expect output | |
425 | ' | |
426 | ||
4bfee30a MSO |
427 | cat >expect <<EOF |
428 | # On branch master | |
429 | # Changes to be committed: | |
430 | # (use "git reset HEAD <file>..." to unstage) | |
431 | # | |
432 | # new file: dir2/added | |
433 | # | |
8009d83c | 434 | # Changes not staged for commit: |
4bfee30a | 435 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 436 | # (use "git checkout -- <file>..." to discard changes in working directory) |
4bfee30a MSO |
437 | # |
438 | # modified: dir1/modified | |
439 | # | |
440 | # Untracked files: | |
441 | # (use "git add <file>..." to include in what will be committed) | |
442 | # | |
443 | # dir1/untracked | |
444 | # dir2/modified | |
445 | # dir2/untracked | |
446 | # dir3/untracked1 | |
447 | # dir3/untracked2 | |
448 | # expect | |
449 | # output | |
450 | # untracked | |
451 | EOF | |
cc6658e7 | 452 | test_expect_success 'status -uall' ' |
4bfee30a | 453 | git status -uall >output && |
cc6658e7 | 454 | test_i18ncmp expect output |
d6293d1f | 455 | ' |
cc6658e7 JH |
456 | |
457 | test_expect_success 'status (status.showUntrackedFiles all)' ' | |
c63659dd | 458 | test_config status.showuntrackedfiles all |
d6293d1f | 459 | git status >output && |
cc6658e7 | 460 | test_i18ncmp expect output |
4bfee30a MSO |
461 | ' |
462 | ||
355ec7a1 ÆAB |
463 | test_expect_success 'teardown dir3' ' |
464 | rm -rf dir3 | |
465 | ' | |
466 | ||
14ed05dd MG |
467 | cat >expect <<EOF |
468 | M dir1/modified | |
469 | A dir2/added | |
470 | ?? dir1/untracked | |
471 | ?? dir2/modified | |
472 | ?? dir2/untracked | |
473 | ?? expect | |
474 | ?? output | |
475 | ?? untracked | |
476 | EOF | |
477 | test_expect_success 'status -s -uall' ' | |
478 | git config --unset status.showuntrackedfiles | |
479 | git status -s -uall >output && | |
480 | test_cmp expect output | |
481 | ' | |
482 | test_expect_success 'status -s (status.showUntrackedFiles all)' ' | |
c63659dd | 483 | test_config status.showuntrackedfiles all && |
14ed05dd MG |
484 | git status -s >output && |
485 | rm -rf dir3 && | |
14ed05dd MG |
486 | test_cmp expect output |
487 | ' | |
488 | ||
68cfc6f5 | 489 | cat >expect <<\EOF |
367c9886 JS |
490 | # On branch master |
491 | # Changes to be committed: | |
492 | # (use "git reset HEAD <file>..." to unstage) | |
493 | # | |
494 | # new file: ../dir2/added | |
495 | # | |
8009d83c | 496 | # Changes not staged for commit: |
367c9886 | 497 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 498 | # (use "git checkout -- <file>..." to discard changes in working directory) |
367c9886 | 499 | # |
69e74918 | 500 | # modified: modified |
367c9886 JS |
501 | # |
502 | # Untracked files: | |
503 | # (use "git add <file>..." to include in what will be committed) | |
504 | # | |
505 | # untracked | |
506 | # ../dir2/modified | |
507 | # ../dir2/untracked | |
508 | # ../expect | |
509 | # ../output | |
510 | # ../untracked | |
511 | EOF | |
512 | ||
cc6658e7 | 513 | test_expect_success 'status with relative paths' ' |
68cfc6f5 | 514 | (cd dir1 && git status) >output && |
cc6658e7 | 515 | test_i18ncmp expect output |
367c9886 JS |
516 | ' |
517 | ||
68cfc6f5 | 518 | cat >expect <<\EOF |
14ed05dd MG |
519 | M modified |
520 | A ../dir2/added | |
521 | ?? untracked | |
522 | ?? ../dir2/modified | |
523 | ?? ../dir2/untracked | |
524 | ?? ../expect | |
525 | ?? ../output | |
526 | ?? ../untracked | |
527 | EOF | |
528 | test_expect_success 'status -s with relative paths' ' | |
529 | ||
68cfc6f5 | 530 | (cd dir1 && git status -s) >output && |
14ed05dd MG |
531 | test_cmp expect output |
532 | ||
533 | ' | |
534 | ||
68cfc6f5 | 535 | cat >expect <<\EOF |
c521bb71 MG |
536 | M dir1/modified |
537 | A dir2/added | |
538 | ?? dir1/untracked | |
539 | ?? dir2/modified | |
540 | ?? dir2/untracked | |
541 | ?? expect | |
542 | ?? output | |
543 | ?? untracked | |
544 | EOF | |
545 | ||
546 | test_expect_success 'status --porcelain ignores relative paths setting' ' | |
547 | ||
68cfc6f5 | 548 | (cd dir1 && git status --porcelain) >output && |
c521bb71 MG |
549 | test_cmp expect output |
550 | ||
551 | ' | |
552 | ||
68cfc6f5 MG |
553 | test_expect_success 'setup unique colors' ' |
554 | ||
1d282327 AA |
555 | git config status.color.untracked blue && |
556 | git config status.color.branch green | |
68cfc6f5 MG |
557 | |
558 | ' | |
559 | ||
560 | cat >expect <<\EOF | |
1d282327 | 561 | # On branch <GREEN>master<RESET> |
68cfc6f5 MG |
562 | # Changes to be committed: |
563 | # (use "git reset HEAD <file>..." to unstage) | |
564 | # | |
565 | # <GREEN>new file: dir2/added<RESET> | |
566 | # | |
8009d83c | 567 | # Changes not staged for commit: |
68cfc6f5 MG |
568 | # (use "git add <file>..." to update what will be committed) |
569 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
570 | # | |
571 | # <RED>modified: dir1/modified<RESET> | |
572 | # | |
573 | # Untracked files: | |
574 | # (use "git add <file>..." to include in what will be committed) | |
575 | # | |
576 | # <BLUE>dir1/untracked<RESET> | |
577 | # <BLUE>dir2/modified<RESET> | |
578 | # <BLUE>dir2/untracked<RESET> | |
579 | # <BLUE>expect<RESET> | |
580 | # <BLUE>output<RESET> | |
581 | # <BLUE>untracked<RESET> | |
582 | EOF | |
583 | ||
cc6658e7 | 584 | test_expect_success 'status with color.ui' ' |
c63659dd | 585 | test_config color.ui always && |
68cfc6f5 | 586 | git status | test_decode_color >output && |
cc6658e7 | 587 | test_i18ncmp expect output |
68cfc6f5 MG |
588 | ' |
589 | ||
cc6658e7 | 590 | test_expect_success 'status with color.status' ' |
c63659dd | 591 | test_config color.status always && |
68cfc6f5 | 592 | git status | test_decode_color >output && |
cc6658e7 | 593 | test_i18ncmp expect output |
68cfc6f5 MG |
594 | ' |
595 | ||
596 | cat >expect <<\EOF | |
597 | <RED>M<RESET> dir1/modified | |
598 | <GREEN>A<RESET> dir2/added | |
599 | <BLUE>??<RESET> dir1/untracked | |
600 | <BLUE>??<RESET> dir2/modified | |
601 | <BLUE>??<RESET> dir2/untracked | |
602 | <BLUE>??<RESET> expect | |
603 | <BLUE>??<RESET> output | |
604 | <BLUE>??<RESET> untracked | |
605 | EOF | |
606 | ||
607 | test_expect_success 'status -s with color.ui' ' | |
608 | ||
68cfc6f5 MG |
609 | git config color.ui always && |
610 | git status -s | test_decode_color >output && | |
611 | test_cmp expect output | |
612 | ||
613 | ' | |
614 | ||
615 | test_expect_success 'status -s with color.status' ' | |
616 | ||
617 | git config --unset color.ui && | |
618 | git config color.status always && | |
619 | git status -s | test_decode_color >output && | |
620 | test_cmp expect output | |
621 | ||
622 | ' | |
623 | ||
46077fa5 MG |
624 | cat >expect <<\EOF |
625 | ## <GREEN>master<RESET> | |
626 | <RED>M<RESET> dir1/modified | |
627 | <GREEN>A<RESET> dir2/added | |
628 | <BLUE>??<RESET> dir1/untracked | |
629 | <BLUE>??<RESET> dir2/modified | |
630 | <BLUE>??<RESET> dir2/untracked | |
631 | <BLUE>??<RESET> expect | |
632 | <BLUE>??<RESET> output | |
633 | <BLUE>??<RESET> untracked | |
634 | EOF | |
635 | ||
636 | test_expect_success 'status -s -b with color.status' ' | |
637 | ||
638 | git status -s -b | test_decode_color >output && | |
639 | test_cmp expect output | |
640 | ||
641 | ' | |
642 | ||
68cfc6f5 MG |
643 | cat >expect <<\EOF |
644 | M dir1/modified | |
645 | A dir2/added | |
646 | ?? dir1/untracked | |
647 | ?? dir2/modified | |
648 | ?? dir2/untracked | |
649 | ?? expect | |
650 | ?? output | |
651 | ?? untracked | |
652 | EOF | |
653 | ||
654 | test_expect_success 'status --porcelain ignores color.ui' ' | |
655 | ||
656 | git config --unset color.status && | |
657 | git config color.ui always && | |
658 | git status --porcelain | test_decode_color >output && | |
659 | test_cmp expect output | |
660 | ||
661 | ' | |
662 | ||
663 | test_expect_success 'status --porcelain ignores color.status' ' | |
664 | ||
665 | git config --unset color.ui && | |
666 | git config color.status always && | |
667 | git status --porcelain | test_decode_color >output && | |
668 | test_cmp expect output | |
669 | ||
670 | ' | |
671 | ||
672 | # recover unconditionally from color tests | |
673 | git config --unset color.status | |
674 | git config --unset color.ui | |
675 | ||
d4a6bf1f | 676 | test_expect_success 'status --porcelain respects -b' ' |
46077fa5 MG |
677 | |
678 | git status --porcelain -b >output && | |
d4a6bf1f JK |
679 | { |
680 | echo "## master" && | |
681 | cat expect | |
682 | } >tmp && | |
683 | mv tmp expect && | |
46077fa5 MG |
684 | test_cmp expect output |
685 | ||
686 | ' | |
687 | ||
68cfc6f5 | 688 | cat >expect <<\EOF |
46f721c8 JK |
689 | # On branch master |
690 | # Changes to be committed: | |
691 | # (use "git reset HEAD <file>..." to unstage) | |
692 | # | |
693 | # new file: dir2/added | |
694 | # | |
8009d83c | 695 | # Changes not staged for commit: |
46f721c8 | 696 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 697 | # (use "git checkout -- <file>..." to discard changes in working directory) |
46f721c8 JK |
698 | # |
699 | # modified: dir1/modified | |
700 | # | |
701 | # Untracked files: | |
702 | # (use "git add <file>..." to include in what will be committed) | |
703 | # | |
704 | # dir1/untracked | |
705 | # dir2/modified | |
706 | # dir2/untracked | |
707 | # expect | |
708 | # output | |
709 | # untracked | |
710 | EOF | |
711 | ||
68cfc6f5 | 712 | |
cc6658e7 | 713 | test_expect_success 'status without relative paths' ' |
46f721c8 | 714 | |
c63659dd | 715 | test_config status.relativePaths false && |
68cfc6f5 | 716 | (cd dir1 && git status) >output && |
cc6658e7 | 717 | test_i18ncmp expect output |
46f721c8 JK |
718 | |
719 | ' | |
720 | ||
68cfc6f5 | 721 | cat >expect <<\EOF |
14ed05dd MG |
722 | M dir1/modified |
723 | A dir2/added | |
724 | ?? dir1/untracked | |
725 | ?? dir2/modified | |
726 | ?? dir2/untracked | |
727 | ?? expect | |
728 | ?? output | |
729 | ?? untracked | |
730 | EOF | |
731 | ||
732 | test_expect_success 'status -s without relative paths' ' | |
733 | ||
c63659dd | 734 | test_config status.relativePaths false && |
68cfc6f5 | 735 | (cd dir1 && git status -s) >output && |
14ed05dd MG |
736 | test_cmp expect output |
737 | ||
738 | ' | |
739 | ||
959ba670 JK |
740 | cat <<EOF >expect |
741 | # On branch master | |
742 | # Changes to be committed: | |
743 | # (use "git reset HEAD <file>..." to unstage) | |
744 | # | |
745 | # modified: dir1/modified | |
746 | # | |
747 | # Untracked files: | |
748 | # (use "git add <file>..." to include in what will be committed) | |
749 | # | |
750 | # dir1/untracked | |
751 | # dir2/ | |
752 | # expect | |
753 | # output | |
754 | # untracked | |
755 | EOF | |
9e4b7ab6 | 756 | test_expect_success 'dry-run of partial commit excluding new file in index' ' |
cc6658e7 JH |
757 | git commit --dry-run dir1/modified >output && |
758 | test_i18ncmp expect output | |
959ba670 JK |
759 | ' |
760 | ||
4c926b37 MH |
761 | cat >expect <<EOF |
762 | :100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M dir1/modified | |
763 | EOF | |
4bb6644d | 764 | test_expect_success 'status refreshes the index' ' |
4c926b37 MH |
765 | touch dir2/added && |
766 | git status && | |
767 | git diff-files >output && | |
768 | test_cmp expect output | |
769 | ' | |
770 | ||
e5e4a7f2 PY |
771 | test_expect_success 'setup status submodule summary' ' |
772 | test_create_repo sm && ( | |
773 | cd sm && | |
774 | >foo && | |
775 | git add foo && | |
776 | git commit -m "Add foo" | |
777 | ) && | |
778 | git add sm | |
779 | ' | |
780 | ||
781 | cat >expect <<EOF | |
782 | # On branch master | |
783 | # Changes to be committed: | |
784 | # (use "git reset HEAD <file>..." to unstage) | |
785 | # | |
786 | # new file: dir2/added | |
787 | # new file: sm | |
788 | # | |
8009d83c | 789 | # Changes not staged for commit: |
e5e4a7f2 | 790 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 791 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
792 | # |
793 | # modified: dir1/modified | |
794 | # | |
795 | # Untracked files: | |
796 | # (use "git add <file>..." to include in what will be committed) | |
797 | # | |
798 | # dir1/untracked | |
799 | # dir2/modified | |
800 | # dir2/untracked | |
801 | # expect | |
802 | # output | |
803 | # untracked | |
804 | EOF | |
cc6658e7 | 805 | test_expect_success 'status submodule summary is disabled by default' ' |
e5e4a7f2 | 806 | git status >output && |
cc6658e7 | 807 | test_i18ncmp expect output |
e5e4a7f2 PY |
808 | ' |
809 | ||
98fa4738 | 810 | # we expect the same as the previous test |
cc6658e7 | 811 | test_expect_success 'status --untracked-files=all does not show submodule' ' |
98fa4738 | 812 | git status --untracked-files=all >output && |
cc6658e7 | 813 | test_i18ncmp expect output |
e5e4a7f2 PY |
814 | ' |
815 | ||
14ed05dd MG |
816 | cat >expect <<EOF |
817 | M dir1/modified | |
818 | A dir2/added | |
819 | A sm | |
820 | ?? dir1/untracked | |
821 | ?? dir2/modified | |
822 | ?? dir2/untracked | |
823 | ?? expect | |
824 | ?? output | |
825 | ?? untracked | |
826 | EOF | |
827 | test_expect_success 'status -s submodule summary is disabled by default' ' | |
828 | git status -s >output && | |
829 | test_cmp expect output | |
830 | ' | |
831 | ||
832 | # we expect the same as the previous test | |
833 | test_expect_success 'status -s --untracked-files=all does not show submodule' ' | |
834 | git status -s --untracked-files=all >output && | |
835 | test_cmp expect output | |
836 | ' | |
837 | ||
e5e4a7f2 PY |
838 | head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
839 | ||
840 | cat >expect <<EOF | |
841 | # On branch master | |
842 | # Changes to be committed: | |
843 | # (use "git reset HEAD <file>..." to unstage) | |
844 | # | |
845 | # new file: dir2/added | |
846 | # new file: sm | |
847 | # | |
8009d83c | 848 | # Changes not staged for commit: |
e5e4a7f2 | 849 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 850 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
851 | # |
852 | # modified: dir1/modified | |
853 | # | |
f17a5d34 | 854 | # Submodule changes to be committed: |
e5e4a7f2 PY |
855 | # |
856 | # * sm 0000000...$head (1): | |
857 | # > Add foo | |
858 | # | |
859 | # Untracked files: | |
860 | # (use "git add <file>..." to include in what will be committed) | |
861 | # | |
862 | # dir1/untracked | |
863 | # dir2/modified | |
864 | # dir2/untracked | |
865 | # expect | |
866 | # output | |
867 | # untracked | |
868 | EOF | |
cc6658e7 | 869 | test_expect_success 'status submodule summary' ' |
e5e4a7f2 PY |
870 | git config status.submodulesummary 10 && |
871 | git status >output && | |
cc6658e7 | 872 | test_i18ncmp expect output |
e5e4a7f2 PY |
873 | ' |
874 | ||
14ed05dd MG |
875 | cat >expect <<EOF |
876 | M dir1/modified | |
877 | A dir2/added | |
878 | A sm | |
879 | ?? dir1/untracked | |
880 | ?? dir2/modified | |
881 | ?? dir2/untracked | |
882 | ?? expect | |
883 | ?? output | |
884 | ?? untracked | |
885 | EOF | |
886 | test_expect_success 'status -s submodule summary' ' | |
887 | git status -s >output && | |
888 | test_cmp expect output | |
889 | ' | |
e5e4a7f2 PY |
890 | |
891 | cat >expect <<EOF | |
892 | # On branch master | |
8009d83c | 893 | # Changes not staged for commit: |
e5e4a7f2 | 894 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 895 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
896 | # |
897 | # modified: dir1/modified | |
898 | # | |
899 | # Untracked files: | |
900 | # (use "git add <file>..." to include in what will be committed) | |
901 | # | |
902 | # dir1/untracked | |
903 | # dir2/modified | |
904 | # dir2/untracked | |
905 | # expect | |
906 | # output | |
907 | # untracked | |
908 | no changes added to commit (use "git add" and/or "git commit -a") | |
909 | EOF | |
355ec7a1 | 910 | test_expect_success 'status submodule summary (clean submodule): commit' ' |
cc6658e7 | 911 | git commit -m "commit submodule" && |
e5e4a7f2 | 912 | git config status.submodulesummary 10 && |
9e4b7ab6 | 913 | test_must_fail git commit --dry-run >output && |
cc6658e7 | 914 | test_i18ncmp expect output && |
9e4b7ab6 | 915 | git status >output && |
cc6658e7 | 916 | test_i18ncmp expect output |
e5e4a7f2 PY |
917 | ' |
918 | ||
14ed05dd MG |
919 | cat >expect <<EOF |
920 | M dir1/modified | |
921 | ?? dir1/untracked | |
922 | ?? dir2/modified | |
923 | ?? dir2/untracked | |
924 | ?? expect | |
925 | ?? output | |
926 | ?? untracked | |
927 | EOF | |
928 | test_expect_success 'status -s submodule summary (clean submodule)' ' | |
929 | git status -s >output && | |
930 | test_cmp expect output | |
931 | ' | |
932 | ||
000f97bd | 933 | test_expect_success 'status -z implies porcelain' ' |
95b9f9f9 | 934 | git status --porcelain | |
7096b648 | 935 | "$PERL_PATH" -pe "s/\012/\000/g" >expect && |
95b9f9f9 BC |
936 | git status -z >output && |
937 | test_cmp expect output | |
938 | ' | |
939 | ||
e5e4a7f2 PY |
940 | cat >expect <<EOF |
941 | # On branch master | |
942 | # Changes to be committed: | |
943 | # (use "git reset HEAD^1 <file>..." to unstage) | |
944 | # | |
945 | # new file: dir2/added | |
946 | # new file: sm | |
947 | # | |
8009d83c | 948 | # Changes not staged for commit: |
e5e4a7f2 | 949 | # (use "git add <file>..." to update what will be committed) |
4d6e4c4d | 950 | # (use "git checkout -- <file>..." to discard changes in working directory) |
e5e4a7f2 PY |
951 | # |
952 | # modified: dir1/modified | |
953 | # | |
f17a5d34 | 954 | # Submodule changes to be committed: |
e5e4a7f2 PY |
955 | # |
956 | # * sm 0000000...$head (1): | |
957 | # > Add foo | |
958 | # | |
959 | # Untracked files: | |
960 | # (use "git add <file>..." to include in what will be committed) | |
961 | # | |
962 | # dir1/untracked | |
963 | # dir2/modified | |
964 | # dir2/untracked | |
965 | # expect | |
966 | # output | |
967 | # untracked | |
968 | EOF | |
cc6658e7 | 969 | test_expect_success 'commit --dry-run submodule summary (--amend)' ' |
e5e4a7f2 | 970 | git config status.submodulesummary 10 && |
9e4b7ab6 | 971 | git commit --dry-run --amend >output && |
cc6658e7 | 972 | test_i18ncmp expect output |
e5e4a7f2 PY |
973 | ' |
974 | ||
c91cfd19 | 975 | test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' ' |
b2f6fd95 MH |
976 | ( |
977 | chmod a-w .git && | |
978 | # make dir1/tracked stat-dirty | |
979 | >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked && | |
980 | git status -s >output && | |
981 | ! grep dir1/tracked output && | |
982 | # make sure "status" succeeded without writing index out | |
983 | git diff-files | grep dir1/tracked | |
984 | ) | |
985 | status=$? | |
986 | chmod 775 .git | |
987 | (exit $status) | |
988 | ' | |
989 | ||
c2e0940b | 990 | (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm |
aee9c7d6 JL |
991 | new_head=$(cd sm && git rev-parse --short=7 --verify HEAD) |
992 | touch .gitmodules | |
993 | ||
46a958b3 JL |
994 | cat > expect << EOF |
995 | # On branch master | |
aee9c7d6 JL |
996 | # Changes to be committed: |
997 | # (use "git reset HEAD <file>..." to unstage) | |
998 | # | |
999 | # modified: sm | |
1000 | # | |
8009d83c | 1001 | # Changes not staged for commit: |
46a958b3 JL |
1002 | # (use "git add <file>..." to update what will be committed) |
1003 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1004 | # | |
1005 | # modified: dir1/modified | |
1006 | # | |
aee9c7d6 JL |
1007 | # Submodule changes to be committed: |
1008 | # | |
1009 | # * sm $head...$new_head (1): | |
1010 | # > Add bar | |
1011 | # | |
46a958b3 JL |
1012 | # Untracked files: |
1013 | # (use "git add <file>..." to include in what will be committed) | |
1014 | # | |
aee9c7d6 | 1015 | # .gitmodules |
46a958b3 JL |
1016 | # dir1/untracked |
1017 | # dir2/modified | |
1018 | # dir2/untracked | |
1019 | # expect | |
1020 | # output | |
1021 | # untracked | |
46a958b3 JL |
1022 | EOF |
1023 | ||
cc6658e7 JH |
1024 | test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' |
1025 | echo modified sm/untracked && | |
1026 | git status --ignore-submodules=untracked >output && | |
1027 | test_i18ncmp expect output | |
46a958b3 JL |
1028 | ' |
1029 | ||
cc6658e7 | 1030 | test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' ' |
c63659dd | 1031 | test_config diff.ignoreSubmodules dirty && |
90e14525 | 1032 | git status >output && |
cc6658e7 | 1033 | test_i18ncmp expect output && |
302ad7a9 JL |
1034 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1035 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1036 | git status >output && |
1037 | test_i18ncmp expect output && | |
c63659dd | 1038 | git config -f .gitmodules --remove-section submodule.subname |
302ad7a9 JL |
1039 | ' |
1040 | ||
cc6658e7 | 1041 | test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' ' |
302ad7a9 JL |
1042 | git config --add -f .gitmodules submodule.subname.ignore none && |
1043 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1044 | git config --add submodule.subname.ignore untracked && |
1045 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1046 | git status >output && |
1047 | test_i18ncmp expect output && | |
302ad7a9 JL |
1048 | git config --remove-section submodule.subname && |
1049 | git config --remove-section -f .gitmodules submodule.subname | |
aee9c7d6 JL |
1050 | ' |
1051 | ||
cc6658e7 JH |
1052 | test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' ' |
1053 | git status --ignore-submodules=dirty >output && | |
1054 | test_i18ncmp expect output | |
46a958b3 JL |
1055 | ' |
1056 | ||
cc6658e7 | 1057 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' ' |
c63659dd | 1058 | test_config diff.ignoreSubmodules dirty && |
90e14525 JL |
1059 | git status >output && |
1060 | ! test -s actual && | |
302ad7a9 JL |
1061 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1062 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1063 | git status >output && |
1064 | test_i18ncmp expect output && | |
c63659dd | 1065 | git config -f .gitmodules --remove-section submodule.subname |
302ad7a9 JL |
1066 | ' |
1067 | ||
cc6658e7 | 1068 | test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' ' |
302ad7a9 JL |
1069 | git config --add -f .gitmodules submodule.subname.ignore none && |
1070 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1071 | git config --add submodule.subname.ignore dirty && |
1072 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1073 | git status >output && |
1074 | test_i18ncmp expect output && | |
302ad7a9 JL |
1075 | git config --remove-section submodule.subname && |
1076 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1077 | ' |
1078 | ||
cc6658e7 JH |
1079 | test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' ' |
1080 | echo modified >sm/foo && | |
1081 | git status --ignore-submodules=dirty >output && | |
1082 | test_i18ncmp expect output | |
46a958b3 JL |
1083 | ' |
1084 | ||
cc6658e7 | 1085 | test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' ' |
302ad7a9 JL |
1086 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1087 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1088 | git status >output && |
1089 | test_i18ncmp expect output && | |
302ad7a9 JL |
1090 | git config -f .gitmodules --remove-section submodule.subname |
1091 | ' | |
1092 | ||
cc6658e7 | 1093 | test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' ' |
302ad7a9 JL |
1094 | git config --add -f .gitmodules submodule.subname.ignore none && |
1095 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1096 | git config --add submodule.subname.ignore dirty && |
1097 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1098 | git status >output && |
1099 | test_i18ncmp expect output && | |
302ad7a9 JL |
1100 | git config --remove-section submodule.subname && |
1101 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1102 | ' |
1103 | ||
46a958b3 JL |
1104 | cat > expect << EOF |
1105 | # On branch master | |
aee9c7d6 JL |
1106 | # Changes to be committed: |
1107 | # (use "git reset HEAD <file>..." to unstage) | |
1108 | # | |
1109 | # modified: sm | |
1110 | # | |
8009d83c | 1111 | # Changes not staged for commit: |
46a958b3 JL |
1112 | # (use "git add <file>..." to update what will be committed) |
1113 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1114 | # (commit or discard the untracked or modified content in submodules) | |
1115 | # | |
1116 | # modified: dir1/modified | |
1117 | # modified: sm (modified content) | |
1118 | # | |
aee9c7d6 JL |
1119 | # Submodule changes to be committed: |
1120 | # | |
1121 | # * sm $head...$new_head (1): | |
1122 | # > Add bar | |
1123 | # | |
46a958b3 JL |
1124 | # Untracked files: |
1125 | # (use "git add <file>..." to include in what will be committed) | |
1126 | # | |
aee9c7d6 | 1127 | # .gitmodules |
46a958b3 JL |
1128 | # dir1/untracked |
1129 | # dir2/modified | |
1130 | # dir2/untracked | |
1131 | # expect | |
1132 | # output | |
1133 | # untracked | |
46a958b3 JL |
1134 | EOF |
1135 | ||
cc6658e7 | 1136 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' |
46a958b3 | 1137 | git status --ignore-submodules=untracked > output && |
cc6658e7 | 1138 | test_i18ncmp expect output |
46a958b3 JL |
1139 | ' |
1140 | ||
cc6658e7 | 1141 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" ' |
302ad7a9 JL |
1142 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1143 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1144 | git status >output && |
1145 | test_i18ncmp expect output && | |
302ad7a9 JL |
1146 | git config -f .gitmodules --remove-section submodule.subname |
1147 | ' | |
1148 | ||
cc6658e7 | 1149 | test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" ' |
302ad7a9 JL |
1150 | git config --add -f .gitmodules submodule.subname.ignore none && |
1151 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1152 | git config --add submodule.subname.ignore untracked && |
1153 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1154 | git status >output && |
1155 | test_i18ncmp expect output && | |
302ad7a9 JL |
1156 | git config --remove-section submodule.subname && |
1157 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1158 | ' |
1159 | ||
46a958b3 JL |
1160 | head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD) |
1161 | ||
1162 | cat > expect << EOF | |
1163 | # On branch master | |
aee9c7d6 JL |
1164 | # Changes to be committed: |
1165 | # (use "git reset HEAD <file>..." to unstage) | |
1166 | # | |
1167 | # modified: sm | |
1168 | # | |
8009d83c | 1169 | # Changes not staged for commit: |
46a958b3 JL |
1170 | # (use "git add <file>..." to update what will be committed) |
1171 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1172 | # | |
1173 | # modified: dir1/modified | |
1174 | # modified: sm (new commits) | |
1175 | # | |
aee9c7d6 JL |
1176 | # Submodule changes to be committed: |
1177 | # | |
1178 | # * sm $head...$new_head (1): | |
1179 | # > Add bar | |
1180 | # | |
46a958b3 JL |
1181 | # Submodules changed but not updated: |
1182 | # | |
aee9c7d6 | 1183 | # * sm $new_head...$head2 (1): |
46a958b3 JL |
1184 | # > 2nd commit |
1185 | # | |
1186 | # Untracked files: | |
1187 | # (use "git add <file>..." to include in what will be committed) | |
1188 | # | |
aee9c7d6 | 1189 | # .gitmodules |
46a958b3 JL |
1190 | # dir1/untracked |
1191 | # dir2/modified | |
1192 | # dir2/untracked | |
1193 | # expect | |
1194 | # output | |
1195 | # untracked | |
46a958b3 JL |
1196 | EOF |
1197 | ||
cc6658e7 | 1198 | test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' |
46a958b3 | 1199 | git status --ignore-submodules=untracked > output && |
cc6658e7 | 1200 | test_i18ncmp expect output |
46a958b3 JL |
1201 | ' |
1202 | ||
cc6658e7 | 1203 | test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" ' |
302ad7a9 JL |
1204 | git config --add -f .gitmodules submodule.subname.ignore untracked && |
1205 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1206 | git status >output && |
1207 | test_i18ncmp expect output && | |
302ad7a9 JL |
1208 | git config -f .gitmodules --remove-section submodule.subname |
1209 | ' | |
1210 | ||
cc6658e7 | 1211 | test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" ' |
302ad7a9 JL |
1212 | git config --add -f .gitmodules submodule.subname.ignore none && |
1213 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1214 | git config --add submodule.subname.ignore untracked && |
1215 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1216 | git status >output && |
1217 | test_i18ncmp expect output && | |
302ad7a9 JL |
1218 | git config --remove-section submodule.subname && |
1219 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1220 | ' |
1221 | ||
cc6658e7 | 1222 | test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" ' |
46a958b3 | 1223 | git status --ignore-submodules=dirty > output && |
cc6658e7 | 1224 | test_i18ncmp expect output |
46a958b3 | 1225 | ' |
cc6658e7 | 1226 | test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" ' |
302ad7a9 JL |
1227 | git config --add -f .gitmodules submodule.subname.ignore dirty && |
1228 | git config --add -f .gitmodules submodule.subname.path sm && | |
cc6658e7 JH |
1229 | git status >output && |
1230 | test_i18ncmp expect output && | |
302ad7a9 JL |
1231 | git config -f .gitmodules --remove-section submodule.subname |
1232 | ' | |
46a958b3 | 1233 | |
cc6658e7 | 1234 | test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" ' |
302ad7a9 JL |
1235 | git config --add -f .gitmodules submodule.subname.ignore none && |
1236 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1237 | git config --add submodule.subname.ignore dirty && |
1238 | git config --add submodule.subname.path sm && | |
cc6658e7 JH |
1239 | git status >output && |
1240 | test_i18ncmp expect output && | |
302ad7a9 JL |
1241 | git config --remove-section submodule.subname && |
1242 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1243 | ' |
1244 | ||
eff80a9f JH |
1245 | cat > expect << EOF |
1246 | ; On branch master | |
1247 | ; Changes to be committed: | |
1248 | ; (use "git reset HEAD <file>..." to unstage) | |
1249 | ; | |
1250 | ; modified: sm | |
1251 | ; | |
1252 | ; Changes not staged for commit: | |
1253 | ; (use "git add <file>..." to update what will be committed) | |
1254 | ; (use "git checkout -- <file>..." to discard changes in working directory) | |
1255 | ; | |
1256 | ; modified: dir1/modified | |
1257 | ; modified: sm (new commits) | |
1258 | ; | |
1259 | ; Submodule changes to be committed: | |
1260 | ; | |
1261 | ; * sm $head...$new_head (1): | |
1262 | ; > Add bar | |
1263 | ; | |
1264 | ; Submodules changed but not updated: | |
1265 | ; | |
1266 | ; * sm $new_head...$head2 (1): | |
1267 | ; > 2nd commit | |
1268 | ; | |
1269 | ; Untracked files: | |
1270 | ; (use "git add <file>..." to include in what will be committed) | |
1271 | ; | |
1272 | ; .gitmodules | |
1273 | ; dir1/untracked | |
1274 | ; dir2/modified | |
1275 | ; dir2/untracked | |
1276 | ; expect | |
1277 | ; output | |
1278 | ; untracked | |
1279 | EOF | |
1280 | ||
1281 | test_expect_success "status (core.commentchar with submodule summary)" ' | |
c63659dd | 1282 | test_config core.commentchar ";" && |
eff80a9f JH |
1283 | git status >output && |
1284 | test_i18ncmp expect output | |
1285 | ' | |
1286 | ||
1287 | test_expect_success "status (core.commentchar with two chars with submodule summary)" ' | |
c63659dd | 1288 | test_config core.commentchar ";;" && |
eff80a9f JH |
1289 | git status >output && |
1290 | test_i18ncmp expect output | |
1291 | ' | |
1292 | ||
46a958b3 JL |
1293 | cat > expect << EOF |
1294 | # On branch master | |
8009d83c | 1295 | # Changes not staged for commit: |
46a958b3 JL |
1296 | # (use "git add <file>..." to update what will be committed) |
1297 | # (use "git checkout -- <file>..." to discard changes in working directory) | |
1298 | # | |
1299 | # modified: dir1/modified | |
1300 | # | |
1301 | # Untracked files: | |
1302 | # (use "git add <file>..." to include in what will be committed) | |
1303 | # | |
aee9c7d6 | 1304 | # .gitmodules |
46a958b3 JL |
1305 | # dir1/untracked |
1306 | # dir2/modified | |
1307 | # dir2/untracked | |
1308 | # expect | |
1309 | # output | |
1310 | # untracked | |
1311 | no changes added to commit (use "git add" and/or "git commit -a") | |
1312 | EOF | |
1313 | ||
cc6658e7 | 1314 | test_expect_success "--ignore-submodules=all suppresses submodule summary" ' |
46a958b3 | 1315 | git status --ignore-submodules=all > output && |
cc6658e7 | 1316 | test_i18ncmp expect output |
46a958b3 JL |
1317 | ' |
1318 | ||
302ad7a9 JL |
1319 | test_expect_failure '.gitmodules ignore=all suppresses submodule summary' ' |
1320 | git config --add -f .gitmodules submodule.subname.ignore all && | |
1321 | git config --add -f .gitmodules submodule.subname.path sm && | |
1322 | git status > output && | |
1323 | test_cmp expect output && | |
1324 | git config -f .gitmodules --remove-section submodule.subname | |
1325 | ' | |
1326 | ||
aee9c7d6 | 1327 | test_expect_failure '.git/config ignore=all suppresses submodule summary' ' |
302ad7a9 JL |
1328 | git config --add -f .gitmodules submodule.subname.ignore none && |
1329 | git config --add -f .gitmodules submodule.subname.path sm && | |
aee9c7d6 JL |
1330 | git config --add submodule.subname.ignore all && |
1331 | git config --add submodule.subname.path sm && | |
1332 | git status > output && | |
1333 | test_cmp expect output && | |
302ad7a9 JL |
1334 | git config --remove-section submodule.subname && |
1335 | git config -f .gitmodules --remove-section submodule.subname | |
aee9c7d6 JL |
1336 | ' |
1337 | ||
4fb5166a JJGG |
1338 | test_expect_success 'setup of test environment' ' |
1339 | git config status.showUntrackedFiles no && | |
1340 | git status -s >expected_short && | |
1341 | git status --no-short >expected_noshort | |
1342 | ' | |
1343 | ||
1344 | test_expect_success '"status.short=true" same as "-s"' ' | |
1345 | git -c status.short=true status >actual && | |
1346 | test_cmp expected_short actual | |
1347 | ' | |
1348 | ||
1349 | test_expect_success '"status.short=true" weaker than "--no-short"' ' | |
1350 | git -c status.short=true status --no-short >actual && | |
1351 | test_cmp expected_noshort actual | |
1352 | ' | |
1353 | ||
1354 | test_expect_success '"status.short=false" same as "--no-short"' ' | |
1355 | git -c status.short=false status >actual && | |
1356 | test_cmp expected_noshort actual | |
1357 | ' | |
1358 | ||
1359 | test_expect_success '"status.short=false" weaker than "-s"' ' | |
1360 | git -c status.short=false status -s >actual && | |
1361 | test_cmp expected_short actual | |
1362 | ' | |
1363 | ||
1364 | test_expect_success 'Restore default test environment' ' | |
1365 | git config --unset status.showUntrackedFiles | |
1366 | ' | |
1367 | ||
367c9886 | 1368 | test_done |