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