3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git status'
9 *MINGW
*) GIT_TEST_CMP
="diff -uw";;
14 test_expect_success
'setup' '
28 git commit -m initial &&
32 echo 1 >dir1/modified &&
33 echo 2 >dir2/modified &&
38 test_expect_success
'status (1)' '
40 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
46 # Changes to be committed:
47 # (use "git reset HEAD <file>..." to unstage)
49 # new file: dir2/added
51 # Changed but not updated:
52 # (use "git add <file>..." to update what will be committed)
53 # (use "git checkout -- <file>..." to discard changes in working directory)
55 # modified: dir1/modified
58 # (use "git add <file>..." to include in what will be committed)
68 test_expect_success
'status (2)' '
71 test_cmp expect output
86 test_expect_success
'status -s (2)' '
88 git status -s >output &&
89 test_cmp expect output
95 # Changes to be committed:
96 # (use "git reset HEAD <file>..." to unstage)
98 # new file: dir2/added
100 # Changed but not updated:
101 # (use "git add <file>..." to update what will be committed)
102 # (use "git checkout -- <file>..." to discard changes in working directory)
104 # modified: dir1/modified
106 # Untracked files not listed (use -u option to show untracked files)
108 test_expect_success
'status -uno' '
110 : >dir3/untracked1 &&
111 : >dir3/untracked2 &&
112 git status -uno >output &&
113 test_cmp expect output
116 test_expect_success
'status (status.showUntrackedFiles no)' '
117 git config status.showuntrackedfiles no
118 git status >output &&
119 test_cmp expect output
126 test_expect_success
'status -s -uno' '
127 git config --unset status.showuntrackedfiles
128 git status -s -uno >output &&
129 test_cmp expect output
132 test_expect_success
'status -s (status.showUntrackedFiles no)' '
133 git config status.showuntrackedfiles no
134 git status -s >output &&
135 test_cmp expect output
140 # Changes to be committed:
141 # (use "git reset HEAD <file>..." to unstage)
143 # new file: dir2/added
145 # Changed but not updated:
146 # (use "git add <file>..." to update what will be committed)
147 # (use "git checkout -- <file>..." to discard changes in working directory)
149 # modified: dir1/modified
152 # (use "git add <file>..." to include in what will be committed)
162 test_expect_success
'status -unormal' '
163 git status -unormal >output &&
164 test_cmp expect output
167 test_expect_success
'status (status.showUntrackedFiles normal)' '
168 git config status.showuntrackedfiles normal
169 git status >output &&
170 test_cmp expect output
184 test_expect_success
'status -s -unormal' '
185 git config --unset status.showuntrackedfiles
186 git status -s -unormal >output &&
187 test_cmp expect output
190 test_expect_success
'status -s (status.showUntrackedFiles normal)' '
191 git config status.showuntrackedfiles normal
192 git status -s >output &&
193 test_cmp expect output
198 # Changes to be committed:
199 # (use "git reset HEAD <file>..." to unstage)
201 # new file: dir2/added
203 # Changed but not updated:
204 # (use "git add <file>..." to update what will be committed)
205 # (use "git checkout -- <file>..." to discard changes in working directory)
207 # modified: dir1/modified
210 # (use "git add <file>..." to include in what will be committed)
221 test_expect_success
'status -uall' '
222 git status -uall >output &&
223 test_cmp expect output
225 test_expect_success
'status (status.showUntrackedFiles all)' '
226 git config status.showuntrackedfiles all
227 git status >output &&
229 git config --unset status.showuntrackedfiles &&
230 test_cmp expect output
243 test_expect_success
'status -s -uall' '
244 git config --unset status.showuntrackedfiles
245 git status -s -uall >output &&
246 test_cmp expect output
248 test_expect_success
'status -s (status.showUntrackedFiles all)' '
249 git config status.showuntrackedfiles all
250 git status -s >output &&
252 git config --unset status.showuntrackedfiles &&
253 test_cmp expect output
258 # Changes to be committed:
259 # (use "git reset HEAD <file>..." to unstage)
261 # new file: ../dir2/added
263 # Changed but not updated:
264 # (use "git add <file>..." to update what will be committed)
265 # (use "git checkout -- <file>..." to discard changes in working directory)
270 # (use "git add <file>..." to include in what will be committed)
280 test_expect_success
'status with relative paths' '
282 (cd dir1 && git status) >output &&
283 test_cmp expect output
297 test_expect_success
'status -s with relative paths' '
299 (cd dir1 && git status -s) >output &&
300 test_cmp expect output
315 test_expect_success
'status --porcelain ignores relative paths setting' '
317 (cd dir1 && git status --porcelain) >output &&
318 test_cmp expect output
322 test_expect_success
'setup unique colors' '
324 git config status.color.untracked blue
330 # Changes to be committed:
331 # (use "git reset HEAD <file>..." to unstage)
333 # <GREEN>new file: dir2/added<RESET>
335 # Changed but not updated:
336 # (use "git add <file>..." to update what will be committed)
337 # (use "git checkout -- <file>..." to discard changes in working directory)
339 # <RED>modified: dir1/modified<RESET>
342 # (use "git add <file>..." to include in what will be committed)
344 # <BLUE>dir1/untracked<RESET>
345 # <BLUE>dir2/modified<RESET>
346 # <BLUE>dir2/untracked<RESET>
347 # <BLUE>expect<RESET>
348 # <BLUE>output<RESET>
349 # <BLUE>untracked<RESET>
352 test_expect_success
'status with color.ui' '
354 git config color.ui always &&
355 git status | test_decode_color >output &&
356 test_cmp expect output
360 test_expect_success
'status with color.status' '
362 git config --unset color.ui &&
363 git config color.status always &&
364 git status | test_decode_color >output &&
365 test_cmp expect output
370 <RED
>M
<RESET
> dir
1/modified
371 <GREEN
>A
<RESET
> dir
2/added
372 <BLUE
>??
<RESET
> dir
1/untracked
373 <BLUE
>??
<RESET
> dir
2/modified
374 <BLUE
>??
<RESET
> dir
2/untracked
375 <BLUE
>??
<RESET
> expect
376 <BLUE
>??
<RESET
> output
377 <BLUE
>??
<RESET
> untracked
380 test_expect_success
'status -s with color.ui' '
382 git config --unset color.status &&
383 git config color.ui always &&
384 git status -s | test_decode_color >output &&
385 test_cmp expect output
389 test_expect_success
'status -s with color.status' '
391 git config --unset color.ui &&
392 git config color.status always &&
393 git status -s | test_decode_color >output &&
394 test_cmp expect output
409 test_expect_success
'status --porcelain ignores color.ui' '
411 git config --unset color.status &&
412 git config color.ui always &&
413 git status --porcelain | test_decode_color >output &&
414 test_cmp expect output
418 test_expect_success
'status --porcelain ignores color.status' '
420 git config --unset color.ui &&
421 git config color.status always &&
422 git status --porcelain | test_decode_color >output &&
423 test_cmp expect output
427 # recover unconditionally from color tests
428 git config
--unset color.status
429 git config
--unset color.ui
433 # Changes to be committed:
434 # (use "git reset HEAD <file>..." to unstage)
436 # new file: dir2/added
438 # Changed but not updated:
439 # (use "git add <file>..." to update what will be committed)
440 # (use "git checkout -- <file>..." to discard changes in working directory)
442 # modified: dir1/modified
445 # (use "git add <file>..." to include in what will be committed)
456 test_expect_success
'status without relative paths' '
458 git config status.relativePaths false
459 (cd dir1 && git status) >output &&
460 test_cmp expect output
475 test_expect_success
'status -s without relative paths' '
477 (cd dir1 && git status -s) >output &&
478 test_cmp expect output
484 # Changes to be committed:
485 # (use "git reset HEAD <file>..." to unstage)
487 # modified: dir1/modified
490 # (use "git add <file>..." to include in what will be committed)
498 test_expect_success
'dry-run of partial commit excluding new file in index' '
499 git commit --dry-run dir1/modified >output &&
500 test_cmp expect output
503 test_expect_success
'setup status submodule summary' '
504 test_create_repo sm && (
508 git commit -m "Add foo"
515 # Changes to be committed:
516 # (use "git reset HEAD <file>..." to unstage)
518 # new file: dir2/added
521 # Changed but not updated:
522 # (use "git add <file>..." to update what will be committed)
523 # (use "git checkout -- <file>..." to discard changes in working directory)
525 # modified: dir1/modified
528 # (use "git add <file>..." to include in what will be committed)
537 test_expect_success
'status submodule summary is disabled by default' '
538 git status >output &&
539 test_cmp expect output
542 # we expect the same as the previous test
543 test_expect_success
'status --untracked-files=all does not show submodule' '
544 git status --untracked-files=all >output &&
545 test_cmp expect output
559 test_expect_success
'status -s submodule summary is disabled by default' '
560 git status -s >output &&
561 test_cmp expect output
564 # we expect the same as the previous test
565 test_expect_success
'status -s --untracked-files=all does not show submodule' '
566 git status -s --untracked-files=all >output &&
567 test_cmp expect output
570 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
574 # Changes to be committed:
575 # (use "git reset HEAD <file>..." to unstage)
577 # new file: dir2/added
580 # Changed but not updated:
581 # (use "git add <file>..." to update what will be committed)
582 # (use "git checkout -- <file>..." to discard changes in working directory)
584 # modified: dir1/modified
586 # Modified submodules:
588 # * sm 0000000...$head (1):
592 # (use "git add <file>..." to include in what will be committed)
601 test_expect_success
'status submodule summary' '
602 git config status.submodulesummary 10 &&
603 git status >output &&
604 test_cmp expect output
618 test_expect_success
'status -s submodule summary' '
619 git status -s >output &&
620 test_cmp expect output
625 # Changed but not updated:
626 # (use "git add <file>..." to update what will be committed)
627 # (use "git checkout -- <file>..." to discard changes in working directory)
629 # modified: dir1/modified
632 # (use "git add <file>..." to include in what will be committed)
640 no changes added to commit (use "git add" and/or "git commit -a")
642 test_expect_success
'status submodule summary (clean submodule)' '
643 git commit -m "commit submodule" &&
644 git config status.submodulesummary 10 &&
645 test_must_fail git commit --dry-run >output &&
646 test_cmp expect output &&
647 git status >output &&
648 test_cmp expect output
660 test_expect_success
'status -s submodule summary (clean submodule)' '
661 git status -s >output &&
662 test_cmp expect output
667 # Changes to be committed:
668 # (use "git reset HEAD^1 <file>..." to unstage)
670 # new file: dir2/added
673 # Changed but not updated:
674 # (use "git add <file>..." to update what will be committed)
675 # (use "git checkout -- <file>..." to discard changes in working directory)
677 # modified: dir1/modified
679 # Modified submodules:
681 # * sm 0000000...$head (1):
685 # (use "git add <file>..." to include in what will be committed)
694 test_expect_success
'commit --dry-run submodule summary (--amend)' '
695 git config status.submodulesummary 10 &&
696 git commit --dry-run --amend >output &&
697 test_cmp expect output