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 &&
30 echo 3 > dir2/added &&
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)' '
66 git status > output &&
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
302 # Changes to be committed:
303 # (use "git reset HEAD <file>..." to unstage)
305 # new file: dir2/added
307 # Changed but not updated:
308 # (use "git add <file>..." to update what will be committed)
309 # (use "git checkout -- <file>..." to discard changes in working directory)
311 # modified: dir1/modified
314 # (use "git add <file>..." to include in what will be committed)
324 test_expect_success
'status without relative paths' '
326 git config status.relativePaths false
327 (cd dir1 && git status) > output &&
328 test_cmp expect output
343 test_expect_success
'status -s without relative paths' '
345 (cd dir1 && git status -s) > output &&
346 test_cmp expect output
352 # Changes to be committed:
353 # (use "git reset HEAD <file>..." to unstage)
355 # modified: dir1/modified
358 # (use "git add <file>..." to include in what will be committed)
366 test_expect_success
'dry-run of partial commit excluding new file in index' '
367 git commit --dry-run dir1/modified >output &&
368 test_cmp expect output
371 test_expect_success
'setup status submodule summary' '
372 test_create_repo sm && (
376 git commit -m "Add foo"
383 # Changes to be committed:
384 # (use "git reset HEAD <file>..." to unstage)
386 # new file: dir2/added
389 # Changed but not updated:
390 # (use "git add <file>..." to update what will be committed)
391 # (use "git checkout -- <file>..." to discard changes in working directory)
393 # modified: dir1/modified
396 # (use "git add <file>..." to include in what will be committed)
405 test_expect_success
'status submodule summary is disabled by default' '
406 git status >output &&
407 test_cmp expect output
410 # we expect the same as the previous test
411 test_expect_success
'status --untracked-files=all does not show submodule' '
412 git status --untracked-files=all >output &&
413 test_cmp expect output
427 test_expect_success
'status -s submodule summary is disabled by default' '
428 git status -s >output &&
429 test_cmp expect output
432 # we expect the same as the previous test
433 test_expect_success
'status -s --untracked-files=all does not show submodule' '
434 git status -s --untracked-files=all >output &&
435 test_cmp expect output
438 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
442 # Changes to be committed:
443 # (use "git reset HEAD <file>..." to unstage)
445 # new file: dir2/added
448 # Changed but not updated:
449 # (use "git add <file>..." to update what will be committed)
450 # (use "git checkout -- <file>..." to discard changes in working directory)
452 # modified: dir1/modified
454 # Modified submodules:
456 # * sm 0000000...$head (1):
460 # (use "git add <file>..." to include in what will be committed)
469 test_expect_success
'status submodule summary' '
470 git config status.submodulesummary 10 &&
471 git status >output &&
472 test_cmp expect output
486 test_expect_success
'status -s submodule summary' '
487 git status -s >output &&
488 test_cmp expect output
493 # Changed but not updated:
494 # (use "git add <file>..." to update what will be committed)
495 # (use "git checkout -- <file>..." to discard changes in working directory)
497 # modified: dir1/modified
500 # (use "git add <file>..." to include in what will be committed)
508 no changes added to commit (use "git add" and/or "git commit -a")
510 test_expect_success
'status submodule summary (clean submodule)' '
511 git commit -m "commit submodule" &&
512 git config status.submodulesummary 10 &&
513 test_must_fail git commit --dry-run >output &&
514 test_cmp expect output &&
515 git status >output &&
516 test_cmp expect output
528 test_expect_success
'status -s submodule summary (clean submodule)' '
529 git status -s >output &&
530 test_cmp expect output
535 # Changes to be committed:
536 # (use "git reset HEAD^1 <file>..." to unstage)
538 # new file: dir2/added
541 # Changed but not updated:
542 # (use "git add <file>..." to update what will be committed)
543 # (use "git checkout -- <file>..." to discard changes in working directory)
545 # modified: dir1/modified
547 # Modified submodules:
549 # * sm 0000000...$head (1):
553 # (use "git add <file>..." to include in what will be committed)
562 test_expect_success
'commit --dry-run submodule summary (--amend)' '
563 git config status.submodulesummary 10 &&
564 git commit --dry-run --amend >output &&
565 test_cmp expect output