surround %s with quotes when failed to lookup commit
[git/debian.git] / t / t7508-status.sh
blobaed07c5b622e9a244313e781ceba0e6898024d21
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-terminal.sh
11 test_expect_success 'status -h in broken repository' '
12 git config --global advice.statusuoption false &&
13 mkdir broken &&
14 test_when_finished "rm -fr broken" &&
16 cd broken &&
17 git init &&
18 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
19 test_expect_code 129 git status -h >usage 2>&1
20 ) &&
21 test_i18ngrep "[Uu]sage" broken/usage
24 test_expect_success 'commit -h in broken repository' '
25 mkdir broken &&
26 test_when_finished "rm -fr broken" &&
28 cd broken &&
29 git init &&
30 echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
31 test_expect_code 129 git commit -h >usage 2>&1
32 ) &&
33 test_i18ngrep "[Uu]sage" broken/usage
36 test_expect_success 'create upstream branch' '
37 git checkout -b upstream &&
38 test_commit upstream1 &&
39 test_commit upstream2 &&
40 # leave the first commit on main as root because several
41 # tests depend on this case; for our upstream we only
42 # care about commit counts anyway, so a totally divergent
43 # history is OK
44 git checkout --orphan main
47 test_expect_success 'setup' '
48 : >tracked &&
49 : >modified &&
50 mkdir dir1 &&
51 : >dir1/tracked &&
52 : >dir1/modified &&
53 mkdir dir2 &&
54 : >dir1/tracked &&
55 : >dir1/modified &&
56 git add . &&
58 git status >output &&
60 test_tick &&
61 git commit -m initial &&
62 : >untracked &&
63 : >dir1/untracked &&
64 : >dir2/untracked &&
65 echo 1 >dir1/modified &&
66 echo 2 >dir2/modified &&
67 echo 3 >dir2/added &&
68 git add dir2/added &&
70 git branch --set-upstream-to=upstream
73 test_expect_success 'status (1)' '
74 test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
77 strip_comments () {
78 tab=' '
79 sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
80 rm "$1" && mv "$1".tmp "$1"
83 cat >.gitignore <<\EOF
84 .gitignore
85 expect*
86 output*
87 EOF
89 test_expect_success 'status --column' '
90 cat >expect <<\EOF &&
91 # On branch main
92 # Your branch and '\''upstream'\'' have diverged,
93 # and have 1 and 2 different commits each, respectively.
94 # (use "git pull" to merge the remote branch into yours)
96 # Changes to be committed:
97 # (use "git restore --staged <file>..." to unstage)
98 # new file: dir2/added
100 # Changes not staged for commit:
101 # (use "git add <file>..." to update what will be committed)
102 # (use "git restore <file>..." to discard changes in working directory)
103 # modified: dir1/modified
105 # Untracked files:
106 # (use "git add <file>..." to include in what will be committed)
107 # dir1/untracked dir2/untracked
108 # dir2/modified untracked
111 COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
112 test_cmp expect output
115 test_expect_success 'status --column status.displayCommentPrefix=false' '
116 strip_comments expect &&
117 COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
118 test_cmp expect output
121 cat >expect <<\EOF
122 # On branch main
123 # Your branch and 'upstream' have diverged,
124 # and have 1 and 2 different commits each, respectively.
125 # (use "git pull" to merge the remote branch into yours)
127 # Changes to be committed:
128 # (use "git restore --staged <file>..." to unstage)
129 # new file: dir2/added
131 # Changes not staged for commit:
132 # (use "git add <file>..." to update what will be committed)
133 # (use "git restore <file>..." to discard changes in working directory)
134 # modified: dir1/modified
136 # Untracked files:
137 # (use "git add <file>..." to include in what will be committed)
138 # dir1/untracked
139 # dir2/modified
140 # dir2/untracked
141 # untracked
145 test_expect_success 'status with status.displayCommentPrefix=true' '
146 git -c status.displayCommentPrefix=true status >output &&
147 test_cmp expect output
150 test_expect_success 'status with status.displayCommentPrefix=false' '
151 strip_comments expect &&
152 git -c status.displayCommentPrefix=false status >output &&
153 test_cmp expect output
156 test_expect_success 'status -v' '
157 (cat expect && git diff --cached) >expect-with-v &&
158 git status -v >output &&
159 test_cmp expect-with-v output
162 test_expect_success 'status -v -v' '
163 (cat expect &&
164 echo "Changes to be committed:" &&
165 git -c diff.mnemonicprefix=true diff --cached &&
166 echo "--------------------------------------------------" &&
167 echo "Changes not staged for commit:" &&
168 git -c diff.mnemonicprefix=true diff) >expect-with-v &&
169 git status -v -v >output &&
170 test_cmp expect-with-v output
173 test_expect_success 'setup fake editor' '
174 cat >.git/editor <<-\EOF &&
175 #! /bin/sh
176 cp "$1" output
178 chmod 755 .git/editor
181 commit_template_commented () {
183 EDITOR=.git/editor &&
184 export EDITOR &&
185 # Fails due to empty message
186 test_must_fail git commit
187 ) &&
188 ! grep '^[^#]' output
191 test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
192 commit_template_commented
195 cat >expect <<\EOF
196 On branch main
197 Your branch and 'upstream' have diverged,
198 and have 1 and 2 different commits each, respectively.
200 Changes to be committed:
201 new file: dir2/added
203 Changes not staged for commit:
204 modified: dir1/modified
206 Untracked files:
207 dir1/untracked
208 dir2/modified
209 dir2/untracked
210 untracked
214 test_expect_success 'status (advice.statusHints false)' '
215 test_config advice.statusHints false &&
216 git status >output &&
217 test_cmp expect output
221 cat >expect <<\EOF
222 M dir1/modified
223 A dir2/added
224 ?? dir1/untracked
225 ?? dir2/modified
226 ?? dir2/untracked
227 ?? untracked
230 test_expect_success 'status -s' '
232 git status -s >output &&
233 test_cmp expect output
237 test_expect_success 'status with gitignore' '
239 echo ".gitignore" &&
240 echo "expect*" &&
241 echo "output" &&
242 echo "untracked"
243 } >.gitignore &&
245 cat >expect <<-\EOF &&
246 M dir1/modified
247 A dir2/added
248 ?? dir2/modified
250 git status -s >output &&
251 test_cmp expect output &&
253 cat >expect <<-\EOF &&
254 M dir1/modified
255 A dir2/added
256 ?? dir2/modified
257 !! .gitignore
258 !! dir1/untracked
259 !! dir2/untracked
260 !! expect
261 !! expect-with-v
262 !! output
263 !! untracked
265 git status -s --ignored >output &&
266 test_cmp expect output &&
268 cat >expect <<\EOF &&
269 On branch main
270 Your branch and '\''upstream'\'' have diverged,
271 and have 1 and 2 different commits each, respectively.
272 (use "git pull" to merge the remote branch into yours)
274 Changes to be committed:
275 (use "git restore --staged <file>..." to unstage)
276 new file: dir2/added
278 Changes not staged for commit:
279 (use "git add <file>..." to update what will be committed)
280 (use "git restore <file>..." to discard changes in working directory)
281 modified: dir1/modified
283 Untracked files:
284 (use "git add <file>..." to include in what will be committed)
285 dir2/modified
287 Ignored files:
288 (use "git add -f <file>..." to include in what will be committed)
289 .gitignore
290 dir1/untracked
291 dir2/untracked
292 expect
293 expect-with-v
294 output
295 untracked
298 git status --ignored >output &&
299 test_cmp expect output
302 test_expect_success 'status with gitignore (nothing untracked)' '
304 echo ".gitignore" &&
305 echo "expect*" &&
306 echo "dir2/modified" &&
307 echo "output" &&
308 echo "untracked"
309 } >.gitignore &&
311 cat >expect <<-\EOF &&
312 M dir1/modified
313 A dir2/added
315 git status -s >output &&
316 test_cmp expect output &&
318 cat >expect <<-\EOF &&
319 M dir1/modified
320 A dir2/added
321 !! .gitignore
322 !! dir1/untracked
323 !! dir2/modified
324 !! dir2/untracked
325 !! expect
326 !! expect-with-v
327 !! output
328 !! untracked
330 git status -s --ignored >output &&
331 test_cmp expect output &&
333 cat >expect <<\EOF &&
334 On branch main
335 Your branch and '\''upstream'\'' have diverged,
336 and have 1 and 2 different commits each, respectively.
337 (use "git pull" to merge the remote branch into yours)
339 Changes to be committed:
340 (use "git restore --staged <file>..." to unstage)
341 new file: dir2/added
343 Changes not staged for commit:
344 (use "git add <file>..." to update what will be committed)
345 (use "git restore <file>..." to discard changes in working directory)
346 modified: dir1/modified
348 Ignored files:
349 (use "git add -f <file>..." to include in what will be committed)
350 .gitignore
351 dir1/untracked
352 dir2/modified
353 dir2/untracked
354 expect
355 expect-with-v
356 output
357 untracked
360 git status --ignored >output &&
361 test_cmp expect output
364 cat >.gitignore <<\EOF
365 .gitignore
366 expect*
367 output*
370 cat >expect <<\EOF
371 ## main...upstream [ahead 1, behind 2]
372 M dir1/modified
373 A dir2/added
374 ?? dir1/untracked
375 ?? dir2/modified
376 ?? dir2/untracked
377 ?? untracked
380 test_expect_success 'status -s -b' '
382 git status -s -b >output &&
383 test_cmp expect output
387 test_expect_success 'status -s -z -b' '
388 tr "\\n" Q <expect >expect.q &&
389 mv expect.q expect &&
390 git status -s -z -b >output &&
391 nul_to_q <output >output.q &&
392 mv output.q output &&
393 test_cmp expect output
396 test_expect_success 'setup dir3' '
397 mkdir dir3 &&
398 : >dir3/untracked1 &&
399 : >dir3/untracked2
402 test_expect_success 'status -uno' '
403 cat >expect <<EOF &&
404 On branch main
405 Your branch and '\''upstream'\'' have diverged,
406 and have 1 and 2 different commits each, respectively.
407 (use "git pull" to merge the remote branch into yours)
409 Changes to be committed:
410 (use "git restore --staged <file>..." to unstage)
411 new file: dir2/added
413 Changes not staged for commit:
414 (use "git add <file>..." to update what will be committed)
415 (use "git restore <file>..." to discard changes in working directory)
416 modified: dir1/modified
418 Untracked files not listed (use -u option to show untracked files)
420 git status -uno >output &&
421 test_cmp expect output
424 test_expect_success 'status (status.showUntrackedFiles no)' '
425 test_config status.showuntrackedfiles no &&
426 git status >output &&
427 test_cmp expect output
430 test_expect_success 'status -uno (advice.statusHints false)' '
431 cat >expect <<EOF &&
432 On branch main
433 Your branch and '\''upstream'\'' have diverged,
434 and have 1 and 2 different commits each, respectively.
436 Changes to be committed:
437 new file: dir2/added
439 Changes not staged for commit:
440 modified: dir1/modified
442 Untracked files not listed
444 test_config advice.statusHints false &&
445 git status -uno >output &&
446 test_cmp expect output
449 cat >expect << EOF
450 M dir1/modified
451 A dir2/added
453 test_expect_success 'status -s -uno' '
454 git status -s -uno >output &&
455 test_cmp expect output
458 test_expect_success 'status -s (status.showUntrackedFiles no)' '
459 git config status.showuntrackedfiles no &&
460 git status -s >output &&
461 test_cmp expect output
464 test_expect_success 'status -unormal' '
465 cat >expect <<EOF &&
466 On branch main
467 Your branch and '\''upstream'\'' have diverged,
468 and have 1 and 2 different commits each, respectively.
469 (use "git pull" to merge the remote branch into yours)
471 Changes to be committed:
472 (use "git restore --staged <file>..." to unstage)
473 new file: dir2/added
475 Changes not staged for commit:
476 (use "git add <file>..." to update what will be committed)
477 (use "git restore <file>..." to discard changes in working directory)
478 modified: dir1/modified
480 Untracked files:
481 (use "git add <file>..." to include in what will be committed)
482 dir1/untracked
483 dir2/modified
484 dir2/untracked
485 dir3/
486 untracked
489 git status -unormal >output &&
490 test_cmp expect output
493 test_expect_success 'status (status.showUntrackedFiles normal)' '
494 test_config status.showuntrackedfiles normal &&
495 git status >output &&
496 test_cmp expect output
499 cat >expect <<EOF
500 M dir1/modified
501 A dir2/added
502 ?? dir1/untracked
503 ?? dir2/modified
504 ?? dir2/untracked
505 ?? dir3/
506 ?? untracked
508 test_expect_success 'status -s -unormal' '
509 git status -s -unormal >output &&
510 test_cmp expect output
513 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
514 git config status.showuntrackedfiles normal &&
515 git status -s >output &&
516 test_cmp expect output
519 test_expect_success 'status -uall' '
520 cat >expect <<EOF &&
521 On branch main
522 Your branch and '\''upstream'\'' have diverged,
523 and have 1 and 2 different commits each, respectively.
524 (use "git pull" to merge the remote branch into yours)
526 Changes to be committed:
527 (use "git restore --staged <file>..." to unstage)
528 new file: dir2/added
530 Changes not staged for commit:
531 (use "git add <file>..." to update what will be committed)
532 (use "git restore <file>..." to discard changes in working directory)
533 modified: dir1/modified
535 Untracked files:
536 (use "git add <file>..." to include in what will be committed)
537 dir1/untracked
538 dir2/modified
539 dir2/untracked
540 dir3/untracked1
541 dir3/untracked2
542 untracked
545 git status -uall >output &&
546 test_cmp expect output
549 test_expect_success 'status (status.showUntrackedFiles all)' '
550 test_config status.showuntrackedfiles all &&
551 git status >output &&
552 test_cmp expect output
555 test_expect_success 'teardown dir3' '
556 rm -rf dir3
559 cat >expect <<EOF
560 M dir1/modified
561 A dir2/added
562 ?? dir1/untracked
563 ?? dir2/modified
564 ?? dir2/untracked
565 ?? untracked
567 test_expect_success 'status -s -uall' '
568 test_unconfig status.showuntrackedfiles &&
569 git status -s -uall >output &&
570 test_cmp expect output
572 test_expect_success 'status -s (status.showUntrackedFiles all)' '
573 test_config status.showuntrackedfiles all &&
574 git status -s >output &&
575 rm -rf dir3 &&
576 test_cmp expect output
579 test_expect_success 'status with relative paths' '
580 cat >expect <<\EOF &&
581 On branch main
582 Your branch and '\''upstream'\'' have diverged,
583 and have 1 and 2 different commits each, respectively.
584 (use "git pull" to merge the remote branch into yours)
586 Changes to be committed:
587 (use "git restore --staged <file>..." to unstage)
588 new file: ../dir2/added
590 Changes not staged for commit:
591 (use "git add <file>..." to update what will be committed)
592 (use "git restore <file>..." to discard changes in working directory)
593 modified: modified
595 Untracked files:
596 (use "git add <file>..." to include in what will be committed)
597 untracked
598 ../dir2/modified
599 ../dir2/untracked
600 ../untracked
603 (cd dir1 && git status) >output &&
604 test_cmp expect output
607 cat >expect <<\EOF
608 M modified
609 A ../dir2/added
610 ?? untracked
611 ?? ../dir2/modified
612 ?? ../dir2/untracked
613 ?? ../untracked
615 test_expect_success 'status -s with relative paths' '
617 (cd dir1 && git status -s) >output &&
618 test_cmp expect output
622 cat >expect <<\EOF
623 M dir1/modified
624 A dir2/added
625 ?? dir1/untracked
626 ?? dir2/modified
627 ?? dir2/untracked
628 ?? untracked
631 test_expect_success 'status --porcelain ignores relative paths setting' '
633 (cd dir1 && git status --porcelain) >output &&
634 test_cmp expect output
638 test_expect_success 'setup unique colors' '
640 git config status.color.untracked blue &&
641 git config status.color.branch green &&
642 git config status.color.localBranch yellow &&
643 git config status.color.remoteBranch cyan
647 test_expect_success TTY 'status with color.ui' '
648 cat >expect <<\EOF &&
649 On branch <GREEN>main<RESET>
650 Your branch and '\''upstream'\'' have diverged,
651 and have 1 and 2 different commits each, respectively.
652 (use "git pull" to merge the remote branch into yours)
654 Changes to be committed:
655 (use "git restore --staged <file>..." to unstage)
656 <GREEN>new file: dir2/added<RESET>
658 Changes not staged for commit:
659 (use "git add <file>..." to update what will be committed)
660 (use "git restore <file>..." to discard changes in working directory)
661 <RED>modified: dir1/modified<RESET>
663 Untracked files:
664 (use "git add <file>..." to include in what will be committed)
665 <BLUE>dir1/untracked<RESET>
666 <BLUE>dir2/modified<RESET>
667 <BLUE>dir2/untracked<RESET>
668 <BLUE>untracked<RESET>
671 test_config color.ui auto &&
672 test_terminal git status | test_decode_color >output &&
673 test_cmp expect output
676 test_expect_success TTY 'status with color.status' '
677 test_config color.status auto &&
678 test_terminal git status | test_decode_color >output &&
679 test_cmp expect output
682 cat >expect <<\EOF
683 <RED>M<RESET> dir1/modified
684 <GREEN>A<RESET> dir2/added
685 <BLUE>??<RESET> dir1/untracked
686 <BLUE>??<RESET> dir2/modified
687 <BLUE>??<RESET> dir2/untracked
688 <BLUE>??<RESET> untracked
691 test_expect_success TTY 'status -s with color.ui' '
693 git config color.ui auto &&
694 test_terminal git status -s | test_decode_color >output &&
695 test_cmp expect output
699 test_expect_success TTY 'status -s with color.status' '
701 git config --unset color.ui &&
702 git config color.status auto &&
703 test_terminal git status -s | test_decode_color >output &&
704 test_cmp expect output
708 cat >expect <<\EOF
709 ## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
710 <RED>M<RESET> dir1/modified
711 <GREEN>A<RESET> dir2/added
712 <BLUE>??<RESET> dir1/untracked
713 <BLUE>??<RESET> dir2/modified
714 <BLUE>??<RESET> dir2/untracked
715 <BLUE>??<RESET> untracked
718 test_expect_success TTY 'status -s -b with color.status' '
720 test_terminal git status -s -b | test_decode_color >output &&
721 test_cmp expect output
725 cat >expect <<\EOF
726 M dir1/modified
727 A dir2/added
728 ?? dir1/untracked
729 ?? dir2/modified
730 ?? dir2/untracked
731 ?? untracked
734 test_expect_success TTY 'status --porcelain ignores color.ui' '
736 git config --unset color.status &&
737 git config color.ui auto &&
738 test_terminal git status --porcelain | test_decode_color >output &&
739 test_cmp expect output
743 test_expect_success TTY 'status --porcelain ignores color.status' '
745 git config --unset color.ui &&
746 git config color.status auto &&
747 test_terminal git status --porcelain | test_decode_color >output &&
748 test_cmp expect output
752 # recover unconditionally from color tests
753 git config --unset color.status
754 git config --unset color.ui
756 test_expect_success 'status --porcelain respects -b' '
758 git status --porcelain -b >output &&
760 echo "## main...upstream [ahead 1, behind 2]" &&
761 cat expect
762 } >tmp &&
763 mv tmp expect &&
764 test_cmp expect output
770 test_expect_success 'status without relative paths' '
771 cat >expect <<\EOF &&
772 On branch main
773 Your branch and '\''upstream'\'' have diverged,
774 and have 1 and 2 different commits each, respectively.
775 (use "git pull" to merge the remote branch into yours)
777 Changes to be committed:
778 (use "git restore --staged <file>..." to unstage)
779 new file: dir2/added
781 Changes not staged for commit:
782 (use "git add <file>..." to update what will be committed)
783 (use "git restore <file>..." to discard changes in working directory)
784 modified: dir1/modified
786 Untracked files:
787 (use "git add <file>..." to include in what will be committed)
788 dir1/untracked
789 dir2/modified
790 dir2/untracked
791 untracked
794 test_config status.relativePaths false &&
795 (cd dir1 && git status) >output &&
796 test_cmp expect output
800 cat >expect <<\EOF
801 M dir1/modified
802 A dir2/added
803 ?? dir1/untracked
804 ?? dir2/modified
805 ?? dir2/untracked
806 ?? untracked
809 test_expect_success 'status -s without relative paths' '
811 test_config status.relativePaths false &&
812 (cd dir1 && git status -s) >output &&
813 test_cmp expect output
817 cat >expect <<\EOF
818 M dir1/modified
819 A dir2/added
820 A "file with spaces"
821 ?? dir1/untracked
822 ?? dir2/modified
823 ?? dir2/untracked
824 ?? "file with spaces 2"
825 ?? untracked
828 test_expect_success 'status -s without relative paths' '
829 test_when_finished "git rm --cached \"file with spaces\"; rm -f file*" &&
830 >"file with spaces" &&
831 >"file with spaces 2" &&
832 >"expect with spaces" &&
833 git add "file with spaces" &&
835 git status -s >output &&
836 test_cmp expect output &&
838 git status -s --ignored >output &&
839 grep "^!! \"expect with spaces\"$" output &&
840 grep -v "^!! " output >output-wo-ignored &&
841 test_cmp expect output-wo-ignored
844 test_expect_success 'dry-run of partial commit excluding new file in index' '
845 cat >expect <<EOF &&
846 On branch main
847 Your branch and '\''upstream'\'' have diverged,
848 and have 1 and 2 different commits each, respectively.
849 (use "git pull" to merge the remote branch into yours)
851 Changes to be committed:
852 (use "git restore --staged <file>..." to unstage)
853 modified: dir1/modified
855 Untracked files:
856 (use "git add <file>..." to include in what will be committed)
857 dir1/untracked
858 dir2/
859 untracked
862 git commit --dry-run dir1/modified >output &&
863 test_cmp expect output
866 cat >expect <<EOF
867 :100644 100644 $EMPTY_BLOB $ZERO_OID M dir1/modified
869 test_expect_success 'status refreshes the index' '
870 touch dir2/added &&
871 git status &&
872 git diff-files >output &&
873 test_cmp expect output
876 test_expect_success 'status shows detached HEAD properly after checking out non-local upstream branch' '
877 test_when_finished rm -rf upstream downstream actual &&
879 test_create_repo upstream &&
880 test_commit -C upstream foo &&
882 git clone upstream downstream &&
883 git -C downstream checkout @{u} &&
884 git -C downstream status >actual &&
885 grep -E "HEAD detached at [0-9a-f]+" actual
888 test_expect_success 'setup status submodule summary' '
889 test_create_repo sm && (
890 cd sm &&
891 >foo &&
892 git add foo &&
893 git commit -m "Add foo"
894 ) &&
895 git add sm
898 test_expect_success 'status submodule summary is disabled by default' '
899 cat >expect <<EOF &&
900 On branch main
901 Your branch and '\''upstream'\'' have diverged,
902 and have 1 and 2 different commits each, respectively.
903 (use "git pull" to merge the remote branch into yours)
905 Changes to be committed:
906 (use "git restore --staged <file>..." to unstage)
907 new file: dir2/added
908 new file: sm
910 Changes not staged for commit:
911 (use "git add <file>..." to update what will be committed)
912 (use "git restore <file>..." to discard changes in working directory)
913 modified: dir1/modified
915 Untracked files:
916 (use "git add <file>..." to include in what will be committed)
917 dir1/untracked
918 dir2/modified
919 dir2/untracked
920 untracked
923 git status >output &&
924 test_cmp expect output
927 # we expect the same as the previous test
928 test_expect_success 'status --untracked-files=all does not show submodule' '
929 git status --untracked-files=all >output &&
930 test_cmp expect output
933 cat >expect <<EOF
934 M dir1/modified
935 A dir2/added
936 A sm
937 ?? dir1/untracked
938 ?? dir2/modified
939 ?? dir2/untracked
940 ?? untracked
942 test_expect_success 'status -s submodule summary is disabled by default' '
943 git status -s >output &&
944 test_cmp expect output
947 # we expect the same as the previous test
948 test_expect_success 'status -s --untracked-files=all does not show submodule' '
949 git status -s --untracked-files=all >output &&
950 test_cmp expect output
953 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
955 test_expect_success 'status submodule summary' '
956 cat >expect <<EOF &&
957 On branch main
958 Your branch and '\''upstream'\'' have diverged,
959 and have 1 and 2 different commits each, respectively.
960 (use "git pull" to merge the remote branch into yours)
962 Changes to be committed:
963 (use "git restore --staged <file>..." to unstage)
964 new file: dir2/added
965 new file: sm
967 Changes not staged for commit:
968 (use "git add <file>..." to update what will be committed)
969 (use "git restore <file>..." to discard changes in working directory)
970 modified: dir1/modified
972 Submodule changes to be committed:
974 * sm 0000000...$head (1):
975 > Add foo
977 Untracked files:
978 (use "git add <file>..." to include in what will be committed)
979 dir1/untracked
980 dir2/modified
981 dir2/untracked
982 untracked
985 git config status.submodulesummary 10 &&
986 git status >output &&
987 test_cmp expect output
990 test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
991 strip_comments expect &&
992 git -c status.displayCommentPrefix=false status >output &&
993 test_cmp expect output
996 test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
997 commit_template_commented
1000 cat >expect <<EOF
1001 M dir1/modified
1002 A dir2/added
1003 A sm
1004 ?? dir1/untracked
1005 ?? dir2/modified
1006 ?? dir2/untracked
1007 ?? untracked
1009 test_expect_success 'status -s submodule summary' '
1010 git status -s >output &&
1011 test_cmp expect output
1014 test_expect_success 'status submodule summary (clean submodule): commit' '
1015 cat >expect <<EOF &&
1016 On branch main
1017 Your branch and '\''upstream'\'' have diverged,
1018 and have 2 and 2 different commits each, respectively.
1019 (use "git pull" to merge the remote branch into yours)
1021 Changes not staged for commit:
1022 (use "git add <file>..." to update what will be committed)
1023 (use "git restore <file>..." to discard changes in working directory)
1024 modified: dir1/modified
1026 Untracked files:
1027 (use "git add <file>..." to include in what will be committed)
1028 dir1/untracked
1029 dir2/modified
1030 dir2/untracked
1031 untracked
1033 no changes added to commit (use "git add" and/or "git commit -a")
1035 git commit -m "commit submodule" &&
1036 git config status.submodulesummary 10 &&
1037 test_must_fail git commit --dry-run >output &&
1038 test_cmp expect output &&
1039 git status >output &&
1040 test_cmp expect output
1043 cat >expect <<EOF
1044 M dir1/modified
1045 ?? dir1/untracked
1046 ?? dir2/modified
1047 ?? dir2/untracked
1048 ?? untracked
1050 test_expect_success 'status -s submodule summary (clean submodule)' '
1051 git status -s >output &&
1052 test_cmp expect output
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
1062 test_expect_success 'commit --dry-run submodule summary (--amend)' '
1063 cat >expect <<EOF &&
1064 On branch main
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)
1069 Changes to be committed:
1070 (use "git restore --source=HEAD^1 --staged <file>..." to unstage)
1071 new file: dir2/added
1072 new file: sm
1074 Changes not staged for commit:
1075 (use "git add <file>..." to update what will be committed)
1076 (use "git restore <file>..." to discard changes in working directory)
1077 modified: dir1/modified
1079 Submodule changes to be committed:
1081 * sm 0000000...$head (1):
1082 > Add foo
1084 Untracked files:
1085 (use "git add <file>..." to include in what will be committed)
1086 dir1/untracked
1087 dir2/modified
1088 dir2/untracked
1089 untracked
1092 git config status.submodulesummary 10 &&
1093 git commit --dry-run --amend >output &&
1094 test_cmp expect output
1097 test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
1098 test_when_finished "chmod 775 .git" &&
1100 chmod a-w .git &&
1101 # make dir1/tracked stat-dirty
1102 >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
1103 git status -s >output &&
1104 ! grep dir1/tracked output &&
1105 # make sure "status" succeeded without writing index out
1106 git diff-files | grep dir1/tracked
1110 (cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
1111 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
1112 touch .gitmodules
1114 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
1115 cat > expect << EOF &&
1116 On branch main
1117 Your branch and '\''upstream'\'' have diverged,
1118 and have 2 and 2 different commits each, respectively.
1119 (use "git pull" to merge the remote branch into yours)
1121 Changes to be committed:
1122 (use "git restore --staged <file>..." to unstage)
1123 modified: sm
1125 Changes not staged for commit:
1126 (use "git add <file>..." to update what will be committed)
1127 (use "git restore <file>..." to discard changes in working directory)
1128 modified: dir1/modified
1130 Submodule changes to be committed:
1132 * sm $head...$new_head (1):
1133 > Add bar
1135 Untracked files:
1136 (use "git add <file>..." to include in what will be committed)
1137 .gitmodules
1138 dir1/untracked
1139 dir2/modified
1140 dir2/untracked
1141 untracked
1144 echo modified sm/untracked &&
1145 git status --ignore-submodules=untracked >output &&
1146 test_cmp expect output
1149 test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
1150 test_config diff.ignoreSubmodules dirty &&
1151 git status >output &&
1152 test_cmp expect output &&
1153 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1154 git config --add -f .gitmodules submodule.subname.path sm &&
1155 git status >output &&
1156 test_cmp expect output &&
1157 git config -f .gitmodules --remove-section submodule.subname
1160 test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
1161 git config --add -f .gitmodules submodule.subname.ignore none &&
1162 git config --add -f .gitmodules submodule.subname.path sm &&
1163 git config --add submodule.subname.ignore untracked &&
1164 git config --add submodule.subname.path sm &&
1165 git status >output &&
1166 test_cmp expect output &&
1167 git config --remove-section submodule.subname &&
1168 git config --remove-section -f .gitmodules submodule.subname
1171 test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
1172 git status --ignore-submodules=dirty >output &&
1173 test_cmp expect output
1176 test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
1177 test_config diff.ignoreSubmodules dirty &&
1178 git status >output &&
1179 ! test -s actual &&
1180 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1181 git config --add -f .gitmodules submodule.subname.path sm &&
1182 git status >output &&
1183 test_cmp expect output &&
1184 git config -f .gitmodules --remove-section submodule.subname
1187 test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
1188 git config --add -f .gitmodules submodule.subname.ignore none &&
1189 git config --add -f .gitmodules submodule.subname.path sm &&
1190 git config --add submodule.subname.ignore dirty &&
1191 git config --add submodule.subname.path sm &&
1192 git status >output &&
1193 test_cmp expect output &&
1194 git config --remove-section submodule.subname &&
1195 git config -f .gitmodules --remove-section submodule.subname
1198 test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
1199 echo modified >sm/foo &&
1200 git status --ignore-submodules=dirty >output &&
1201 test_cmp expect output
1204 test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
1205 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1206 git config --add -f .gitmodules submodule.subname.path sm &&
1207 git status >output &&
1208 test_cmp expect output &&
1209 git config -f .gitmodules --remove-section submodule.subname
1212 test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
1213 git config --add -f .gitmodules submodule.subname.ignore none &&
1214 git config --add -f .gitmodules submodule.subname.path sm &&
1215 git config --add submodule.subname.ignore dirty &&
1216 git config --add submodule.subname.path sm &&
1217 git status >output &&
1218 test_cmp expect output &&
1219 git config --remove-section submodule.subname &&
1220 git config -f .gitmodules --remove-section submodule.subname
1223 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
1224 cat > expect << EOF &&
1225 On branch main
1226 Your branch and '\''upstream'\'' have diverged,
1227 and have 2 and 2 different commits each, respectively.
1228 (use "git pull" to merge the remote branch into yours)
1230 Changes to be committed:
1231 (use "git restore --staged <file>..." to unstage)
1232 modified: sm
1234 Changes not staged for commit:
1235 (use "git add <file>..." to update what will be committed)
1236 (use "git restore <file>..." to discard changes in working directory)
1237 (commit or discard the untracked or modified content in submodules)
1238 modified: dir1/modified
1239 modified: sm (modified content)
1241 Submodule changes to be committed:
1243 * sm $head...$new_head (1):
1244 > Add bar
1246 Untracked files:
1247 (use "git add <file>..." to include in what will be committed)
1248 .gitmodules
1249 dir1/untracked
1250 dir2/modified
1251 dir2/untracked
1252 untracked
1255 git status --ignore-submodules=untracked > output &&
1256 test_cmp expect output
1259 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
1260 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1261 git config --add -f .gitmodules submodule.subname.path sm &&
1262 git status >output &&
1263 test_cmp expect output &&
1264 git config -f .gitmodules --remove-section submodule.subname
1267 test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
1268 git config --add -f .gitmodules submodule.subname.ignore none &&
1269 git config --add -f .gitmodules submodule.subname.path sm &&
1270 git config --add submodule.subname.ignore untracked &&
1271 git config --add submodule.subname.path sm &&
1272 git status >output &&
1273 test_cmp expect output &&
1274 git config --remove-section submodule.subname &&
1275 git config -f .gitmodules --remove-section submodule.subname
1278 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
1280 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
1281 cat > expect << EOF &&
1282 On branch main
1283 Your branch and '\''upstream'\'' have diverged,
1284 and have 2 and 2 different commits each, respectively.
1285 (use "git pull" to merge the remote branch into yours)
1287 Changes to be committed:
1288 (use "git restore --staged <file>..." to unstage)
1289 modified: sm
1291 Changes not staged for commit:
1292 (use "git add <file>..." to update what will be committed)
1293 (use "git restore <file>..." to discard changes in working directory)
1294 modified: dir1/modified
1295 modified: sm (new commits)
1297 Submodule changes to be committed:
1299 * sm $head...$new_head (1):
1300 > Add bar
1302 Submodules changed but not updated:
1304 * sm $new_head...$head2 (1):
1305 > 2nd commit
1307 Untracked files:
1308 (use "git add <file>..." to include in what will be committed)
1309 .gitmodules
1310 dir1/untracked
1311 dir2/modified
1312 dir2/untracked
1313 untracked
1316 git status --ignore-submodules=untracked > output &&
1317 test_cmp expect output
1320 test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
1321 git config --add -f .gitmodules submodule.subname.ignore untracked &&
1322 git config --add -f .gitmodules submodule.subname.path sm &&
1323 git status >output &&
1324 test_cmp expect output &&
1325 git config -f .gitmodules --remove-section submodule.subname
1328 test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
1329 git config --add -f .gitmodules submodule.subname.ignore none &&
1330 git config --add -f .gitmodules submodule.subname.path sm &&
1331 git config --add submodule.subname.ignore untracked &&
1332 git config --add submodule.subname.path sm &&
1333 git status >output &&
1334 test_cmp expect output &&
1335 git config --remove-section submodule.subname &&
1336 git config -f .gitmodules --remove-section submodule.subname
1339 test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
1340 git status --ignore-submodules=dirty > output &&
1341 test_cmp expect output
1343 test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
1344 git config --add -f .gitmodules submodule.subname.ignore dirty &&
1345 git config --add -f .gitmodules submodule.subname.path sm &&
1346 git status >output &&
1347 test_cmp expect output &&
1348 git config -f .gitmodules --remove-section submodule.subname
1351 test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
1352 git config --add -f .gitmodules submodule.subname.ignore none &&
1353 git config --add -f .gitmodules submodule.subname.path sm &&
1354 git config --add submodule.subname.ignore dirty &&
1355 git config --add submodule.subname.path sm &&
1356 git status >output &&
1357 test_cmp expect output &&
1358 git config --remove-section submodule.subname &&
1359 git config -f .gitmodules --remove-section submodule.subname
1362 cat > expect << EOF
1363 ; On branch main
1364 ; Your branch and 'upstream' have diverged,
1365 ; and have 2 and 2 different commits each, respectively.
1366 ; (use "git pull" to merge the remote branch into yours)
1368 ; Changes to be committed:
1369 ; (use "git restore --staged <file>..." to unstage)
1370 ; modified: sm
1372 ; Changes not staged for commit:
1373 ; (use "git add <file>..." to update what will be committed)
1374 ; (use "git restore <file>..." to discard changes in working directory)
1375 ; modified: dir1/modified
1376 ; modified: sm (new commits)
1378 ; Submodule changes to be committed:
1380 ; * sm $head...$new_head (1):
1381 ; > Add bar
1383 ; Submodules changed but not updated:
1385 ; * sm $new_head...$head2 (1):
1386 ; > 2nd commit
1388 ; Untracked files:
1389 ; (use "git add <file>..." to include in what will be committed)
1390 ; .gitmodules
1391 ; dir1/untracked
1392 ; dir2/modified
1393 ; dir2/untracked
1394 ; untracked
1398 test_expect_success "status (core.commentchar with submodule summary)" '
1399 test_config core.commentchar ";" &&
1400 git -c status.displayCommentPrefix=true status >output &&
1401 test_cmp expect output
1404 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1405 test_config core.commentchar ";;" &&
1406 test_must_fail git -c status.displayCommentPrefix=true status
1409 test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1410 cat > expect << EOF &&
1411 On branch main
1412 Your branch and '\''upstream'\'' have diverged,
1413 and have 2 and 2 different commits each, respectively.
1414 (use "git pull" to merge the remote branch into yours)
1416 Changes not staged for commit:
1417 (use "git add <file>..." to update what will be committed)
1418 (use "git restore <file>..." to discard changes in working directory)
1419 modified: dir1/modified
1421 Untracked files:
1422 (use "git add <file>..." to include in what will be committed)
1423 .gitmodules
1424 dir1/untracked
1425 dir2/modified
1426 dir2/untracked
1427 untracked
1429 no changes added to commit (use "git add" and/or "git commit -a")
1431 git status --ignore-submodules=all > output &&
1432 test_cmp expect output
1435 test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
1436 cat > expect << EOF &&
1437 On branch main
1438 Your branch and '\''upstream'\'' have diverged,
1439 and have 2 and 2 different commits each, respectively.
1440 (use "git pull" to merge the remote branch into yours)
1442 Changes to be committed:
1443 (use "git restore --staged <file>..." to unstage)
1444 modified: sm
1446 Changes not staged for commit:
1447 (use "git add <file>..." to update what will be committed)
1448 (use "git restore <file>..." to discard changes in working directory)
1449 modified: dir1/modified
1451 Untracked files:
1452 (use "git add <file>..." to include in what will be committed)
1453 .gitmodules
1454 dir1/untracked
1455 dir2/modified
1456 dir2/untracked
1457 untracked
1460 git config --add -f .gitmodules submodule.subname.ignore all &&
1461 git config --add -f .gitmodules submodule.subname.path sm &&
1462 git status > output &&
1463 test_cmp expect output &&
1464 git config -f .gitmodules --remove-section submodule.subname
1467 test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
1468 git config --add -f .gitmodules submodule.subname.ignore none &&
1469 git config --add -f .gitmodules submodule.subname.path sm &&
1470 git config --add submodule.subname.ignore all &&
1471 git config --add submodule.subname.path sm &&
1472 git status > output &&
1473 test_cmp expect output &&
1474 git config --remove-section submodule.subname &&
1475 git config -f .gitmodules --remove-section submodule.subname
1478 test_expect_success 'setup of test environment' '
1479 git config status.showUntrackedFiles no &&
1480 git status -s >expected_short &&
1481 git status --no-short >expected_noshort
1484 test_expect_success '"status.short=true" same as "-s"' '
1485 git -c status.short=true status >actual &&
1486 test_cmp expected_short actual
1489 test_expect_success '"status.short=true" weaker than "--no-short"' '
1490 git -c status.short=true status --no-short >actual &&
1491 test_cmp expected_noshort actual
1494 test_expect_success '"status.short=false" same as "--no-short"' '
1495 git -c status.short=false status >actual &&
1496 test_cmp expected_noshort actual
1499 test_expect_success '"status.short=false" weaker than "-s"' '
1500 git -c status.short=false status -s >actual &&
1501 test_cmp expected_short actual
1504 test_expect_success '"status.branch=true" same as "-b"' '
1505 git status -sb >expected_branch &&
1506 git -c status.branch=true status -s >actual &&
1507 test_cmp expected_branch actual
1510 test_expect_success '"status.branch=true" different from "--no-branch"' '
1511 git status -s --no-branch >expected_nobranch &&
1512 git -c status.branch=true status -s >actual &&
1513 ! test_cmp expected_nobranch actual
1516 test_expect_success '"status.branch=true" weaker than "--no-branch"' '
1517 git -c status.branch=true status -s --no-branch >actual &&
1518 test_cmp expected_nobranch actual
1521 test_expect_success '"status.branch=true" weaker than "--porcelain"' '
1522 git -c status.branch=true status --porcelain >actual &&
1523 test_cmp expected_nobranch actual
1526 test_expect_success '"status.branch=false" same as "--no-branch"' '
1527 git -c status.branch=false status -s >actual &&
1528 test_cmp expected_nobranch actual
1531 test_expect_success '"status.branch=false" weaker than "-b"' '
1532 git -c status.branch=false status -sb >actual &&
1533 test_cmp expected_branch actual
1536 test_expect_success 'Restore default test environment' '
1537 git config --unset status.showUntrackedFiles
1540 test_expect_success 'git commit will commit a staged but ignored submodule' '
1541 git config --add -f .gitmodules submodule.subname.ignore all &&
1542 git config --add -f .gitmodules submodule.subname.path sm &&
1543 git config --add submodule.subname.ignore all &&
1544 git status -s --ignore-submodules=dirty >output &&
1545 test_i18ngrep "^M. sm" output &&
1546 GIT_EDITOR="echo hello >>\"\$1\"" &&
1547 export GIT_EDITOR &&
1548 git commit -uno &&
1549 git status -s --ignore-submodules=dirty >output &&
1550 test_i18ngrep ! "^M. sm" output
1553 test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
1554 git reset HEAD^ &&
1555 git add sm &&
1556 cat >expect << EOF &&
1557 On branch main
1558 Your branch and '\''upstream'\'' have diverged,
1559 and have 2 and 2 different commits each, respectively.
1560 (use "git pull" to merge the remote branch into yours)
1562 Changes to be committed:
1563 (use "git restore --staged <file>..." to unstage)
1564 modified: sm
1566 Changes not staged for commit:
1567 (use "git add <file>..." to update what will be committed)
1568 (use "git restore <file>..." to discard changes in working directory)
1569 modified: dir1/modified
1571 Untracked files not listed (use -u option to show untracked files)
1573 git commit -uno --dry-run >output &&
1574 test_cmp expect output &&
1575 git status -s --ignore-submodules=dirty >output &&
1576 test_i18ngrep "^M. sm" output
1579 test_expect_success 'git commit -m will commit a staged but ignored submodule' '
1580 git commit -uno -m message &&
1581 git status -s --ignore-submodules=dirty >output &&
1582 test_i18ngrep ! "^M. sm" output &&
1583 git config --remove-section submodule.subname &&
1584 git config -f .gitmodules --remove-section submodule.subname
1587 test_expect_success 'show stash info with "--show-stash"' '
1588 git reset --hard &&
1589 git stash clear &&
1590 echo 1 >file &&
1591 git add file &&
1592 git stash &&
1593 git status >expected_default &&
1594 git status --show-stash >expected_with_stash &&
1595 test_i18ngrep "^Your stash currently has 1 entry$" expected_with_stash
1598 test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
1599 git status --show-stash --no-show-stash >expected_without_stash &&
1600 test_cmp expected_default expected_without_stash
1603 test_expect_success '"status.showStash=false" weaker than "--show-stash"' '
1604 git -c status.showStash=false status --show-stash >actual &&
1605 test_cmp expected_with_stash actual
1608 test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' '
1609 git -c status.showStash=true status --no-show-stash >actual &&
1610 test_cmp expected_without_stash actual
1613 test_expect_success 'no additional info if no stash entries' '
1614 git stash clear &&
1615 git -c status.showStash=true status >actual &&
1616 test_cmp expected_without_stash actual
1619 test_expect_success '"No commits yet" should be noted in status output' '
1620 git checkout --orphan empty-branch-1 &&
1621 git status >output &&
1622 test_i18ngrep "No commits yet" output
1625 test_expect_success '"No commits yet" should not be noted in status output' '
1626 git checkout --orphan empty-branch-2 &&
1627 test_commit test-commit-1 &&
1628 git status >output &&
1629 test_i18ngrep ! "No commits yet" output
1632 test_expect_success '"Initial commit" should be noted in commit template' '
1633 git checkout --orphan empty-branch-3 &&
1634 touch to_be_committed_1 &&
1635 git add to_be_committed_1 &&
1636 git commit --dry-run >output &&
1637 test_i18ngrep "Initial commit" output
1640 test_expect_success '"Initial commit" should not be noted in commit template' '
1641 git checkout --orphan empty-branch-4 &&
1642 test_commit test-commit-2 &&
1643 touch to_be_committed_2 &&
1644 git add to_be_committed_2 &&
1645 git commit --dry-run >output &&
1646 test_i18ngrep ! "Initial commit" output
1649 test_expect_success '--no-optional-locks prevents index update' '
1650 test_set_magic_mtime .git/index &&
1651 git --no-optional-locks status &&
1652 test_is_magic_mtime .git/index &&
1653 git status &&
1654 ! test_is_magic_mtime .git/index
1657 test_expect_success 'racy timestamps will be fixed for clean worktree' '
1658 echo content >racy-dirty &&
1659 echo content >racy-racy &&
1660 git add racy* &&
1661 git commit -m "racy test files" &&
1662 # let status rewrite the index, if necessary; after that we expect
1663 # no more index writes unless caused by racy timestamps; note that
1664 # timestamps may already be racy now (depending on previous tests)
1665 git status &&
1666 test_set_magic_mtime .git/index &&
1667 git status &&
1668 ! test_is_magic_mtime .git/index
1671 test_expect_success 'racy timestamps will be fixed for dirty worktree' '
1672 echo content2 >racy-dirty &&
1673 git status &&
1674 test_set_magic_mtime .git/index &&
1675 git status &&
1676 ! test_is_magic_mtime .git/index
1679 test_expect_success 'setup slow status advice' '
1680 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main git init slowstatus &&
1682 cd slowstatus &&
1683 cat >.gitignore <<-\EOF &&
1684 /actual
1685 /expected
1686 /out
1688 git add .gitignore &&
1689 git commit -m "Add .gitignore" &&
1690 git config advice.statusuoption true
1694 test_expect_success 'slow status advice when core.untrackedCache and fsmonitor are unset' '
1696 cd slowstatus &&
1697 git config core.untrackedCache false &&
1698 git config core.fsmonitor false &&
1699 GIT_TEST_UF_DELAY_WARNING=1 git status >actual &&
1700 cat >expected <<-\EOF &&
1701 On branch main
1703 It took 3.25 seconds to enumerate untracked files.
1704 See '\''git help status'\'' for information on how to improve this.
1706 nothing to commit, working tree clean
1708 test_cmp expected actual
1712 test_expect_success 'slow status advice when core.untrackedCache true, but not fsmonitor' '
1714 cd slowstatus &&
1715 git config core.untrackedCache true &&
1716 git config core.fsmonitor false &&
1717 GIT_TEST_UF_DELAY_WARNING=1 git status >actual &&
1718 cat >expected <<-\EOF &&
1719 On branch main
1721 It took 3.25 seconds to enumerate untracked files.
1722 See '\''git help status'\'' for information on how to improve this.
1724 nothing to commit, working tree clean
1726 test_cmp expected actual
1730 test_expect_success 'slow status advice when core.untrackedCache true, and fsmonitor' '
1732 cd slowstatus &&
1733 git config core.untrackedCache true &&
1734 git config core.fsmonitor true &&
1735 GIT_TEST_UF_DELAY_WARNING=1 git status >actual &&
1736 cat >expected <<-\EOF &&
1737 On branch main
1739 It took 3.25 seconds to enumerate untracked files,
1740 but the results were cached, and subsequent runs may be faster.
1741 See '\''git help status'\'' for information on how to improve this.
1743 nothing to commit, working tree clean
1745 test_cmp expected actual
1749 test_done