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 'dry-run of partial commit excluding new file in index' '
252 git commit --dry-run 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 # we expect the same as the previous test
296 test_expect_success 'status --untracked-files=all does not show submodule' '
297 git status --untracked-files=all >output &&
298 test_cmp expect output
301 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
305 # Changes to be committed:
306 # (use "git reset HEAD <file>..." to unstage)
308 # new file: dir2/added
311 # Changed but not updated:
312 # (use "git add <file>..." to update what will be committed)
313 # (use "git checkout -- <file>..." to discard changes in working directory)
315 # modified: dir1/modified
317 # Modified submodules:
319 # * sm 0000000...$head (1):
323 # (use "git add <file>..." to include in what will be committed)
332 test_expect_success 'status submodule summary' '
333 git config status.submodulesummary 10 &&
334 git status >output &&
335 test_cmp expect output
341 # Changed but not updated:
342 # (use "git add <file>..." to update what will be committed)
343 # (use "git checkout -- <file>..." to discard changes in working directory)
345 # modified: dir1/modified
348 # (use "git add <file>..." to include in what will be committed)
356 no changes added to commit (use "git add" and/or "git commit -a")
358 test_expect_success 'status submodule summary (clean submodule)' '
359 git commit -m "commit submodule" &&
360 git config status.submodulesummary 10 &&
361 test_must_fail git commit --dry-run >output &&
362 test_cmp expect output &&
363 git status >output &&
364 test_cmp expect output
369 # Changes to be committed:
370 # (use "git reset HEAD^1 <file>..." to unstage)
372 # new file: dir2/added
375 # Changed but not updated:
376 # (use "git add <file>..." to update what will be committed)
377 # (use "git checkout -- <file>..." to discard changes in working directory)
379 # modified: dir1/modified
381 # Modified submodules:
383 # * sm 0000000...$head (1):
387 # (use "git add <file>..." to include in what will be committed)
396 test_expect_success 'commit --dry-run submodule summary (--amend)' '
397 git config status.submodulesummary 10 &&
398 git commit --dry-run --amend >output &&
399 test_cmp expect output