3 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
6 test_description
='Support for verbose submodule differences in git diff
8 This test tries to verify the sanity of the --submodule option of git diff.
19 echo "$name" > "$name" &&
22 git commit
-m "Add $name"
24 git rev-parse
--verify HEAD | cut
-c1-7
29 git commit
"$@" -m "Commit $*" >/dev
/null
32 test_create_repo sm1
&&
33 add_file . foo
>/dev
/null
35 head1
=$
(add_file sm1 foo1 foo2
)
37 test_expect_success
'added submodule' "
39 git diff-index -p --submodule=log HEAD >actual &&
41 Submodule sm1 0000000...$head1 (new submodule)
46 head2
=$
(add_file sm1 foo3
)
48 test_expect_success
'modified submodule(forward)' "
49 git diff-index -p --submodule=log HEAD >actual &&
51 Submodule sm1 $head1..$head2:
56 test_expect_success
'modified submodule(forward)' "
57 git diff --submodule=log >actual &&
59 Submodule sm1 $head1..$head2:
64 test_expect_success
'modified submodule(forward) --submodule' "
65 git diff --submodule >actual &&
67 Submodule sm1 $head1..$head2:
72 fullhead1
=$
(cd sm1
; git rev-list
--max-count=1 $head1)
73 fullhead2
=$
(cd sm1
; git rev-list
--max-count=1 $head2)
74 test_expect_success
'modified submodule(forward) --submodule=short' "
75 git diff --submodule=short >actual &&
77 diff --git a/sm1 b/sm1
78 index $head1..$head2 160000
82 -Subproject commit $fullhead1
83 +Subproject commit $fullhead2
90 git
reset --hard HEAD~
2 >/dev
/null
&&
91 git rev-parse
--verify HEAD | cut
-c1-7
94 test_expect_success
'modified submodule(backward)' "
95 git diff-index -p --submodule=log HEAD >actual &&
97 Submodule sm1 $head2..$head3 (rewind):
103 head4
=$
(add_file sm1 foo4 foo5
) &&
104 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
105 test_expect_success
'modified submodule(backward and forward)' "
106 git diff-index -p --submodule=log HEAD >actual &&
108 Submodule sm1 $head2...$head4:
119 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
124 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
125 git diff --submodule=log --cached >actual &&
127 Submodule sm1 41fbea9...0000000 (submodule deleted)
128 diff --git a/sm1 b/sm1
130 index 0000000..9da5fb8
138 test_expect_success
'typechanged submodule(submodule->blob)' "
139 git diff --submodule=log >actual &&
141 diff --git a/sm1 b/sm1
142 deleted file mode 100644
143 index 9da5fb8..0000000
148 Submodule sm1 0000000...$head4 (new submodule)
153 git checkout-index sm1
154 test_expect_success
'typechanged submodule(submodule->blob)' "
155 git diff-index -p --submodule=log HEAD >actual &&
157 Submodule sm1 $head4...0000000 (submodule deleted)
158 diff --git a/sm1 b/sm1
160 index 0000000..$head5
169 test_create_repo sm1
&&
170 head6
=$
(add_file sm1 foo6 foo7
)
171 fullhead6
=$
(cd sm1
; git rev-list
--max-count=1 $head6)
172 test_expect_success
'nonexistent commit' "
173 git diff-index -p --submodule=log HEAD >actual &&
175 Submodule sm1 $head4...$head6 (commits not present)
180 test_expect_success
'typechanged submodule(blob->submodule)' "
181 git diff-index -p --submodule=log HEAD >actual &&
183 diff --git a/sm1 b/sm1
184 deleted file mode 100644
185 index $head5..0000000
190 Submodule sm1 0000000...$head6 (new submodule)
195 test_expect_success
'submodule is up to date' "
196 git diff-index -p --submodule=log HEAD >actual &&
201 test_expect_success
'submodule contains untracked content' "
202 echo new > sm1/new-file &&
203 git diff-index -p --submodule=log HEAD >actual &&
205 Submodule sm1 contains untracked content
209 test_expect_success
'submodule contains untracked content (untracked ignored)' "
210 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
214 test_expect_success
'submodule contains untracked content (dirty ignored)' "
215 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
219 test_expect_success
'submodule contains untracked content (all ignored)' "
220 git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
224 test_expect_success
'submodule contains untracked and modifed content' "
225 echo new > sm1/foo6 &&
226 git diff-index -p --submodule=log HEAD >actual &&
228 Submodule sm1 contains untracked content
229 Submodule sm1 contains modified content
233 test_expect_success
'submodule contains untracked and modifed content (untracked ignored)' "
234 echo new > sm1/foo6 &&
235 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
237 Submodule sm1 contains modified content
241 test_expect_success
'submodule contains untracked and modifed content (dirty ignored)' "
242 echo new > sm1/foo6 &&
243 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
247 test_expect_success
'submodule contains untracked and modifed content (all ignored)' "
248 echo new > sm1/foo6 &&
249 git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
253 test_expect_success
'submodule contains modifed content' "
254 rm -f sm1/new-file &&
255 git diff-index -p --submodule=log HEAD >actual &&
257 Submodule sm1 contains modified content
261 (cd sm1
; git commit
-mchange foo6
>/dev
/null
) &&
262 head8
=$
(cd sm1
; git rev-parse
--verify HEAD | cut
-c1-7) &&
263 test_expect_success
'submodule is modified' "
264 git diff-index -p --submodule=log HEAD >actual &&
266 Submodule sm1 $head6..$head8:
271 test_expect_success
'modified submodule contains untracked content' "
272 echo new > sm1/new-file &&
273 git diff-index -p --submodule=log HEAD >actual &&
275 Submodule sm1 contains untracked content
276 Submodule sm1 $head6..$head8:
281 test_expect_success
'modified submodule contains untracked content (untracked ignored)' "
282 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
284 Submodule sm1 $head6..$head8:
289 test_expect_success
'modified submodule contains untracked content (dirty ignored)' "
290 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
292 Submodule sm1 $head6..$head8:
297 test_expect_success
'modified submodule contains untracked content (all ignored)' "
298 git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
302 test_expect_success
'modified submodule contains untracked and modifed content' "
303 echo modification >> sm1/foo6 &&
304 git diff-index -p --submodule=log HEAD >actual &&
306 Submodule sm1 contains untracked content
307 Submodule sm1 contains modified content
308 Submodule sm1 $head6..$head8:
313 test_expect_success
'modified submodule contains untracked and modifed content (untracked ignored)' "
314 echo modification >> sm1/foo6 &&
315 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
317 Submodule sm1 contains modified content
318 Submodule sm1 $head6..$head8:
323 test_expect_success
'modified submodule contains untracked and modifed content (dirty ignored)' "
324 echo modification >> sm1/foo6 &&
325 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
327 Submodule sm1 $head6..$head8:
332 test_expect_success
'modified submodule contains untracked and modifed content (all ignored)' "
333 echo modification >> sm1/foo6 &&
334 git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
338 test_expect_success
'modified submodule contains modifed content' "
339 rm -f sm1/new-file &&
340 git diff-index -p --submodule=log HEAD >actual &&
342 Submodule sm1 contains modified content
343 Submodule sm1 $head6..$head8:
349 test_expect_success
'deleted submodule' "
350 git diff-index -p --submodule=log HEAD >actual &&
352 Submodule sm1 $head6...0000000 (submodule deleted)
356 test_create_repo sm2
&&
357 head7
=$
(add_file sm2 foo8 foo9
) &&
360 test_expect_success
'multiple submodules' "
361 git diff-index -p --submodule=log HEAD >actual &&
363 Submodule sm1 $head6...0000000 (submodule deleted)
364 Submodule sm2 0000000...$head7 (new submodule)
368 test_expect_success
'path filter' "
369 git diff-index -p --submodule=log HEAD sm2 >actual &&
371 Submodule sm2 0000000...$head7 (new submodule)
376 test_expect_success
'given commit' "
377 git diff-index -p --submodule=log HEAD^ >actual &&
379 Submodule sm1 $head6...0000000 (submodule deleted)
380 Submodule sm2 0000000...$head7 (new submodule)
384 test_expect_success
'given commit --submodule' "
385 git diff-index -p --submodule HEAD^ >actual &&
387 Submodule sm1 $head6...0000000 (submodule deleted)
388 Submodule sm2 0000000...$head7 (new submodule)
392 fullhead7
=$
(cd sm2
; git rev-list
--max-count=1 $head7)
394 test_expect_success
'given commit --submodule=short' "
395 git diff-index -p --submodule=short HEAD^ >actual &&
397 diff --git a/sm1 b/sm1
398 deleted file mode 160000
399 index $head6..0000000
403 -Subproject commit $fullhead6
404 diff --git a/sm2 b/sm2
406 index 0000000..$head7
410 +Subproject commit $fullhead7
414 test_expect_success
'setup .git file for sm2' '
416 REAL="$(pwd)/../.real" &&
418 echo "gitdir: $REAL" >.git)
421 test_expect_success
'diff --submodule with .git file' '
422 git diff --submodule HEAD^ >actual &&
424 Submodule sm1 $head6...0000000 (submodule deleted)
425 Submodule sm2 0000000...$head7 (new submodule)