MinGW tests: override 'pwd', too
[git/mingw/4msysgit/wingit-dll.git] / t / t7502-status.sh
blob5885023e53cd51231bdd58d139e094c9848dffdf
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)
53 # (use "git checkout -- <file>..." to discard changes in working directory)
55 # modified: dir1/modified
57 # Untracked files:
58 # (use "git add <file>..." to include in what will be committed)
60 # dir1/untracked
61 # dir2/modified
62 # dir2/untracked
63 # expect
64 # output
65 # untracked
66 EOF
68 test_expect_success 'status (2)' '
70 git status > output &&
71 test_cmp expect output
75 cat >expect <<EOF
76 # On branch master
77 # Changes to be committed:
78 # (use "git reset HEAD <file>..." to unstage)
80 # new file: dir2/added
82 # Changed but not updated:
83 # (use "git add <file>..." to update what will be committed)
84 # (use "git checkout -- <file>..." to discard changes in working directory)
86 # modified: dir1/modified
88 # Untracked files not listed (use -u option to show untracked files)
89 EOF
90 test_expect_success 'status -uno' '
91 mkdir dir3 &&
92 : > dir3/untracked1 &&
93 : > dir3/untracked2 &&
94 git status -uno >output &&
95 test_cmp expect output
98 test_expect_success 'status (status.showUntrackedFiles no)' '
99 git config status.showuntrackedfiles no
100 git status >output &&
101 test_cmp expect output
104 cat >expect <<EOF
105 # On branch master
106 # Changes to be committed:
107 # (use "git reset HEAD <file>..." to unstage)
109 # new file: dir2/added
111 # Changed but not updated:
112 # (use "git add <file>..." to update what will be committed)
113 # (use "git checkout -- <file>..." to discard changes in working directory)
115 # modified: dir1/modified
117 # Untracked files:
118 # (use "git add <file>..." to include in what will be committed)
120 # dir1/untracked
121 # dir2/modified
122 # dir2/untracked
123 # dir3/
124 # expect
125 # output
126 # untracked
128 test_expect_success 'status -unormal' '
129 git status -unormal >output &&
130 test_cmp expect output
133 test_expect_success 'status (status.showUntrackedFiles normal)' '
134 git config status.showuntrackedfiles normal
135 git status >output &&
136 test_cmp expect output
139 cat >expect <<EOF
140 # On branch master
141 # Changes to be committed:
142 # (use "git reset HEAD <file>..." to unstage)
144 # new file: dir2/added
146 # Changed but not updated:
147 # (use "git add <file>..." to update what will be committed)
148 # (use "git checkout -- <file>..." to discard changes in working directory)
150 # modified: dir1/modified
152 # Untracked files:
153 # (use "git add <file>..." to include in what will be committed)
155 # dir1/untracked
156 # dir2/modified
157 # dir2/untracked
158 # dir3/untracked1
159 # dir3/untracked2
160 # expect
161 # output
162 # untracked
164 test_expect_success 'status -uall' '
165 git status -uall >output &&
166 test_cmp expect output
168 test_expect_success 'status (status.showUntrackedFiles all)' '
169 git config status.showuntrackedfiles all
170 git status >output &&
171 rm -rf dir3 &&
172 git config --unset status.showuntrackedfiles &&
173 test_cmp expect output
176 cat > expect << \EOF
177 # On branch master
178 # Changes to be committed:
179 # (use "git reset HEAD <file>..." to unstage)
181 # new file: ../dir2/added
183 # Changed but not updated:
184 # (use "git add <file>..." to update what will be committed)
185 # (use "git checkout -- <file>..." to discard changes in working directory)
187 # modified: modified
189 # Untracked files:
190 # (use "git add <file>..." to include in what will be committed)
192 # untracked
193 # ../dir2/modified
194 # ../dir2/untracked
195 # ../expect
196 # ../output
197 # ../untracked
200 test_expect_success 'status with relative paths' '
202 (cd dir1 && git status) > output &&
203 test_cmp expect output
207 cat > expect << \EOF
208 # On branch master
209 # Changes to be committed:
210 # (use "git reset HEAD <file>..." to unstage)
212 # new file: dir2/added
214 # Changed but not updated:
215 # (use "git add <file>..." to update what will be committed)
216 # (use "git checkout -- <file>..." to discard changes in working directory)
218 # modified: dir1/modified
220 # Untracked files:
221 # (use "git add <file>..." to include in what will be committed)
223 # dir1/untracked
224 # dir2/modified
225 # dir2/untracked
226 # expect
227 # output
228 # untracked
231 test_expect_success 'status without relative paths' '
233 git config status.relativePaths false
234 (cd dir1 && git status) > output &&
235 test_cmp expect output
239 cat <<EOF >expect
240 # On branch master
241 # Changes to be committed:
242 # (use "git reset HEAD <file>..." to unstage)
244 # modified: dir1/modified
246 # Untracked files:
247 # (use "git add <file>..." to include in what will be committed)
249 # dir1/untracked
250 # dir2/
251 # expect
252 # output
253 # untracked
255 test_expect_success 'status of partial commit excluding new file in index' '
256 git status dir1/modified >output &&
257 test_cmp expect output
260 test_expect_success 'setup status submodule summary' '
261 test_create_repo sm && (
262 cd sm &&
263 >foo &&
264 git add foo &&
265 git commit -m "Add foo"
266 ) &&
267 git add sm
270 cat >expect <<EOF
271 # On branch master
272 # Changes to be committed:
273 # (use "git reset HEAD <file>..." to unstage)
275 # new file: dir2/added
276 # new file: sm
278 # Changed but not updated:
279 # (use "git add <file>..." to update what will be committed)
280 # (use "git checkout -- <file>..." to discard changes in working directory)
282 # modified: dir1/modified
284 # Untracked files:
285 # (use "git add <file>..." to include in what will be committed)
287 # dir1/untracked
288 # dir2/modified
289 # dir2/untracked
290 # expect
291 # output
292 # untracked
294 test_expect_success 'status submodule summary is disabled by default' '
295 git status >output &&
296 test_cmp expect output
299 # we expect the same as the previous test
300 test_expect_success 'status --untracked-files=all does not show submodule' '
301 git status --untracked-files=all >output &&
302 test_cmp expect output
305 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
307 cat >expect <<EOF
308 # On branch master
309 # Changes to be committed:
310 # (use "git reset HEAD <file>..." to unstage)
312 # new file: dir2/added
313 # new file: sm
315 # Changed but not updated:
316 # (use "git add <file>..." to update what will be committed)
317 # (use "git checkout -- <file>..." to discard changes in working directory)
319 # modified: dir1/modified
321 # Modified submodules:
323 # * sm 0000000...$head (1):
324 # > Add foo
326 # Untracked files:
327 # (use "git add <file>..." to include in what will be committed)
329 # dir1/untracked
330 # dir2/modified
331 # dir2/untracked
332 # expect
333 # output
334 # untracked
336 test_expect_success 'status submodule summary' '
337 git config status.submodulesummary 10 &&
338 git status >output &&
339 test_cmp expect output
343 cat >expect <<EOF
344 # On branch master
345 # Changed but not updated:
346 # (use "git add <file>..." to update what will be committed)
347 # (use "git checkout -- <file>..." to discard changes in working directory)
349 # modified: dir1/modified
351 # Untracked files:
352 # (use "git add <file>..." to include in what will be committed)
354 # dir1/untracked
355 # dir2/modified
356 # dir2/untracked
357 # expect
358 # output
359 # untracked
360 no changes added to commit (use "git add" and/or "git commit -a")
362 test_expect_success 'status submodule summary (clean submodule)' '
363 git commit -m "commit submodule" &&
364 git config status.submodulesummary 10 &&
365 test_must_fail git status >output &&
366 test_cmp expect output
369 cat >expect <<EOF
370 # On branch master
371 # Changes to be committed:
372 # (use "git reset HEAD^1 <file>..." to unstage)
374 # new file: dir2/added
375 # new file: sm
377 # Changed but not updated:
378 # (use "git add <file>..." to update what will be committed)
379 # (use "git checkout -- <file>..." to discard changes in working directory)
381 # modified: dir1/modified
383 # Modified submodules:
385 # * sm 0000000...$head (1):
386 # > Add foo
388 # Untracked files:
389 # (use "git add <file>..." to include in what will be committed)
391 # dir1/untracked
392 # dir2/modified
393 # dir2/untracked
394 # expect
395 # output
396 # untracked
398 test_expect_success 'status submodule summary (--amend)' '
399 git config status.submodulesummary 10 &&
400 git status --amend >output &&
401 test_cmp expect output
404 test_done