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