]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7502-status.sh
git-commit.txt: Add missing long/short options
[thirdparty/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
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#
69e74918 80# modified: modified
367c9886
JS
81#
82# Untracked files:
83# (use "git add <file>..." to include in what will be committed)
84#
85# untracked
86# ../dir2/modified
87# ../dir2/untracked
88# ../expect
89# ../output
90# ../untracked
91EOF
92
93test_expect_success 'status with relative paths' '
94
95 (cd dir1 && git status) > output &&
3af82863 96 test_cmp expect output
367c9886
JS
97
98'
99
46f721c8
JK
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)
109#
110# modified: dir1/modified
111#
112# Untracked files:
113# (use "git add <file>..." to include in what will be committed)
114#
115# dir1/untracked
116# dir2/modified
117# dir2/untracked
118# expect
119# output
120# untracked
121EOF
122
123test_expect_success 'status without relative paths' '
124
125 git config status.relativePaths false
126 (cd dir1 && git status) > output &&
3af82863 127 test_cmp expect output
46f721c8
JK
128
129'
130
959ba670
JK
131cat <<EOF >expect
132# On branch master
133# Changes to be committed:
134# (use "git reset HEAD <file>..." to unstage)
135#
136# modified: dir1/modified
137#
138# Untracked files:
139# (use "git add <file>..." to include in what will be committed)
140#
141# dir1/untracked
142# dir2/
143# expect
144# output
145# untracked
146EOF
147test_expect_success 'status of partial commit excluding new file in index' '
148 git status dir1/modified >output &&
82ebb0b6 149 test_cmp expect output
959ba670
JK
150'
151
e5e4a7f2
PY
152test_expect_success 'setup status submodule summary' '
153 test_create_repo sm && (
154 cd sm &&
155 >foo &&
156 git add foo &&
157 git commit -m "Add foo"
158 ) &&
159 git add sm
160'
161
162cat >expect <<EOF
163# On branch master
164# Changes to be committed:
165# (use "git reset HEAD <file>..." to unstage)
166#
167# new file: dir2/added
168# new file: sm
169#
170# Changed but not updated:
171# (use "git add <file>..." to update what will be committed)
172#
173# modified: dir1/modified
174#
175# Untracked files:
176# (use "git add <file>..." to include in what will be committed)
177#
178# dir1/untracked
179# dir2/modified
180# dir2/untracked
181# expect
182# output
183# untracked
184EOF
185test_expect_success 'status submodule summary is disabled by default' '
186 git status >output &&
187 test_cmp expect output
188'
189
190head=$(cd sm && git rev-parse --short=7 --verify HEAD)
191
192cat >expect <<EOF
193# On branch master
194# Changes to be committed:
195# (use "git reset HEAD <file>..." to unstage)
196#
197# new file: dir2/added
198# new file: sm
199#
200# Changed but not updated:
201# (use "git add <file>..." to update what will be committed)
202#
203# modified: dir1/modified
204#
205# Modified submodules:
206#
207# * sm 0000000...$head (1):
208# > Add foo
209#
210# Untracked files:
211# (use "git add <file>..." to include in what will be committed)
212#
213# dir1/untracked
214# dir2/modified
215# dir2/untracked
216# expect
217# output
218# untracked
219EOF
220test_expect_success 'status submodule summary' '
221 git config status.submodulesummary 10 &&
222 git status >output &&
223 test_cmp expect output
224'
225
226
227cat >expect <<EOF
228# On branch master
229# Changed but not updated:
230# (use "git add <file>..." to update what will be committed)
231#
232# modified: dir1/modified
233#
234# Untracked files:
235# (use "git add <file>..." to include in what will be committed)
236#
237# dir1/untracked
238# dir2/modified
239# dir2/untracked
240# expect
241# output
242# untracked
243no changes added to commit (use "git add" and/or "git commit -a")
244EOF
245test_expect_success 'status submodule summary (clean submodule)' '
246 git commit -m "commit submodule" &&
247 git config status.submodulesummary 10 &&
248 test_must_fail git status >output &&
249 test_cmp expect output
250'
251
252cat >expect <<EOF
253# On branch master
254# Changes to be committed:
255# (use "git reset HEAD^1 <file>..." to unstage)
256#
257# new file: dir2/added
258# new file: sm
259#
260# Changed but not updated:
261# (use "git add <file>..." to update what will be committed)
262#
263# modified: dir1/modified
264#
265# Modified submodules:
266#
267# * sm 0000000...$head (1):
268# > Add foo
269#
270# Untracked files:
271# (use "git add <file>..." to include in what will be committed)
272#
273# dir1/untracked
274# dir2/modified
275# dir2/untracked
276# expect
277# output
278# untracked
279EOF
280test_expect_success 'status submodule summary (--amend)' '
281 git config status.submodulesummary 10 &&
282 git status --amend >output &&
283 test_cmp expect output
284'
285
367c9886 286test_done