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)
50 # modified: dir1/modified
53 # (use "git add <file>..." to include in what will be committed)
63 test_expect_success
'status (2)' '
65 git status > output &&
66 test_cmp expect output
72 # Changes to be committed:
73 # (use "git reset HEAD <file>..." to unstage)
75 # new file: dir2/added
77 # Changed but not updated:
78 # (use "git add <file>..." to update what will be committed)
80 # modified: dir1/modified
82 # Untracked files not listed (use -u option to show untracked files)
84 test_expect_success
'status -uno' '
86 : > dir3/untracked1 &&
87 : > dir3/untracked2 &&
88 git status -uno >output &&
89 test_cmp expect output
92 test_expect_success
'status (status.showUntrackedFiles no)' '
93 git config status.showuntrackedfiles no
95 test_cmp expect output
100 # Changes to be committed:
101 # (use "git reset HEAD <file>..." to unstage)
103 # new file: dir2/added
105 # Changed but not updated:
106 # (use "git add <file>..." to update what will be committed)
108 # modified: dir1/modified
111 # (use "git add <file>..." to include in what will be committed)
121 test_expect_success
'status -unormal' '
122 git status -unormal >output &&
123 test_cmp expect output
126 test_expect_success
'status (status.showUntrackedFiles normal)' '
127 git config status.showuntrackedfiles normal
128 git status >output &&
129 test_cmp expect output
134 # Changes to be committed:
135 # (use "git reset HEAD <file>..." to unstage)
137 # new file: dir2/added
139 # Changed but not updated:
140 # (use "git add <file>..." to update what will be committed)
142 # modified: dir1/modified
145 # (use "git add <file>..." to include in what will be committed)
156 test_expect_success
'status -uall' '
157 git status -uall >output &&
158 test_cmp expect output
160 test_expect_success
'status (status.showUntrackedFiles all)' '
161 git config status.showuntrackedfiles all
162 git status >output &&
164 git config --unset status.showuntrackedfiles &&
165 test_cmp expect output
170 # Changes to be committed:
171 # (use "git reset HEAD <file>..." to unstage)
173 # new file: ../dir2/added
175 # Changed but not updated:
176 # (use "git add <file>..." to update what will be committed)
181 # (use "git add <file>..." to include in what will be committed)
191 test_expect_success
'status with relative paths' '
193 (cd dir1 && git status) > output &&
194 test_cmp expect output
200 # Changes to be committed:
201 # (use "git reset HEAD <file>..." to unstage)
203 # new file: dir2/added
205 # Changed but not updated:
206 # (use "git add <file>..." to update what will be committed)
208 # modified: dir1/modified
211 # (use "git add <file>..." to include in what will be committed)
221 test_expect_success
'status without relative paths' '
223 git config status.relativePaths false
224 (cd dir1 && git status) > output &&
225 test_cmp expect output
231 # Changes to be committed:
232 # (use "git reset HEAD <file>..." to unstage)
234 # modified: dir1/modified
237 # (use "git add <file>..." to include in what will be committed)
245 test_expect_success
'status of partial commit excluding new file in index' '
246 git status dir1/modified >output &&
247 test_cmp expect output
250 test_expect_success
'setup status submodule summary' '
251 test_create_repo sm && (
255 git commit -m "Add foo"
262 # Changes to be committed:
263 # (use "git reset HEAD <file>..." to unstage)
265 # new file: dir2/added
268 # Changed but not updated:
269 # (use "git add <file>..." to update what will be committed)
271 # modified: dir1/modified
274 # (use "git add <file>..." to include in what will be committed)
283 test_expect_success
'status submodule summary is disabled by default' '
284 git status >output &&
285 test_cmp expect output
288 # we expect the same as the previous test
289 test_expect_success
'status --untracked-files=all does not show submodule' '
290 git status --untracked-files=all >output &&
291 test_cmp expect output
294 head=$
(cd sm
&& git rev-parse
--short=7 --verify HEAD
)
298 # Changes to be committed:
299 # (use "git reset HEAD <file>..." to unstage)
301 # new file: dir2/added
304 # Changed but not updated:
305 # (use "git add <file>..." to update what will be committed)
307 # modified: dir1/modified
309 # Modified submodules:
311 # * sm 0000000...$head (1):
315 # (use "git add <file>..." to include in what will be committed)
324 test_expect_success
'status submodule summary' '
325 git config status.submodulesummary 10 &&
326 git status >output &&
327 test_cmp expect output
333 # Changed but not updated:
334 # (use "git add <file>..." to update what will be committed)
336 # modified: dir1/modified
339 # (use "git add <file>..." to include in what will be committed)
347 no changes added to commit (use "git add" and/or "git commit -a")
349 test_expect_success
'status submodule summary (clean submodule)' '
350 git commit -m "commit submodule" &&
351 git config status.submodulesummary 10 &&
352 test_must_fail git status >output &&
353 test_cmp expect output
358 # Changes to be committed:
359 # (use "git reset HEAD^1 <file>..." to unstage)
361 # new file: dir2/added
364 # Changed but not updated:
365 # (use "git add <file>..." to update what will be committed)
367 # modified: dir1/modified
369 # Modified submodules:
371 # * sm 0000000...$head (1):
375 # (use "git add <file>..." to include in what will be committed)
384 test_expect_success
'status submodule summary (--amend)' '
385 git config status.submodulesummary 10 &&
386 git status --amend >output &&
387 test_cmp expect output