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
89 git
reset --hard HEAD~
2 >/dev
/null
&&
90 head3
=$
(git rev-parse
--verify HEAD | cut
-c1-7) &&
93 test_expect_success
'modified submodule(backward)' "
94 git diff-index -p --submodule=log HEAD >actual &&
96 Submodule sm1 $head2..$head3 (rewind):
102 head4
=$
(add_file sm1 foo4 foo5
) &&
103 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
104 test_expect_success
'modified submodule(backward and forward)' "
105 git diff-index -p --submodule=log HEAD >actual &&
107 Submodule sm1 $head2...$head4:
118 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
123 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
124 git diff --submodule=log --cached >actual &&
126 Submodule sm1 41fbea9...0000000 (submodule deleted)
127 diff --git a/sm1 b/sm1
129 index 0000000..9da5fb8
137 test_expect_success
'typechanged submodule(submodule->blob)' "
138 git diff --submodule=log >actual &&
140 diff --git a/sm1 b/sm1
141 deleted file mode 100644
142 index 9da5fb8..0000000
147 Submodule sm1 0000000...$head4 (new submodule)
152 git checkout-index sm1
153 test_expect_success
'typechanged submodule(submodule->blob)' "
154 git diff-index -p --submodule=log HEAD >actual &&
156 Submodule sm1 $head4...0000000 (submodule deleted)
157 diff --git a/sm1 b/sm1
159 index 0000000..$head5
168 test_create_repo sm1
&&
169 head6
=$
(add_file sm1 foo6 foo7
)
170 fullhead6
=$
(cd sm1
; git rev-list
--max-count=1 $head6)
171 test_expect_success
'nonexistent commit' "
172 git diff-index -p --submodule=log HEAD >actual &&
174 Submodule sm1 $head4...$head6 (commits not present)
179 test_expect_success
'typechanged submodule(blob->submodule)' "
180 git diff-index -p --submodule=log HEAD >actual &&
182 diff --git a/sm1 b/sm1
183 deleted file mode 100644
184 index $head5..0000000
189 Submodule sm1 0000000...$head6 (new submodule)
194 test_expect_success
'submodule is up to date' "
195 git diff-index -p --submodule=log HEAD >actual &&
200 test_expect_success
'submodule contains untracked content' "
201 echo new > sm1/new-file &&
202 git diff-index -p --submodule=log HEAD >actual &&
204 Submodule sm1 contains untracked content
208 test_expect_success
'submodule contains untracked content (untracked ignored)' "
209 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
213 test_expect_success
'submodule contains untracked content (dirty ignored)' "
214 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
218 test_expect_success
'submodule contains untracked content (all ignored)' "
219 git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
223 test_expect_success
'submodule contains untracked and modifed content' "
224 echo new > sm1/foo6 &&
225 git diff-index -p --submodule=log HEAD >actual &&
227 Submodule sm1 contains untracked content
228 Submodule sm1 contains modified content
232 test_expect_success
'submodule contains untracked and modifed content (untracked ignored)' "
233 echo new > sm1/foo6 &&
234 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
236 Submodule sm1 contains modified content
240 test_expect_success
'submodule contains untracked and modifed content (dirty ignored)' "
241 echo new > sm1/foo6 &&
242 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
246 test_expect_success
'submodule contains untracked and modifed content (all ignored)' "
247 echo new > sm1/foo6 &&
248 git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
252 test_expect_success
'submodule contains modifed content' "
253 rm -f sm1/new-file &&
254 git diff-index -p --submodule=log HEAD >actual &&
256 Submodule sm1 contains modified content
260 (cd sm1
; git commit
-mchange foo6
>/dev
/null
) &&
261 head8
=$
(cd sm1
; git rev-parse
--verify HEAD | cut
-c1-7) &&
262 test_expect_success
'submodule is modified' "
263 git diff-index -p --submodule=log HEAD >actual &&
265 Submodule sm1 $head6..$head8:
270 test_expect_success
'modified submodule contains untracked content' "
271 echo new > sm1/new-file &&
272 git diff-index -p --submodule=log HEAD >actual &&
274 Submodule sm1 contains untracked content
275 Submodule sm1 $head6..$head8:
280 test_expect_success
'modified submodule contains untracked content (untracked ignored)' "
281 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
283 Submodule sm1 $head6..$head8:
288 test_expect_success
'modified submodule contains untracked content (dirty ignored)' "
289 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
291 Submodule sm1 $head6..$head8:
296 test_expect_success
'modified submodule contains untracked content (all ignored)' "
297 git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
301 test_expect_success
'modified submodule contains untracked and modifed content' "
302 echo modification >> sm1/foo6 &&
303 git diff-index -p --submodule=log HEAD >actual &&
305 Submodule sm1 contains untracked content
306 Submodule sm1 contains modified content
307 Submodule sm1 $head6..$head8:
312 test_expect_success
'modified submodule contains untracked and modifed content (untracked ignored)' "
313 echo modification >> sm1/foo6 &&
314 git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
316 Submodule sm1 contains modified content
317 Submodule sm1 $head6..$head8:
322 test_expect_success
'modified submodule contains untracked and modifed content (dirty ignored)' "
323 echo modification >> sm1/foo6 &&
324 git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
326 Submodule sm1 $head6..$head8:
331 test_expect_success
'modified submodule contains untracked and modifed content (all ignored)' "
332 echo modification >> sm1/foo6 &&
333 git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
337 test_expect_success
'modified submodule contains modifed content' "
338 rm -f sm1/new-file &&
339 git diff-index -p --submodule=log HEAD >actual &&
341 Submodule sm1 contains modified content
342 Submodule sm1 $head6..$head8:
348 test_expect_success
'deleted submodule' "
349 git diff-index -p --submodule=log HEAD >actual &&
351 Submodule sm1 $head6...0000000 (submodule deleted)
355 test_create_repo sm2
&&
356 head7
=$
(add_file sm2 foo8 foo9
) &&
359 test_expect_success
'multiple submodules' "
360 git diff-index -p --submodule=log HEAD >actual &&
362 Submodule sm1 $head6...0000000 (submodule deleted)
363 Submodule sm2 0000000...$head7 (new submodule)
367 test_expect_success
'path filter' "
368 git diff-index -p --submodule=log HEAD sm2 >actual &&
370 Submodule sm2 0000000...$head7 (new submodule)
375 test_expect_success
'given commit' "
376 git diff-index -p --submodule=log HEAD^ >actual &&
378 Submodule sm1 $head6...0000000 (submodule deleted)
379 Submodule sm2 0000000...$head7 (new submodule)
383 test_expect_success
'given commit --submodule' "
384 git diff-index -p --submodule HEAD^ >actual &&
386 Submodule sm1 $head6...0000000 (submodule deleted)
387 Submodule sm2 0000000...$head7 (new submodule)
391 fullhead7
=$
(cd sm2
; git rev-list
--max-count=1 $head7)
393 test_expect_success
'given commit --submodule=short' "
394 git diff-index -p --submodule=short HEAD^ >actual &&
396 diff --git a/sm1 b/sm1
397 deleted file mode 160000
398 index $head6..0000000
402 -Subproject commit $fullhead6
403 diff --git a/sm2 b/sm2
405 index 0000000..$head7
409 +Subproject commit $fullhead7
413 test_expect_success
'setup .git file for sm2' '
415 REAL="$(pwd)/../.real" &&
417 echo "gitdir: $REAL" >.git)
420 test_expect_success
'diff --submodule with .git file' '
421 git diff --submodule HEAD^ >actual &&
423 Submodule sm1 $head6...0000000 (submodule deleted)
424 Submodule sm2 0000000...$head7 (new submodule)