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 &&
34 echo 3 > dir2/added &&
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)' '
70 git status > output &&
71 test_cmp expect output
77 # Changes to be committed:
78 # (use "git reset HEAD <file>..." to unstage)
80 # new file: dir2/added
82 # Changed but not updated:
83 # (use "git add <file>..." to update what will be committed)
84 # (use "git checkout -- <file>..." to discard changes in working directory)
86 # modified: dir1/modified
88 # Untracked files not listed (use -u option to show untracked files)
90 test_expect_success
'status -uno' '
92 : > dir3/untracked1 &&
93 : > dir3/untracked2 &&
94 git status -uno >output &&
95 test_cmp expect output
98 test_expect_success
'status (status.showUntrackedFiles no)' '
99 git config status.showuntrackedfiles no
100 git status >output &&
101 test_cmp expect output
106 # Changes to be committed:
107 # (use "git reset HEAD <file>..." to unstage)
109 # new file: dir2/added
111 # Changed but not updated:
112 # (use "git add <file>..." to update what will be committed)
113 # (use "git checkout -- <file>..." to discard changes in working directory)
115 # modified: dir1/modified
118 # (use "git add <file>..." to include in what will be committed)
128 test_expect_success
'status -unormal' '
129 git status -unormal >output &&
130 test_cmp expect output
133 test_expect_success
'status (status.showUntrackedFiles normal)' '
134 git config status.showuntrackedfiles normal
135 git status >output &&
136 test_cmp expect output
141 # Changes to be committed:
142 # (use "git reset HEAD <file>..." to unstage)
144 # new file: dir2/added
146 # Changed but not updated:
147 # (use "git add <file>..." to update what will be committed)
148 # (use "git checkout -- <file>..." to discard changes in working directory)
150 # modified: dir1/modified
153 # (use "git add <file>..." to include in what will be committed)
164 test_expect_success
'status -uall' '
165 git status -uall >output &&
166 test_cmp expect output
168 test_expect_success
'status (status.showUntrackedFiles all)' '
169 git config status.showuntrackedfiles all
170 git status >output &&
172 git config --unset status.showuntrackedfiles &&
173 test_cmp expect output
178 # Changes to be committed:
179 # (use "git reset HEAD <file>..." to unstage)
181 # new file: ../dir2/added
183 # Changed but not updated:
184 # (use "git add <file>..." to update what will be committed)
185 # (use "git checkout -- <file>..." to discard changes in working directory)
190 # (use "git add <file>..." to include in what will be committed)
200 test_expect_success
'status with relative paths' '
202 (cd dir1 && git status) > output &&
203 test_cmp expect output
209 # Changes to be committed:
210 # (use "git reset HEAD <file>..." to unstage)
212 # new file: dir2/added
214 # Changed but not updated:
215 # (use "git add <file>..." to update what will be committed)
216 # (use "git checkout -- <file>..." to discard changes in working directory)
218 # modified: dir1/modified
221 # (use "git add <file>..." to include in what will be committed)
231 test_expect_success
'status without relative paths' '
233 git config status.relativePaths false
234 (cd dir1 && git status) > output &&
235 test_cmp expect output
241 # Changes to be committed:
242 # (use "git reset HEAD <file>..." to unstage)
244 # modified: dir1/modified
247 # (use "git add <file>..." to include in what will be committed)
255 test_expect_success
'status of partial commit excluding new file in index' '
256 git status dir1/modified >output &&
257 test_cmp expect output
260 test_expect_success
'setup status submodule summary' '
261 test_create_repo sm && (
265 git commit -m "Add foo"
272 # Changes to be committed:
273 # (use "git reset HEAD <file>..." to unstage)
275 # new file: dir2/added
278 # Changed but not updated:
279 # (use "git add <file>..." to update what will be committed)
280 # (use "git checkout -- <file>..." to discard changes in working directory)
282 # modified: dir1/modified
285 # (use "git add <file>..." to include in what will be committed)
294 test_expect_success
'status submodule summary is disabled by default' '
295 git status >output &&
296 test_cmp expect output
299 # we expect the same as the previous test
300 test_expect_success
'status --untracked-files=all does not show submodule' '
301 git status --untracked-files=all >output &&
302 test_cmp expect output
305 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
309 # Changes to be committed:
310 # (use "git reset HEAD <file>..." to unstage)
312 # new file: dir2/added
315 # Changed but not updated:
316 # (use "git add <file>..." to update what will be committed)
317 # (use "git checkout -- <file>..." to discard changes in working directory)
319 # modified: dir1/modified
321 # Modified submodules:
323 # * sm 0000000...$head (1):
327 # (use "git add <file>..." to include in what will be committed)
336 test_expect_success
'status submodule summary' '
337 git config status.submodulesummary 10 &&
338 git status >output &&
339 test_cmp expect output
345 # Changed but not updated:
346 # (use "git add <file>..." to update what will be committed)
347 # (use "git checkout -- <file>..." to discard changes in working directory)
349 # modified: dir1/modified
352 # (use "git add <file>..." to include in what will be committed)
360 no changes added to commit (use "git add" and/or "git commit -a")
362 test_expect_success
'status submodule summary (clean submodule)' '
363 git commit -m "commit submodule" &&
364 git config status.submodulesummary 10 &&
365 test_must_fail git status >output &&
366 test_cmp expect output
371 # Changes to be committed:
372 # (use "git reset HEAD^1 <file>..." to unstage)
374 # new file: dir2/added
377 # Changed but not updated:
378 # (use "git add <file>..." to update what will be committed)
379 # (use "git checkout -- <file>..." to discard changes in working directory)
381 # modified: dir1/modified
383 # Modified submodules:
385 # * sm 0000000...$head (1):
389 # (use "git add <file>..." to include in what will be committed)
398 test_expect_success
'status submodule summary (--amend)' '
399 git config status.submodulesummary 10 &&
400 git status --amend >output &&
401 test_cmp expect output