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
91 # Changes to be committed:
92 # (use "git reset HEAD <file>..." to unstage)
94 # new file: dir2/added
96 # Changed but not updated:
97 # (use "git add <file>..." to update what will be committed)
98 # (use "git checkout -- <file>..." to discard changes in working directory)
100 # modified: dir1/modified
102 # Untracked files not listed (use -u option to show untracked files)
104 test_expect_success 'status -uno' '
106 : >dir3/untracked1 &&
107 : >dir3/untracked2 &&
108 git status -uno >output &&
109 test_cmp expect output
112 test_expect_success 'status (status.showUntrackedFiles no)' '
113 git config status.showuntrackedfiles no
114 git status >output &&
115 test_cmp expect output
122 test_expect_success 'status -s -uno' '
123 git config --unset status.showuntrackedfiles
124 git status -s -uno >output &&
125 test_cmp expect output
128 test_expect_success 'status -s (status.showUntrackedFiles no)' '
129 git config status.showuntrackedfiles no
130 git status -s >output &&
131 test_cmp expect output
136 # Changes to be committed:
137 # (use "git reset HEAD <file>..." to unstage)
139 # new file: dir2/added
141 # Changed but not updated:
142 # (use "git add <file>..." to update what will be committed)
143 # (use "git checkout -- <file>..." to discard changes in working directory)
145 # modified: dir1/modified
148 # (use "git add <file>..." to include in what will be committed)
158 test_expect_success 'status -unormal' '
159 git status -unormal >output &&
160 test_cmp expect output
163 test_expect_success 'status (status.showUntrackedFiles normal)' '
164 git config status.showuntrackedfiles normal
165 git status >output &&
166 test_cmp expect output
180 test_expect_success 'status -s -unormal' '
181 git config --unset status.showuntrackedfiles
182 git status -s -unormal >output &&
183 test_cmp expect output
186 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
187 git config status.showuntrackedfiles normal
188 git status -s >output &&
189 test_cmp expect output
194 # Changes to be committed:
195 # (use "git reset HEAD <file>..." to unstage)
197 # new file: dir2/added
199 # Changed but not updated:
200 # (use "git add <file>..." to update what will be committed)
201 # (use "git checkout -- <file>..." to discard changes in working directory)
203 # modified: dir1/modified
206 # (use "git add <file>..." to include in what will be committed)
217 test_expect_success 'status -uall' '
218 git status -uall >output &&
219 test_cmp expect output
221 test_expect_success 'status (status.showUntrackedFiles all)' '
222 git config status.showuntrackedfiles all
223 git status >output &&
225 git config --unset status.showuntrackedfiles &&
226 test_cmp expect output
239 test_expect_success 'status -s -uall' '
240 git config --unset status.showuntrackedfiles
241 git status -s -uall >output &&
242 test_cmp expect output
244 test_expect_success 'status -s (status.showUntrackedFiles all)' '
245 git config status.showuntrackedfiles all
246 git status -s >output &&
248 git config --unset status.showuntrackedfiles &&
249 test_cmp expect output
254 # Changes to be committed:
255 # (use "git reset HEAD <file>..." to unstage)
257 # new file: ../dir2/added
259 # Changed but not updated:
260 # (use "git add <file>..." to update what will be committed)
261 # (use "git checkout -- <file>..." to discard changes in working directory)
266 # (use "git add <file>..." to include in what will be committed)
276 test_expect_success 'status with relative paths' '
278 (cd dir1 && git status) >output &&
279 test_cmp expect output
293 test_expect_success 'status -s with relative paths' '
295 (cd dir1 && git status -s) >output &&
296 test_cmp expect output
311 test_expect_success 'status --porcelain ignores relative paths setting' '
313 (cd dir1 && git status --porcelain) >output &&
314 test_cmp expect output
318 test_expect_success 'setup unique colors' '
320 git config status.color.untracked blue
326 # Changes to be committed:
327 # (use "git reset HEAD <file>..." to unstage)
329 # <GREEN>new file: dir2/added<RESET>
331 # Changed but not updated:
332 # (use "git add <file>..." to update what will be committed)
333 # (use "git checkout -- <file>..." to discard changes in working directory)
335 # <RED>modified: dir1/modified<RESET>
338 # (use "git add <file>..." to include in what will be committed)
340 # <BLUE>dir1/untracked<RESET>
341 # <BLUE>dir2/modified<RESET>
342 # <BLUE>dir2/untracked<RESET>
343 # <BLUE>expect<RESET>
344 # <BLUE>output<RESET>
345 # <BLUE>untracked<RESET>
348 test_expect_success 'status with color.ui' '
350 git config color.ui always &&
351 git status | test_decode_color >output &&
352 test_cmp expect output
356 test_expect_success 'status with color.status' '
358 git config --unset color.ui &&
359 git config color.status always &&
360 git status | test_decode_color >output &&
361 test_cmp expect output
366 <RED>M<RESET> dir1/modified
367 <GREEN>A<RESET> dir2/added
368 <BLUE>??<RESET> dir1/untracked
369 <BLUE>??<RESET> dir2/modified
370 <BLUE>??<RESET> dir2/untracked
371 <BLUE>??<RESET> expect
372 <BLUE>??<RESET> output
373 <BLUE>??<RESET> untracked
376 test_expect_success 'status -s with color.ui' '
378 git config --unset color.status &&
379 git config color.ui always &&
380 git status -s | test_decode_color >output &&
381 test_cmp expect output
385 test_expect_success 'status -s with color.status' '
387 git config --unset color.ui &&
388 git config color.status always &&
389 git status -s | test_decode_color >output &&
390 test_cmp expect output
405 test_expect_success 'status --porcelain ignores color.ui' '
407 git config --unset color.status &&
408 git config color.ui always &&
409 git status --porcelain | test_decode_color >output &&
410 test_cmp expect output
414 test_expect_success 'status --porcelain ignores color.status' '
416 git config --unset color.ui &&
417 git config color.status always &&
418 git status --porcelain | test_decode_color >output &&
419 test_cmp expect output
423 # recover unconditionally from color tests
424 git config --unset color.status
425 git config --unset color.ui
429 # Changes to be committed:
430 # (use "git reset HEAD <file>..." to unstage)
432 # new file: dir2/added
434 # Changed but not updated:
435 # (use "git add <file>..." to update what will be committed)
436 # (use "git checkout -- <file>..." to discard changes in working directory)
438 # modified: dir1/modified
441 # (use "git add <file>..." to include in what will be committed)
452 test_expect_success 'status without relative paths' '
454 git config status.relativePaths false
455 (cd dir1 && git status) >output &&
456 test_cmp expect output
471 test_expect_success 'status -s without relative paths' '
473 (cd dir1 && git status -s) >output &&
474 test_cmp expect output
480 # Changes to be committed:
481 # (use "git reset HEAD <file>..." to unstage)
483 # modified: dir1/modified
486 # (use "git add <file>..." to include in what will be committed)
494 test_expect_success 'dry-run of partial commit excluding new file in index' '
495 git commit --dry-run dir1/modified >output &&
496 test_cmp expect output
499 test_expect_success 'setup status submodule summary' '
500 test_create_repo sm && (
504 git commit -m "Add foo"
511 # Changes to be committed:
512 # (use "git reset HEAD <file>..." to unstage)
514 # new file: dir2/added
517 # Changed but not updated:
518 # (use "git add <file>..." to update what will be committed)
519 # (use "git checkout -- <file>..." to discard changes in working directory)
521 # modified: dir1/modified
524 # (use "git add <file>..." to include in what will be committed)
533 test_expect_success 'status submodule summary is disabled by default' '
534 git status >output &&
535 test_cmp expect output
538 # we expect the same as the previous test
539 test_expect_success 'status --untracked-files=all does not show submodule' '
540 git status --untracked-files=all >output &&
541 test_cmp expect output
555 test_expect_success 'status -s submodule summary is disabled by default' '
556 git status -s >output &&
557 test_cmp expect output
560 # we expect the same as the previous test
561 test_expect_success 'status -s --untracked-files=all does not show submodule' '
562 git status -s --untracked-files=all >output &&
563 test_cmp expect output
566 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
570 # Changes to be committed:
571 # (use "git reset HEAD <file>..." to unstage)
573 # new file: dir2/added
576 # Changed but not updated:
577 # (use "git add <file>..." to update what will be committed)
578 # (use "git checkout -- <file>..." to discard changes in working directory)
580 # modified: dir1/modified
582 # Submodule changes to be committed:
584 # * sm 0000000...$head (1):
588 # (use "git add <file>..." to include in what will be committed)
597 test_expect_success 'status submodule summary' '
598 git config status.submodulesummary 10 &&
599 git status >output &&
600 test_cmp expect output
614 test_expect_success 'status -s submodule summary' '
615 git status -s >output &&
616 test_cmp expect output
621 # Changed but not updated:
622 # (use "git add <file>..." to update what will be committed)
623 # (use "git checkout -- <file>..." to discard changes in working directory)
625 # modified: dir1/modified
628 # (use "git add <file>..." to include in what will be committed)
636 no changes added to commit (use "git add" and/or "git commit -a")
638 test_expect_success 'status submodule summary (clean submodule)' '
639 git commit -m "commit submodule" &&
640 git config status.submodulesummary 10 &&
641 test_must_fail git commit --dry-run >output &&
642 test_cmp expect output &&
643 git status >output &&
644 test_cmp expect output
656 test_expect_success 'status -s submodule summary (clean submodule)' '
657 git status -s >output &&
658 test_cmp expect output
663 # Changes to be committed:
664 # (use "git reset HEAD^1 <file>..." to unstage)
666 # new file: dir2/added
669 # Changed but not updated:
670 # (use "git add <file>..." to update what will be committed)
671 # (use "git checkout -- <file>..." to discard changes in working directory)
673 # modified: dir1/modified
675 # Submodule changes to be committed:
677 # * sm 0000000...$head (1):
681 # (use "git add <file>..." to include in what will be committed)
690 test_expect_success 'commit --dry-run submodule summary (--amend)' '
691 git config status.submodulesummary 10 &&
692 git commit --dry-run --amend >output &&
693 test_cmp expect output