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