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
73 # Changes to be committed:
74 # (use "git reset HEAD <file>..." to unstage)
76 # new file: dir2/added
78 # Changed but not updated:
79 # (use "git add <file>..." to update what will be committed)
80 # (use "git checkout -- <file>..." to discard changes in working directory)
82 # modified: dir1/modified
84 # Untracked files not listed (use -u option to show untracked files)
86 test_expect_success 'status -uno' '
88 : > dir3/untracked1 &&
89 : > dir3/untracked2 &&
90 git status -uno >output &&
91 test_cmp expect output
94 test_expect_success 'status (status.showUntrackedFiles no)' '
95 git config status.showuntrackedfiles no
97 test_cmp expect output
102 # Changes to be committed:
103 # (use "git reset HEAD <file>..." to unstage)
105 # new file: dir2/added
107 # Changed but not updated:
108 # (use "git add <file>..." to update what will be committed)
109 # (use "git checkout -- <file>..." to discard changes in working directory)
111 # modified: dir1/modified
114 # (use "git add <file>..." to include in what will be committed)
124 test_expect_success 'status -unormal' '
125 git status -unormal >output &&
126 test_cmp expect output
129 test_expect_success 'status (status.showUntrackedFiles normal)' '
130 git config status.showuntrackedfiles normal
131 git status >output &&
132 test_cmp expect output
137 # Changes to be committed:
138 # (use "git reset HEAD <file>..." to unstage)
140 # new file: dir2/added
142 # Changed but not updated:
143 # (use "git add <file>..." to update what will be committed)
144 # (use "git checkout -- <file>..." to discard changes in working directory)
146 # modified: dir1/modified
149 # (use "git add <file>..." to include in what will be committed)
160 test_expect_success 'status -uall' '
161 git status -uall >output &&
162 test_cmp expect output
164 test_expect_success 'status (status.showUntrackedFiles all)' '
165 git config status.showuntrackedfiles all
166 git status >output &&
168 git config --unset status.showuntrackedfiles &&
169 test_cmp expect output
174 # Changes to be committed:
175 # (use "git reset HEAD <file>..." to unstage)
177 # new file: ../dir2/added
179 # Changed but not updated:
180 # (use "git add <file>..." to update what will be committed)
181 # (use "git checkout -- <file>..." to discard changes in working directory)
186 # (use "git add <file>..." to include in what will be committed)
196 test_expect_success 'status with relative paths' '
198 (cd dir1 && git status) > output &&
199 test_cmp expect output
205 # Changes to be committed:
206 # (use "git reset HEAD <file>..." to unstage)
208 # new file: dir2/added
210 # Changed but not updated:
211 # (use "git add <file>..." to update what will be committed)
212 # (use "git checkout -- <file>..." to discard changes in working directory)
214 # modified: dir1/modified
217 # (use "git add <file>..." to include in what will be committed)
227 test_expect_success 'status without relative paths' '
229 git config status.relativePaths false
230 (cd dir1 && git status) > output &&
231 test_cmp expect output
237 # Changes to be committed:
238 # (use "git reset HEAD <file>..." to unstage)
240 # modified: dir1/modified
243 # (use "git add <file>..." to include in what will be committed)
251 test_expect_success 'status of partial commit excluding new file in index' '
252 git status dir1/modified >output &&
253 test_cmp expect output
256 test_expect_success 'setup status submodule summary' '
257 test_create_repo sm && (
261 git commit -m "Add foo"
268 # Changes to be committed:
269 # (use "git reset HEAD <file>..." to unstage)
271 # new file: dir2/added
274 # Changed but not updated:
275 # (use "git add <file>..." to update what will be committed)
276 # (use "git checkout -- <file>..." to discard changes in working directory)
278 # modified: dir1/modified
281 # (use "git add <file>..." to include in what will be committed)
290 test_expect_success 'status submodule summary is disabled by default' '
291 git status >output &&
292 test_cmp expect output
295 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
299 # Changes to be committed:
300 # (use "git reset HEAD <file>..." to unstage)
302 # new file: dir2/added
305 # Changed but not updated:
306 # (use "git add <file>..." to update what will be committed)
307 # (use "git checkout -- <file>..." to discard changes in working directory)
309 # modified: dir1/modified
311 # Modified submodules:
313 # * sm 0000000...$head (1):
317 # (use "git add <file>..." to include in what will be committed)
326 test_expect_success 'status submodule summary' '
327 git config status.submodulesummary 10 &&
328 git status >output &&
329 test_cmp expect output
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 # modified: dir1/modified
342 # (use "git add <file>..." to include in what will be committed)
350 no changes added to commit (use "git add" and/or "git commit -a")
352 test_expect_success 'status submodule summary (clean submodule)' '
353 git commit -m "commit submodule" &&
354 git config status.submodulesummary 10 &&
355 test_must_fail git status >output &&
356 test_cmp expect output
361 # Changes to be committed:
362 # (use "git reset HEAD^1 <file>..." to unstage)
364 # new file: dir2/added
367 # Changed but not updated:
368 # (use "git add <file>..." to update what will be committed)
369 # (use "git checkout -- <file>..." to discard changes in working directory)
371 # modified: dir1/modified
373 # Modified submodules:
375 # * sm 0000000...$head (1):
379 # (use "git add <file>..." to include in what will be committed)
388 test_expect_success 'status submodule summary (--amend)' '
389 git config status.submodulesummary 10 &&
390 git status --amend >output &&
391 test_cmp expect output