Merge branch 'maint'
[git.git] / t / t7502-status.sh
blob1905fb34cd222aa9443d28fd673b0cc9e02f3335
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='git status'
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 : > tracked &&
12 : > modified &&
13 mkdir dir1 &&
14 : > dir1/tracked &&
15 : > dir1/modified &&
16 mkdir dir2 &&
17 : > dir1/tracked &&
18 : > dir1/modified &&
19 git add . &&
21 git status >output &&
23 test_tick &&
24 git commit -m initial &&
25 : > untracked &&
26 : > dir1/untracked &&
27 : > dir2/untracked &&
28 echo 1 > dir1/modified &&
29 echo 2 > dir2/modified &&
30 echo 3 > dir2/added &&
31 git add dir2/added
34 test_expect_success 'status (1)' '
36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
40 cat > expect << \EOF
41 # On branch master
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
53 # Untracked files:
54 # (use "git add <file>..." to include in what will be committed)
56 # dir1/untracked
57 # dir2/modified
58 # dir2/untracked
59 # expect
60 # output
61 # untracked
62 EOF
64 test_expect_success 'status (2)' '
66 git status > output &&
67 test_cmp expect output
71 cat >expect <<EOF
72 # On branch master
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)
85 EOF
86 test_expect_success 'status -uno' '
87 mkdir dir3 &&
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
96 git status >output &&
97 test_cmp expect output
100 cat >expect <<EOF
101 # On branch master
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
113 # Untracked files:
114 # (use "git add <file>..." to include in what will be committed)
116 # dir1/untracked
117 # dir2/modified
118 # dir2/untracked
119 # dir3/
120 # expect
121 # output
122 # untracked
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
135 cat >expect <<EOF
136 # On branch master
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
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)
181 # (use "git checkout -- <file>..." to discard changes in working directory)
183 # modified: modified
185 # Untracked files:
186 # (use "git add <file>..." to include in what will be committed)
188 # untracked
189 # ../dir2/modified
190 # ../dir2/untracked
191 # ../expect
192 # ../output
193 # ../untracked
196 test_expect_success 'status with relative paths' '
198 (cd dir1 && git status) > output &&
199 test_cmp expect output
203 cat > expect << \EOF
204 # On branch master
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
216 # Untracked files:
217 # (use "git add <file>..." to include in what will be committed)
219 # dir1/untracked
220 # dir2/modified
221 # dir2/untracked
222 # expect
223 # output
224 # untracked
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
235 cat <<EOF >expect
236 # On branch master
237 # Changes to be committed:
238 # (use "git reset HEAD <file>..." to unstage)
240 # modified: dir1/modified
242 # Untracked files:
243 # (use "git add <file>..." to include in what will be committed)
245 # dir1/untracked
246 # dir2/
247 # expect
248 # output
249 # untracked
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 && (
258 cd sm &&
259 >foo &&
260 git add foo &&
261 git commit -m "Add foo"
262 ) &&
263 git add sm
266 cat >expect <<EOF
267 # On branch master
268 # Changes to be committed:
269 # (use "git reset HEAD <file>..." to unstage)
271 # new file: dir2/added
272 # new file: sm
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
280 # Untracked files:
281 # (use "git add <file>..." to include in what will be committed)
283 # dir1/untracked
284 # dir2/modified
285 # dir2/untracked
286 # expect
287 # output
288 # untracked
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)
297 cat >expect <<EOF
298 # On branch master
299 # Changes to be committed:
300 # (use "git reset HEAD <file>..." to unstage)
302 # new file: dir2/added
303 # new file: sm
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):
314 # > Add foo
316 # Untracked files:
317 # (use "git add <file>..." to include in what will be committed)
319 # dir1/untracked
320 # dir2/modified
321 # dir2/untracked
322 # expect
323 # output
324 # untracked
326 test_expect_success 'status submodule summary' '
327 git config status.submodulesummary 10 &&
328 git status >output &&
329 test_cmp expect output
333 cat >expect <<EOF
334 # On branch master
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
341 # Untracked files:
342 # (use "git add <file>..." to include in what will be committed)
344 # dir1/untracked
345 # dir2/modified
346 # dir2/untracked
347 # expect
348 # output
349 # untracked
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
359 cat >expect <<EOF
360 # On branch master
361 # Changes to be committed:
362 # (use "git reset HEAD^1 <file>..." to unstage)
364 # new file: dir2/added
365 # new file: sm
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):
376 # > Add foo
378 # Untracked files:
379 # (use "git add <file>..." to include in what will be committed)
381 # dir1/untracked
382 # dir2/modified
383 # dir2/untracked
384 # expect
385 # output
386 # untracked
388 test_expect_success 'status submodule summary (--amend)' '
389 git config status.submodulesummary 10 &&
390 git status --amend >output &&
391 test_cmp expect output
394 test_done