Add an optional <mode> argument to commit/status -u|--untracked-files option
[git/git.git] / t / t7502-status.sh
CommitLineData
367c9886
JS
1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
6test_description='git-status'
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)
49#
50# modified: dir1/modified
51#
52# Untracked files:
53# (use "git add <file>..." to include in what will be committed)
54#
55# dir1/untracked
56# dir2/modified
57# dir2/untracked
58# expect
59# output
60# untracked
61EOF
62
ff58b9aa 63test_expect_success 'status (2)' '
367c9886
JS
64
65 git status > output &&
3af82863 66 test_cmp expect output
367c9886
JS
67
68'
69
4bfee30a
MSO
70cat >expect <<EOF
71# On branch master
72# Changes to be committed:
73# (use "git reset HEAD <file>..." to unstage)
74#
75# new file: dir2/added
76#
77# Changed but not updated:
78# (use "git add <file>..." to update what will be committed)
79#
80# modified: dir1/modified
81#
82# Untracked files:
83# (use "git add <file>..." to include in what will be committed)
84#
85# dir1/untracked
86# dir2/modified
87# dir2/untracked
88# dir3/
89# expect
90# output
91# untracked
92EOF
93test_expect_success 'status -unormal' '
94 mkdir dir3 &&
95 : > dir3/untracked1 &&
96 : > dir3/untracked2 &&
97 git status -unormal >output &&
98 test_cmp expect output
99'
100
101cat >expect <<EOF
102# On branch master
103# Changes to be committed:
104# (use "git reset HEAD <file>..." to unstage)
105#
106# new file: dir2/added
107#
108# Changed but not updated:
109# (use "git add <file>..." to update what will be committed)
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/untracked1
120# dir3/untracked2
121# expect
122# output
123# untracked
124EOF
125test_expect_success 'status -uall' '
126 git status -uall >output &&
127 rm -rf dir3 &&
128 test_cmp expect output
129'
130
367c9886
JS
131cat > expect << \EOF
132# On branch master
133# Changes to be committed:
134# (use "git reset HEAD <file>..." to unstage)
135#
136# new file: ../dir2/added
137#
138# Changed but not updated:
139# (use "git add <file>..." to update what will be committed)
140#
69e74918 141# modified: modified
367c9886
JS
142#
143# Untracked files:
144# (use "git add <file>..." to include in what will be committed)
145#
146# untracked
147# ../dir2/modified
148# ../dir2/untracked
149# ../expect
150# ../output
151# ../untracked
152EOF
153
154test_expect_success 'status with relative paths' '
155
156 (cd dir1 && git status) > output &&
3af82863 157 test_cmp expect output
367c9886
JS
158
159'
160
46f721c8
JK
161cat > expect << \EOF
162# On branch master
163# Changes to be committed:
164# (use "git reset HEAD <file>..." to unstage)
165#
166# new file: dir2/added
167#
168# Changed but not updated:
169# (use "git add <file>..." to update what will be committed)
170#
171# modified: dir1/modified
172#
173# Untracked files:
174# (use "git add <file>..." to include in what will be committed)
175#
176# dir1/untracked
177# dir2/modified
178# dir2/untracked
179# expect
180# output
181# untracked
182EOF
183
184test_expect_success 'status without relative paths' '
185
186 git config status.relativePaths false
187 (cd dir1 && git status) > output &&
3af82863 188 test_cmp expect output
46f721c8
JK
189
190'
191
959ba670
JK
192cat <<EOF >expect
193# On branch master
194# Changes to be committed:
195# (use "git reset HEAD <file>..." to unstage)
196#
197# modified: dir1/modified
198#
199# Untracked files:
200# (use "git add <file>..." to include in what will be committed)
201#
202# dir1/untracked
203# dir2/
204# expect
205# output
206# untracked
207EOF
208test_expect_success 'status of partial commit excluding new file in index' '
209 git status dir1/modified >output &&
82ebb0b6 210 test_cmp expect output
959ba670
JK
211'
212
e5e4a7f2
PY
213test_expect_success 'setup status submodule summary' '
214 test_create_repo sm && (
215 cd sm &&
216 >foo &&
217 git add foo &&
218 git commit -m "Add foo"
219 ) &&
220 git add sm
221'
222
223cat >expect <<EOF
224# On branch master
225# Changes to be committed:
226# (use "git reset HEAD <file>..." to unstage)
227#
228# new file: dir2/added
229# new file: sm
230#
231# Changed but not updated:
232# (use "git add <file>..." to update what will be committed)
233#
234# modified: dir1/modified
235#
236# Untracked files:
237# (use "git add <file>..." to include in what will be committed)
238#
239# dir1/untracked
240# dir2/modified
241# dir2/untracked
242# expect
243# output
244# untracked
245EOF
246test_expect_success 'status submodule summary is disabled by default' '
247 git status >output &&
248 test_cmp expect output
249'
250
251head=$(cd sm && git rev-parse --short=7 --verify HEAD)
252
253cat >expect <<EOF
254# On branch master
255# Changes to be committed:
256# (use "git reset HEAD <file>..." to unstage)
257#
258# new file: dir2/added
259# new file: sm
260#
261# Changed but not updated:
262# (use "git add <file>..." to update what will be committed)
263#
264# modified: dir1/modified
265#
266# Modified submodules:
267#
268# * sm 0000000...$head (1):
269# > Add foo
270#
271# Untracked files:
272# (use "git add <file>..." to include in what will be committed)
273#
274# dir1/untracked
275# dir2/modified
276# dir2/untracked
277# expect
278# output
279# untracked
280EOF
281test_expect_success 'status submodule summary' '
282 git config status.submodulesummary 10 &&
283 git status >output &&
284 test_cmp expect output
285'
286
287
288cat >expect <<EOF
289# On branch master
290# Changed but not updated:
291# (use "git add <file>..." to update what will be committed)
292#
293# modified: dir1/modified
294#
295# Untracked files:
296# (use "git add <file>..." to include in what will be committed)
297#
298# dir1/untracked
299# dir2/modified
300# dir2/untracked
301# expect
302# output
303# untracked
304no changes added to commit (use "git add" and/or "git commit -a")
305EOF
306test_expect_success 'status submodule summary (clean submodule)' '
307 git commit -m "commit submodule" &&
308 git config status.submodulesummary 10 &&
309 test_must_fail git status >output &&
310 test_cmp expect output
311'
312
313cat >expect <<EOF
314# On branch master
315# Changes to be committed:
316# (use "git reset HEAD^1 <file>..." to unstage)
317#
318# new file: dir2/added
319# new file: sm
320#
321# Changed but not updated:
322# (use "git add <file>..." to update what will be committed)
323#
324# modified: dir1/modified
325#
326# Modified submodules:
327#
328# * sm 0000000...$head (1):
329# > Add foo
330#
331# Untracked files:
332# (use "git add <file>..." to include in what will be committed)
333#
334# dir1/untracked
335# dir2/modified
336# dir2/untracked
337# expect
338# output
339# untracked
340EOF
341test_expect_success 'status submodule summary (--amend)' '
342 git config status.submodulesummary 10 &&
343 git status --amend >output &&
344 test_cmp expect output
345'
346
367c9886 347test_done