Code

Add an optional <mode> argument to commit/status -u|--untracked-files option
[git.git] / t / t7502-status.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Johannes E. Schindelin
4 #
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
32 '
34 test_expect_success 'status (1)' '
36         grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
38 '
40 cat > 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
61 EOF
63 test_expect_success 'status (2)' '
65         git status > output &&
66         test_cmp expect output
68 '
70 cat >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
92 EOF
93 test_expect_success 'status -unormal' '
94         mkdir dir3 &&
95         : > dir3/untracked1 &&
96         : > dir3/untracked2 &&
97         git status -unormal >output &&
98         test_cmp expect output
99 '
101 cat >expect <<EOF
102 # On branch master
103 # Changes to be committed:
104 #   (use "git reset HEAD <file>..." to unstage)
106 #       new file:   dir2/added
108 # Changed but not updated:
109 #   (use "git add <file>..." to update what will be committed)
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/untracked1
120 #       dir3/untracked2
121 #       expect
122 #       output
123 #       untracked
124 EOF
125 test_expect_success 'status -uall' '
126         git status -uall >output &&
127         rm -rf dir3 &&
128         test_cmp expect output
131 cat > expect << \EOF
132 # On branch master
133 # Changes to be committed:
134 #   (use "git reset HEAD <file>..." to unstage)
136 #       new file:   ../dir2/added
138 # Changed but not updated:
139 #   (use "git add <file>..." to update what will be committed)
141 #       modified:   modified
143 # Untracked files:
144 #   (use "git add <file>..." to include in what will be committed)
146 #       untracked
147 #       ../dir2/modified
148 #       ../dir2/untracked
149 #       ../expect
150 #       ../output
151 #       ../untracked
152 EOF
154 test_expect_success 'status with relative paths' '
156         (cd dir1 && git status) > output &&
157         test_cmp expect output
161 cat > expect << \EOF
162 # On branch master
163 # Changes to be committed:
164 #   (use "git reset HEAD <file>..." to unstage)
166 #       new file:   dir2/added
168 # Changed but not updated:
169 #   (use "git add <file>..." to update what will be committed)
171 #       modified:   dir1/modified
173 # Untracked files:
174 #   (use "git add <file>..." to include in what will be committed)
176 #       dir1/untracked
177 #       dir2/modified
178 #       dir2/untracked
179 #       expect
180 #       output
181 #       untracked
182 EOF
184 test_expect_success 'status without relative paths' '
186         git config status.relativePaths false
187         (cd dir1 && git status) > output &&
188         test_cmp expect output
192 cat <<EOF >expect
193 # On branch master
194 # Changes to be committed:
195 #   (use "git reset HEAD <file>..." to unstage)
197 #       modified:   dir1/modified
199 # Untracked files:
200 #   (use "git add <file>..." to include in what will be committed)
202 #       dir1/untracked
203 #       dir2/
204 #       expect
205 #       output
206 #       untracked
207 EOF
208 test_expect_success 'status of partial commit excluding new file in index' '
209         git status dir1/modified >output &&
210         test_cmp expect output
213 test_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
223 cat >expect <<EOF
224 # On branch master
225 # Changes to be committed:
226 #   (use "git reset HEAD <file>..." to unstage)
228 #       new file:   dir2/added
229 #       new file:   sm
231 # Changed but not updated:
232 #   (use "git add <file>..." to update what will be committed)
234 #       modified:   dir1/modified
236 # Untracked files:
237 #   (use "git add <file>..." to include in what will be committed)
239 #       dir1/untracked
240 #       dir2/modified
241 #       dir2/untracked
242 #       expect
243 #       output
244 #       untracked
245 EOF
246 test_expect_success 'status submodule summary is disabled by default' '
247         git status >output &&
248         test_cmp expect output
251 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
253 cat >expect <<EOF
254 # On branch master
255 # Changes to be committed:
256 #   (use "git reset HEAD <file>..." to unstage)
258 #       new file:   dir2/added
259 #       new file:   sm
261 # Changed but not updated:
262 #   (use "git add <file>..." to update what will be committed)
264 #       modified:   dir1/modified
266 # Modified submodules:
268 # * sm 0000000...$head (1):
269 #   > Add foo
271 # Untracked files:
272 #   (use "git add <file>..." to include in what will be committed)
274 #       dir1/untracked
275 #       dir2/modified
276 #       dir2/untracked
277 #       expect
278 #       output
279 #       untracked
280 EOF
281 test_expect_success 'status submodule summary' '
282         git config status.submodulesummary 10 &&
283         git status >output &&
284         test_cmp expect output
288 cat >expect <<EOF
289 # On branch master
290 # Changed but not updated:
291 #   (use "git add <file>..." to update what will be committed)
293 #       modified:   dir1/modified
295 # Untracked files:
296 #   (use "git add <file>..." to include in what will be committed)
298 #       dir1/untracked
299 #       dir2/modified
300 #       dir2/untracked
301 #       expect
302 #       output
303 #       untracked
304 no changes added to commit (use "git add" and/or "git commit -a")
305 EOF
306 test_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
313 cat >expect <<EOF
314 # On branch master
315 # Changes to be committed:
316 #   (use "git reset HEAD^1 <file>..." to unstage)
318 #       new file:   dir2/added
319 #       new file:   sm
321 # Changed but not updated:
322 #   (use "git add <file>..." to update what will be committed)
324 #       modified:   dir1/modified
326 # Modified submodules:
328 # * sm 0000000...$head (1):
329 #   > Add foo
331 # Untracked files:
332 #   (use "git add <file>..." to include in what will be committed)
334 #       dir1/untracked
335 #       dir2/modified
336 #       dir2/untracked
337 #       expect
338 #       output
339 #       untracked
340 EOF
341 test_expect_success 'status submodule summary (--amend)' '
342         git config status.submodulesummary 10 &&
343         git status --amend >output &&
344         test_cmp expect output
347 test_done