3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
10 test_expect_success 'setup' '
24 git commit -m initial &&
28 echo 1 >dir1/modified &&
29 echo 2 >dir2/modified &&
34 test_expect_success 'status (1)' '
36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
42 # Changes to be committed:
43 # (use "git reset HEAD <file>..." to unstage)
45 # new file: dir2/added
47 # Changed but not updated:
48 # (use "git add <file>..." to update what will be committed)
49 # (use "git checkout -- <file>..." to discard changes in working directory)
51 # modified: dir1/modified
54 # (use "git add <file>..." to include in what will be committed)
64 test_expect_success 'status (2)' '
67 test_cmp expect output
82 test_expect_success 'status -s (2)' '
84 git status -s >output &&
85 test_cmp expect output
89 test_expect_success 'status with gitignore' '
97 cat >expect <<-\EOF &&
102 git status -s >output &&
103 test_cmp expect output &&
105 cat >expect <<-\EOF &&
116 git status -s --ignored >output &&
117 test_cmp expect output &&
119 cat >expect <<-\EOF &&
121 # Changes to be committed:
122 # (use "git reset HEAD <file>..." to unstage)
124 # new file: dir2/added
126 # Changed but not updated:
127 # (use "git add <file>..." to update what will be committed)
128 # (use "git checkout -- <file>..." to discard changes in working directory)
130 # modified: dir1/modified
133 # (use "git add <file>..." to include in what will be committed)
137 # (use "git add -f <file>..." to include in what will be committed)
146 git status --ignored >output &&
147 test_cmp expect output
150 test_expect_success 'status with gitignore (nothing untracked)' '
154 echo "dir2/modified" &&
159 cat >expect <<-\EOF &&
163 git status -s >output &&
164 test_cmp expect output &&
166 cat >expect <<-\EOF &&
177 git status -s --ignored >output &&
178 test_cmp expect output &&
180 cat >expect <<-\EOF &&
182 # Changes to be committed:
183 # (use "git reset HEAD <file>..." to unstage)
185 # new file: dir2/added
187 # Changed but not updated:
188 # (use "git add <file>..." to update what will be committed)
189 # (use "git checkout -- <file>..." to discard changes in working directory)
191 # modified: dir1/modified
194 # (use "git add -f <file>..." to include in what will be committed)
204 git status --ignored >output &&
205 test_cmp expect output
212 # Changes to be committed:
213 # (use "git reset HEAD <file>..." to unstage)
215 # new file: dir2/added
217 # Changed but not updated:
218 # (use "git add <file>..." to update what will be committed)
219 # (use "git checkout -- <file>..." to discard changes in working directory)
221 # modified: dir1/modified
223 # Untracked files not listed (use -u option to show untracked files)
225 test_expect_success 'status -uno' '
227 : >dir3/untracked1 &&
228 : >dir3/untracked2 &&
229 git status -uno >output &&
230 test_cmp expect output
233 test_expect_success 'status (status.showUntrackedFiles no)' '
234 git config status.showuntrackedfiles no
235 git status >output &&
236 test_cmp expect output
243 test_expect_success 'status -s -uno' '
244 git config --unset status.showuntrackedfiles
245 git status -s -uno >output &&
246 test_cmp expect output
249 test_expect_success 'status -s (status.showUntrackedFiles no)' '
250 git config status.showuntrackedfiles no
251 git status -s >output &&
252 test_cmp expect output
257 # Changes to be committed:
258 # (use "git reset HEAD <file>..." to unstage)
260 # new file: dir2/added
262 # Changed but not updated:
263 # (use "git add <file>..." to update what will be committed)
264 # (use "git checkout -- <file>..." to discard changes in working directory)
266 # modified: dir1/modified
269 # (use "git add <file>..." to include in what will be committed)
279 test_expect_success 'status -unormal' '
280 git status -unormal >output &&
281 test_cmp expect output
284 test_expect_success 'status (status.showUntrackedFiles normal)' '
285 git config status.showuntrackedfiles normal
286 git status >output &&
287 test_cmp expect output
301 test_expect_success 'status -s -unormal' '
302 git config --unset status.showuntrackedfiles
303 git status -s -unormal >output &&
304 test_cmp expect output
307 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
308 git config status.showuntrackedfiles normal
309 git status -s >output &&
310 test_cmp expect output
315 # Changes to be committed:
316 # (use "git reset HEAD <file>..." to unstage)
318 # new file: dir2/added
320 # Changed but not updated:
321 # (use "git add <file>..." to update what will be committed)
322 # (use "git checkout -- <file>..." to discard changes in working directory)
324 # modified: dir1/modified
327 # (use "git add <file>..." to include in what will be committed)
338 test_expect_success 'status -uall' '
339 git status -uall >output &&
340 test_cmp expect output
342 test_expect_success 'status (status.showUntrackedFiles all)' '
343 git config status.showuntrackedfiles all
344 git status >output &&
346 git config --unset status.showuntrackedfiles &&
347 test_cmp expect output
360 test_expect_success 'status -s -uall' '
361 git config --unset status.showuntrackedfiles
362 git status -s -uall >output &&
363 test_cmp expect output
365 test_expect_success 'status -s (status.showUntrackedFiles all)' '
366 git config status.showuntrackedfiles all
367 git status -s >output &&
369 git config --unset status.showuntrackedfiles &&
370 test_cmp expect output
375 # Changes to be committed:
376 # (use "git reset HEAD <file>..." to unstage)
378 # new file: ../dir2/added
380 # Changed but not updated:
381 # (use "git add <file>..." to update what will be committed)
382 # (use "git checkout -- <file>..." to discard changes in working directory)
387 # (use "git add <file>..." to include in what will be committed)
397 test_expect_success 'status with relative paths' '
399 (cd dir1 && git status) >output &&
400 test_cmp expect output
414 test_expect_success 'status -s with relative paths' '
416 (cd dir1 && git status -s) >output &&
417 test_cmp expect output
432 test_expect_success 'status --porcelain ignores relative paths setting' '
434 (cd dir1 && git status --porcelain) >output &&
435 test_cmp expect output
439 test_expect_success 'setup unique colors' '
441 git config status.color.untracked blue
447 # Changes to be committed:
448 # (use "git reset HEAD <file>..." to unstage)
450 # <GREEN>new file: dir2/added<RESET>
452 # Changed but not updated:
453 # (use "git add <file>..." to update what will be committed)
454 # (use "git checkout -- <file>..." to discard changes in working directory)
456 # <RED>modified: dir1/modified<RESET>
459 # (use "git add <file>..." to include in what will be committed)
461 # <BLUE>dir1/untracked<RESET>
462 # <BLUE>dir2/modified<RESET>
463 # <BLUE>dir2/untracked<RESET>
464 # <BLUE>expect<RESET>
465 # <BLUE>output<RESET>
466 # <BLUE>untracked<RESET>
469 test_expect_success 'status with color.ui' '
471 git config color.ui always &&
472 git status | test_decode_color >output &&
473 test_cmp expect output
477 test_expect_success 'status with color.status' '
479 git config --unset color.ui &&
480 git config color.status always &&
481 git status | test_decode_color >output &&
482 test_cmp expect output
487 <RED>M<RESET> dir1/modified
488 <GREEN>A<RESET> dir2/added
489 <BLUE>??<RESET> dir1/untracked
490 <BLUE>??<RESET> dir2/modified
491 <BLUE>??<RESET> dir2/untracked
492 <BLUE>??<RESET> expect
493 <BLUE>??<RESET> output
494 <BLUE>??<RESET> untracked
497 test_expect_success 'status -s with color.ui' '
499 git config --unset color.status &&
500 git config color.ui always &&
501 git status -s | test_decode_color >output &&
502 test_cmp expect output
506 test_expect_success 'status -s with color.status' '
508 git config --unset color.ui &&
509 git config color.status always &&
510 git status -s | test_decode_color >output &&
511 test_cmp expect output
526 test_expect_success 'status --porcelain ignores color.ui' '
528 git config --unset color.status &&
529 git config color.ui always &&
530 git status --porcelain | test_decode_color >output &&
531 test_cmp expect output
535 test_expect_success 'status --porcelain ignores color.status' '
537 git config --unset color.ui &&
538 git config color.status always &&
539 git status --porcelain | test_decode_color >output &&
540 test_cmp expect output
544 # recover unconditionally from color tests
545 git config --unset color.status
546 git config --unset color.ui
550 # Changes to be committed:
551 # (use "git reset HEAD <file>..." to unstage)
553 # new file: dir2/added
555 # Changed but not updated:
556 # (use "git add <file>..." to update what will be committed)
557 # (use "git checkout -- <file>..." to discard changes in working directory)
559 # modified: dir1/modified
562 # (use "git add <file>..." to include in what will be committed)
573 test_expect_success 'status without relative paths' '
575 git config status.relativePaths false
576 (cd dir1 && git status) >output &&
577 test_cmp expect output
592 test_expect_success 'status -s without relative paths' '
594 (cd dir1 && git status -s) >output &&
595 test_cmp expect output
601 # Changes to be committed:
602 # (use "git reset HEAD <file>..." to unstage)
604 # modified: dir1/modified
607 # (use "git add <file>..." to include in what will be committed)
615 test_expect_success 'dry-run of partial commit excluding new file in index' '
616 git commit --dry-run dir1/modified >output &&
617 test_cmp expect output
620 test_expect_success 'setup status submodule summary' '
621 test_create_repo sm && (
625 git commit -m "Add foo"
632 # Changes to be committed:
633 # (use "git reset HEAD <file>..." to unstage)
635 # new file: dir2/added
638 # Changed but not updated:
639 # (use "git add <file>..." to update what will be committed)
640 # (use "git checkout -- <file>..." to discard changes in working directory)
642 # modified: dir1/modified
645 # (use "git add <file>..." to include in what will be committed)
654 test_expect_success 'status submodule summary is disabled by default' '
655 git status >output &&
656 test_cmp expect output
659 # we expect the same as the previous test
660 test_expect_success 'status --untracked-files=all does not show submodule' '
661 git status --untracked-files=all >output &&
662 test_cmp expect output
676 test_expect_success 'status -s submodule summary is disabled by default' '
677 git status -s >output &&
678 test_cmp expect output
681 # we expect the same as the previous test
682 test_expect_success 'status -s --untracked-files=all does not show submodule' '
683 git status -s --untracked-files=all >output &&
684 test_cmp expect output
687 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
691 # Changes to be committed:
692 # (use "git reset HEAD <file>..." to unstage)
694 # new file: dir2/added
697 # Changed but not updated:
698 # (use "git add <file>..." to update what will be committed)
699 # (use "git checkout -- <file>..." to discard changes in working directory)
701 # modified: dir1/modified
703 # Submodule changes to be committed:
705 # * sm 0000000...$head (1):
709 # (use "git add <file>..." to include in what will be committed)
718 test_expect_success 'status submodule summary' '
719 git config status.submodulesummary 10 &&
720 git status >output &&
721 test_cmp expect output
735 test_expect_success 'status -s submodule summary' '
736 git status -s >output &&
737 test_cmp expect output
742 # Changed but not updated:
743 # (use "git add <file>..." to update what will be committed)
744 # (use "git checkout -- <file>..." to discard changes in working directory)
746 # modified: dir1/modified
749 # (use "git add <file>..." to include in what will be committed)
757 no changes added to commit (use "git add" and/or "git commit -a")
759 test_expect_success 'status submodule summary (clean submodule)' '
760 git commit -m "commit submodule" &&
761 git config status.submodulesummary 10 &&
762 test_must_fail git commit --dry-run >output &&
763 test_cmp expect output &&
764 git status >output &&
765 test_cmp expect output
777 test_expect_success 'status -s submodule summary (clean submodule)' '
778 git status -s >output &&
779 test_cmp expect output
784 # Changes to be committed:
785 # (use "git reset HEAD^1 <file>..." to unstage)
787 # new file: dir2/added
790 # Changed but not updated:
791 # (use "git add <file>..." to update what will be committed)
792 # (use "git checkout -- <file>..." to discard changes in working directory)
794 # modified: dir1/modified
796 # Submodule changes to be committed:
798 # * sm 0000000...$head (1):
802 # (use "git add <file>..." to include in what will be committed)
811 test_expect_success 'commit --dry-run submodule summary (--amend)' '
812 git config status.submodulesummary 10 &&
813 git commit --dry-run --amend >output &&
814 test_cmp expect output