Merge branch 'master' of git://repo.or.cz/alt-git
[git/mingw.git] / t / t7502-status.sh
blobd99530fa0a683cce99cfec677c1f3fe36f99d386
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 case $(uname -s) in
9 *MINGW*) GIT_TEST_CMP="diff -uw";;
10 esac
12 . ./test-lib.sh
14 test_expect_success 'setup' '
15 : > tracked &&
16 : > modified &&
17 mkdir dir1 &&
18 : > dir1/tracked &&
19 : > dir1/modified &&
20 mkdir dir2 &&
21 : > dir1/tracked &&
22 : > dir1/modified &&
23 git add . &&
25 git status >output &&
27 test_tick &&
28 git commit -m initial &&
29 : > untracked &&
30 : > dir1/untracked &&
31 : > dir2/untracked &&
32 echo 1 > dir1/modified &&
33 echo 2 > dir2/modified &&
34 echo 3 > dir2/added &&
35 git add dir2/added
38 test_expect_success 'status (1)' '
40 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
44 cat > expect << \EOF
45 # On branch master
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)
54 # modified: dir1/modified
56 # Untracked files:
57 # (use "git add <file>..." to include in what will be committed)
59 # dir1/untracked
60 # dir2/modified
61 # dir2/untracked
62 # expect
63 # output
64 # untracked
65 EOF
67 test_expect_success 'status (2)' '
69 git status > output &&
70 test_cmp expect output
74 cat >expect <<EOF
75 # On branch master
76 # Changes to be committed:
77 # (use "git reset HEAD <file>..." to unstage)
79 # new file: dir2/added
81 # Changed but not updated:
82 # (use "git add <file>..." to update what will be committed)
84 # modified: dir1/modified
86 # Untracked files not listed (use -u option to show untracked files)
87 EOF
88 test_expect_success 'status -uno' '
89 mkdir dir3 &&
90 : > dir3/untracked1 &&
91 : > dir3/untracked2 &&
92 git status -uno >output &&
93 test_cmp expect output
96 test_expect_success 'status (status.showUntrackedFiles no)' '
97 git config status.showuntrackedfiles no
98 git status >output &&
99 test_cmp expect output
102 cat >expect <<EOF
103 # On branch master
104 # Changes to be committed:
105 # (use "git reset HEAD <file>..." to unstage)
107 # new file: dir2/added
109 # Changed but not updated:
110 # (use "git add <file>..." to update what will be committed)
112 # modified: dir1/modified
114 # Untracked files:
115 # (use "git add <file>..." to include in what will be committed)
117 # dir1/untracked
118 # dir2/modified
119 # dir2/untracked
120 # dir3/
121 # expect
122 # output
123 # untracked
125 test_expect_success 'status -unormal' '
126 git status -unormal >output &&
127 test_cmp expect output
130 test_expect_success 'status (status.showUntrackedFiles normal)' '
131 git config status.showuntrackedfiles normal
132 git status >output &&
133 test_cmp expect output
136 cat >expect <<EOF
137 # On branch master
138 # Changes to be committed:
139 # (use "git reset HEAD <file>..." to unstage)
141 # new file: dir2/added
143 # Changed but not updated:
144 # (use "git add <file>..." to update what will be committed)
146 # modified: dir1/modified
148 # Untracked files:
149 # (use "git add <file>..." to include in what will be committed)
151 # dir1/untracked
152 # dir2/modified
153 # dir2/untracked
154 # dir3/untracked1
155 # dir3/untracked2
156 # expect
157 # output
158 # untracked
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 &&
167 rm -rf dir3 &&
168 git config --unset status.showuntrackedfiles &&
169 test_cmp expect output
172 cat > expect << \EOF
173 # On branch master
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)
182 # modified: modified
184 # Untracked files:
185 # (use "git add <file>..." to include in what will be committed)
187 # untracked
188 # ../dir2/modified
189 # ../dir2/untracked
190 # ../expect
191 # ../output
192 # ../untracked
195 test_expect_success 'status with relative paths' '
197 (cd dir1 && git status) > output &&
198 test_cmp expect output
202 cat > expect << \EOF
203 # On branch master
204 # Changes to be committed:
205 # (use "git reset HEAD <file>..." to unstage)
207 # new file: dir2/added
209 # Changed but not updated:
210 # (use "git add <file>..." to update what will be committed)
212 # modified: dir1/modified
214 # Untracked files:
215 # (use "git add <file>..." to include in what will be committed)
217 # dir1/untracked
218 # dir2/modified
219 # dir2/untracked
220 # expect
221 # output
222 # untracked
225 test_expect_success 'status without relative paths' '
227 git config status.relativePaths false
228 (cd dir1 && git status) > output &&
229 test_cmp expect output
233 cat <<EOF >expect
234 # On branch master
235 # Changes to be committed:
236 # (use "git reset HEAD <file>..." to unstage)
238 # modified: dir1/modified
240 # Untracked files:
241 # (use "git add <file>..." to include in what will be committed)
243 # dir1/untracked
244 # dir2/
245 # expect
246 # output
247 # untracked
249 test_expect_success 'status of partial commit excluding new file in index' '
250 git status dir1/modified >output &&
251 test_cmp expect output
254 test_expect_success 'setup status submodule summary' '
255 test_create_repo sm && (
256 cd sm &&
257 >foo &&
258 git add foo &&
259 git commit -m "Add foo"
260 ) &&
261 git add sm
264 cat >expect <<EOF
265 # On branch master
266 # Changes to be committed:
267 # (use "git reset HEAD <file>..." to unstage)
269 # new file: dir2/added
270 # new file: sm
272 # Changed but not updated:
273 # (use "git add <file>..." to update what will be committed)
275 # modified: dir1/modified
277 # Untracked files:
278 # (use "git add <file>..." to include in what will be committed)
280 # dir1/untracked
281 # dir2/modified
282 # dir2/untracked
283 # expect
284 # output
285 # untracked
287 test_expect_success 'status submodule summary is disabled by default' '
288 git status >output &&
289 test_cmp expect output
292 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
294 cat >expect <<EOF
295 # On branch master
296 # Changes to be committed:
297 # (use "git reset HEAD <file>..." to unstage)
299 # new file: dir2/added
300 # new file: sm
302 # Changed but not updated:
303 # (use "git add <file>..." to update what will be committed)
305 # modified: dir1/modified
307 # Modified submodules:
309 # * sm 0000000...$head (1):
310 # > Add foo
312 # Untracked files:
313 # (use "git add <file>..." to include in what will be committed)
315 # dir1/untracked
316 # dir2/modified
317 # dir2/untracked
318 # expect
319 # output
320 # untracked
322 test_expect_success 'status submodule summary' '
323 git config status.submodulesummary 10 &&
324 git status >output &&
325 test_cmp expect output
329 cat >expect <<EOF
330 # On branch master
331 # Changed but not updated:
332 # (use "git add <file>..." to update what will be committed)
334 # modified: dir1/modified
336 # Untracked files:
337 # (use "git add <file>..." to include in what will be committed)
339 # dir1/untracked
340 # dir2/modified
341 # dir2/untracked
342 # expect
343 # output
344 # untracked
345 no changes added to commit (use "git add" and/or "git commit -a")
347 test_expect_success 'status submodule summary (clean submodule)' '
348 git commit -m "commit submodule" &&
349 git config status.submodulesummary 10 &&
350 test_must_fail git status >output &&
351 test_cmp expect output
354 cat >expect <<EOF
355 # On branch master
356 # Changes to be committed:
357 # (use "git reset HEAD^1 <file>..." to unstage)
359 # new file: dir2/added
360 # new file: sm
362 # Changed but not updated:
363 # (use "git add <file>..." to update what will be committed)
365 # modified: dir1/modified
367 # Modified submodules:
369 # * sm 0000000...$head (1):
370 # > Add foo
372 # Untracked files:
373 # (use "git add <file>..." to include in what will be committed)
375 # dir1/untracked
376 # dir2/modified
377 # dir2/untracked
378 # expect
379 # output
380 # untracked
382 test_expect_success 'status submodule summary (--amend)' '
383 git config status.submodulesummary 10 &&
384 git status --amend >output &&
385 test_cmp expect output
388 test_done