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