status -s: respect the status.relativePaths option
[git/git.git] / t / t7508-status.sh
CommitLineData
367c9886
JS
1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
47a528ad 6test_description='git status'
367c9886
JS
7
8. ./test-lib.sh
9
10test_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 . &&
ff58b9aa
JK
20
21 git status >output &&
22
367c9886
JS
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
32'
33
ff58b9aa
JK
34test_expect_success 'status (1)' '
35
aadbe44f 36 grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
ff58b9aa
JK
37
38'
39
367c9886
JS
40cat > expect << \EOF
41# On branch master
42# Changes to be committed:
43# (use "git reset HEAD <file>..." to unstage)
44#
45# new file: dir2/added
46#
47# Changed but not updated:
48# (use "git add <file>..." to update what will be committed)
4d6e4c4d 49# (use "git checkout -- <file>..." to discard changes in working directory)
367c9886
JS
50#
51# modified: dir1/modified
52#
53# Untracked files:
54# (use "git add <file>..." to include in what will be committed)
55#
56# dir1/untracked
57# dir2/modified
58# dir2/untracked
59# expect
60# output
61# untracked
62EOF
63
ff58b9aa 64test_expect_success 'status (2)' '
367c9886
JS
65
66 git status > output &&
3af82863 67 test_cmp expect output
367c9886
JS
68
69'
70
6c2ce048
MSO
71cat >expect <<EOF
72# On branch master
73# Changes to be committed:
74# (use "git reset HEAD <file>..." to unstage)
75#
76# new file: dir2/added
77#
78# Changed but not updated:
79# (use "git add <file>..." to update what will be committed)
4d6e4c4d 80# (use "git checkout -- <file>..." to discard changes in working directory)
6c2ce048
MSO
81#
82# modified: dir1/modified
83#
84# Untracked files not listed (use -u option to show untracked files)
85EOF
86test_expect_success 'status -uno' '
87 mkdir dir3 &&
88 : > dir3/untracked1 &&
89 : > dir3/untracked2 &&
90 git status -uno >output &&
91 test_cmp expect output
92'
93
d6293d1f
MSO
94test_expect_success 'status (status.showUntrackedFiles no)' '
95 git config status.showuntrackedfiles no
96 git status >output &&
97 test_cmp expect output
98'
99
4bfee30a
MSO
100cat >expect <<EOF
101# On branch master
102# Changes to be committed:
103# (use "git reset HEAD <file>..." to unstage)
104#
105# new file: dir2/added
106#
107# Changed but not updated:
108# (use "git add <file>..." to update what will be committed)
4d6e4c4d 109# (use "git checkout -- <file>..." to discard changes in working directory)
4bfee30a
MSO
110#
111# modified: dir1/modified
112#
113# Untracked files:
114# (use "git add <file>..." to include in what will be committed)
115#
116# dir1/untracked
117# dir2/modified
118# dir2/untracked
119# dir3/
120# expect
121# output
122# untracked
123EOF
124test_expect_success 'status -unormal' '
4bfee30a
MSO
125 git status -unormal >output &&
126 test_cmp expect output
127'
128
d6293d1f
MSO
129test_expect_success 'status (status.showUntrackedFiles normal)' '
130 git config status.showuntrackedfiles normal
131 git status >output &&
132 test_cmp expect output
133'
134
4bfee30a
MSO
135cat >expect <<EOF
136# On branch master
137# Changes to be committed:
138# (use "git reset HEAD <file>..." to unstage)
139#
140# new file: dir2/added
141#
142# Changed but not updated:
143# (use "git add <file>..." to update what will be committed)
4d6e4c4d 144# (use "git checkout -- <file>..." to discard changes in working directory)
4bfee30a
MSO
145#
146# modified: dir1/modified
147#
148# Untracked files:
149# (use "git add <file>..." to include in what will be committed)
150#
151# dir1/untracked
152# dir2/modified
153# dir2/untracked
154# dir3/untracked1
155# dir3/untracked2
156# expect
157# output
158# untracked
159EOF
160test_expect_success 'status -uall' '
161 git status -uall >output &&
d6293d1f
MSO
162 test_cmp expect output
163'
164test_expect_success 'status (status.showUntrackedFiles all)' '
165 git config status.showuntrackedfiles all
166 git status >output &&
4bfee30a 167 rm -rf dir3 &&
d6293d1f 168 git config --unset status.showuntrackedfiles &&
4bfee30a
MSO
169 test_cmp expect output
170'
171
367c9886
JS
172cat > expect << \EOF
173# On branch master
174# Changes to be committed:
175# (use "git reset HEAD <file>..." to unstage)
176#
177# new file: ../dir2/added
178#
179# Changed but not updated:
180# (use "git add <file>..." to update what will be committed)
4d6e4c4d 181# (use "git checkout -- <file>..." to discard changes in working directory)
367c9886 182#
69e74918 183# modified: modified
367c9886
JS
184#
185# Untracked files:
186# (use "git add <file>..." to include in what will be committed)
187#
188# untracked
189# ../dir2/modified
190# ../dir2/untracked
191# ../expect
192# ../output
193# ../untracked
194EOF
195
196test_expect_success 'status with relative paths' '
197
198 (cd dir1 && git status) > output &&
3af82863 199 test_cmp expect output
367c9886
JS
200
201'
202
46f721c8
JK
203cat > expect << \EOF
204# On branch master
205# Changes to be committed:
206# (use "git reset HEAD <file>..." to unstage)
207#
208# new file: dir2/added
209#
210# Changed but not updated:
211# (use "git add <file>..." to update what will be committed)
4d6e4c4d 212# (use "git checkout -- <file>..." to discard changes in working directory)
46f721c8
JK
213#
214# modified: dir1/modified
215#
216# Untracked files:
217# (use "git add <file>..." to include in what will be committed)
218#
219# dir1/untracked
220# dir2/modified
221# dir2/untracked
222# expect
223# output
224# untracked
225EOF
226
227test_expect_success 'status without relative paths' '
228
229 git config status.relativePaths false
230 (cd dir1 && git status) > output &&
3af82863 231 test_cmp expect output
46f721c8
JK
232
233'
234
959ba670
JK
235cat <<EOF >expect
236# On branch master
237# Changes to be committed:
238# (use "git reset HEAD <file>..." to unstage)
239#
240# modified: dir1/modified
241#
242# Untracked files:
243# (use "git add <file>..." to include in what will be committed)
244#
245# dir1/untracked
246# dir2/
247# expect
248# output
249# untracked
250EOF
9e4b7ab6
JH
251test_expect_success 'dry-run of partial commit excluding new file in index' '
252 git commit --dry-run dir1/modified >output &&
82ebb0b6 253 test_cmp expect output
959ba670
JK
254'
255
e5e4a7f2
PY
256test_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
264'
265
266cat >expect <<EOF
267# On branch master
268# Changes to be committed:
269# (use "git reset HEAD <file>..." to unstage)
270#
271# new file: dir2/added
272# new file: sm
273#
274# Changed but not updated:
275# (use "git add <file>..." to update what will be committed)
4d6e4c4d 276# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
277#
278# modified: dir1/modified
279#
280# Untracked files:
281# (use "git add <file>..." to include in what will be committed)
282#
283# dir1/untracked
284# dir2/modified
285# dir2/untracked
286# expect
287# output
288# untracked
289EOF
290test_expect_success 'status submodule summary is disabled by default' '
291 git status >output &&
292 test_cmp expect output
293'
294
98fa4738
JK
295# we expect the same as the previous test
296test_expect_success 'status --untracked-files=all does not show submodule' '
297 git status --untracked-files=all >output &&
e5e4a7f2
PY
298 test_cmp expect output
299'
300
301head=$(cd sm && git rev-parse --short=7 --verify HEAD)
302
303cat >expect <<EOF
304# On branch master
305# Changes to be committed:
306# (use "git reset HEAD <file>..." to unstage)
307#
308# new file: dir2/added
309# new file: sm
310#
311# Changed but not updated:
312# (use "git add <file>..." to update what will be committed)
4d6e4c4d 313# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
314#
315# modified: dir1/modified
316#
317# Modified submodules:
318#
319# * sm 0000000...$head (1):
320# > Add foo
321#
322# Untracked files:
323# (use "git add <file>..." to include in what will be committed)
324#
325# dir1/untracked
326# dir2/modified
327# dir2/untracked
328# expect
329# output
330# untracked
331EOF
332test_expect_success 'status submodule summary' '
333 git config status.submodulesummary 10 &&
334 git status >output &&
335 test_cmp expect output
336'
337
338
339cat >expect <<EOF
340# On branch master
341# Changed but not updated:
342# (use "git add <file>..." to update what will be committed)
4d6e4c4d 343# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
344#
345# modified: dir1/modified
346#
347# Untracked files:
348# (use "git add <file>..." to include in what will be committed)
349#
350# dir1/untracked
351# dir2/modified
352# dir2/untracked
353# expect
354# output
355# untracked
356no changes added to commit (use "git add" and/or "git commit -a")
357EOF
358test_expect_success 'status submodule summary (clean submodule)' '
359 git commit -m "commit submodule" &&
360 git config status.submodulesummary 10 &&
9e4b7ab6
JH
361 test_must_fail git commit --dry-run >output &&
362 test_cmp expect output &&
363 git status >output &&
e5e4a7f2
PY
364 test_cmp expect output
365'
366
367cat >expect <<EOF
368# On branch master
369# Changes to be committed:
370# (use "git reset HEAD^1 <file>..." to unstage)
371#
372# new file: dir2/added
373# new file: sm
374#
375# Changed but not updated:
376# (use "git add <file>..." to update what will be committed)
4d6e4c4d 377# (use "git checkout -- <file>..." to discard changes in working directory)
e5e4a7f2
PY
378#
379# modified: dir1/modified
380#
381# Modified submodules:
382#
383# * sm 0000000...$head (1):
384# > Add foo
385#
386# Untracked files:
387# (use "git add <file>..." to include in what will be committed)
388#
389# dir1/untracked
390# dir2/modified
391# dir2/untracked
392# expect
393# output
394# untracked
395EOF
9e4b7ab6 396test_expect_success 'commit --dry-run submodule summary (--amend)' '
e5e4a7f2 397 git config status.submodulesummary 10 &&
9e4b7ab6 398 git commit --dry-run --amend >output &&
e5e4a7f2
PY
399 test_cmp expect output
400'
401
367c9886 402test_done