Use diff -w on Windows to ignore CRLF.
[git/mingw.git] / t / t7502-status.sh
blobededff28ad09115bb1a0cfa551936562db0870cd
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)
54 # modified: dir1/modified
56 # Untracked files:
57 # (use "git add <file>..." to include in what will be committed)
59 # dir1/untracked
60 # dir2/modified
61 # dir2/untracked
62 # expect
63 # output
64 # untracked
65 EOF
67 test_expect_success 'status (2)' '
69 git status > output &&
70 git diff expect output
74 cat > expect << \EOF
75 # On branch master
76 # Changes to be committed:
77 # (use "git reset HEAD <file>..." to unstage)
79 # new file: ../dir2/added
81 # Changed but not updated:
82 # (use "git add <file>..." to update what will be committed)
84 # modified: modified
86 # Untracked files:
87 # (use "git add <file>..." to include in what will be committed)
89 # untracked
90 # ../dir2/modified
91 # ../dir2/untracked
92 # ../expect
93 # ../output
94 # ../untracked
95 EOF
97 test_expect_success 'status with relative paths' '
99 (cd dir1 && git status) > output &&
100 git diff 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)
114 # modified: dir1/modified
116 # Untracked files:
117 # (use "git add <file>..." to include in what will be committed)
119 # dir1/untracked
120 # dir2/modified
121 # dir2/untracked
122 # expect
123 # output
124 # untracked
127 test_expect_success 'status without relative paths' '
129 git config status.relativePaths false
130 (cd dir1 && git status) > output &&
131 git diff expect output
135 cat <<EOF >expect
136 # On branch master
137 # Changes to be committed:
138 # (use "git reset HEAD <file>..." to unstage)
140 # modified: dir1/modified
142 # Untracked files:
143 # (use "git add <file>..." to include in what will be committed)
145 # dir1/untracked
146 # dir2/
147 # expect
148 # output
149 # untracked
151 test_expect_success 'status of partial commit excluding new file in index' '
152 git status dir1/modified >output &&
153 test_cmp expect output
156 test_expect_success 'setup status submodule summary' '
157 test_create_repo sm && (
158 cd sm &&
159 >foo &&
160 git add foo &&
161 git commit -m "Add foo"
162 ) &&
163 git add sm
166 cat >expect <<EOF
167 # On branch master
168 # Changes to be committed:
169 # (use "git reset HEAD <file>..." to unstage)
171 # new file: dir2/added
172 # new file: sm
174 # Changed but not updated:
175 # (use "git add <file>..." to update what will be committed)
177 # modified: dir1/modified
179 # Untracked files:
180 # (use "git add <file>..." to include in what will be committed)
182 # dir1/untracked
183 # dir2/modified
184 # dir2/untracked
185 # expect
186 # output
187 # untracked
189 test_expect_success 'status submodule summary is disabled by default' '
190 git status >output &&
191 test_cmp expect output
194 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
196 cat >expect <<EOF
197 # On branch master
198 # Changes to be committed:
199 # (use "git reset HEAD <file>..." to unstage)
201 # new file: dir2/added
202 # new file: sm
204 # Changed but not updated:
205 # (use "git add <file>..." to update what will be committed)
207 # modified: dir1/modified
209 # Modified submodules:
211 # * sm 0000000...$head (1):
212 # > Add foo
214 # Untracked files:
215 # (use "git add <file>..." to include in what will be committed)
217 # dir1/untracked
218 # dir2/modified
219 # dir2/untracked
220 # expect
221 # output
222 # untracked
224 test_expect_success 'status submodule summary' '
225 git config status.submodulesummary 10 &&
226 git status >output &&
227 test_cmp expect output
231 cat >expect <<EOF
232 # On branch master
233 # Changed but not updated:
234 # (use "git add <file>..." to update what will be committed)
236 # modified: dir1/modified
238 # Untracked files:
239 # (use "git add <file>..." to include in what will be committed)
241 # dir1/untracked
242 # dir2/modified
243 # dir2/untracked
244 # expect
245 # output
246 # untracked
247 no changes added to commit (use "git add" and/or "git commit -a")
249 test_expect_success 'status submodule summary (clean submodule)' '
250 git commit -m "commit submodule" &&
251 git config status.submodulesummary 10 &&
252 test_must_fail git status >output &&
253 test_cmp expect output
256 cat >expect <<EOF
257 # On branch master
258 # Changes to be committed:
259 # (use "git reset HEAD^1 <file>..." to unstage)
261 # new file: dir2/added
262 # new file: sm
264 # Changed but not updated:
265 # (use "git add <file>..." to update what will be committed)
267 # modified: dir1/modified
269 # Modified submodules:
271 # * sm 0000000...$head (1):
272 # > Add foo
274 # Untracked files:
275 # (use "git add <file>..." to include in what will be committed)
277 # dir1/untracked
278 # dir2/modified
279 # dir2/untracked
280 # expect
281 # output
282 # untracked
284 test_expect_success 'status submodule summary (--amend)' '
285 git config status.submodulesummary 10 &&
286 git status --amend >output &&
287 test_cmp expect output
290 test_done