3 # Copyright (c) 2008 Ping Yin
6 test_description
='Summary support for submodules implemented in git diff
8 This test tries to verify the sanity of --submodule-summary 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-summary 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-summary HEAD >actual &&
51 Submodule sm1 $head1..$head2:
56 test_expect_success
'modified submodule(forward)' "
57 git diff --submodule-summary >actual &&
59 Submodule sm1 $head1..$head2:
66 git
reset --hard HEAD~
2 >/dev
/null
&&
67 head3
=$
(git rev-parse
--verify HEAD | cut
-c1-7) &&
70 test_expect_success
'modified submodule(backward)' "
71 git diff-index -p --submodule-summary HEAD >actual &&
73 Submodule sm1 $head2..$head3 (rewind):
79 head4
=$
(add_file sm1 foo4 foo5
) &&
80 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
81 test_expect_success
'modified submodule(backward and forward)' "
82 git diff-index -p --submodule-summary HEAD >actual &&
84 Submodule sm1 $head2...$head4:
95 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
100 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
101 git diff --submodule-summary --cached >actual &&
103 Submodule sm1 41fbea9...0000000 (submodule deleted)
104 diff --git a/sm1 b/sm1
106 index 0000000..9da5fb8
114 test_expect_success
'typechanged submodule(submodule->blob)' "
115 git diff --submodule-summary >actual &&
117 diff --git a/sm1 b/sm1
118 deleted file mode 100644
119 index 9da5fb8..0000000
124 Submodule sm1 0000000...$head4 (new submodule)
129 git checkout-index sm1
130 test_expect_success
'typechanged submodule(submodule->blob)' "
131 git diff-index -p --submodule-summary HEAD >actual &&
133 Submodule sm1 $head4...0000000 (submodule deleted)
134 diff --git a/sm1 b/sm1
136 index 0000000..$head5
145 test_create_repo sm1
&&
146 head6
=$
(add_file sm1 foo6 foo7
)
147 test_expect_success
'nonexistent commit' "
148 git diff-index -p --submodule-summary HEAD >actual &&
150 Submodule sm1 $head4...$head6 (commits not present)
155 test_expect_success
'typechanged submodule(blob->submodule)' "
156 git diff-index -p --submodule-summary HEAD >actual &&
158 diff --git a/sm1 b/sm1
159 deleted file mode 100644
160 index $head5..0000000
165 Submodule sm1 0000000...$head6 (new submodule)
171 test_expect_success
'deleted submodule' "
172 git diff-index -p --submodule-summary HEAD >actual &&
174 Submodule sm1 $head6...0000000 (submodule deleted)
178 test_create_repo sm2
&&
179 head7
=$
(add_file sm2 foo8 foo9
) &&
182 test_expect_success
'multiple submodules' "
183 git diff-index -p --submodule-summary HEAD >actual &&
185 Submodule sm1 $head6...0000000 (submodule deleted)
186 Submodule sm2 0000000...$head7 (new submodule)
190 test_expect_success
'path filter' "
191 git diff-index -p --submodule-summary HEAD sm2 >actual &&
193 Submodule sm2 0000000...$head7 (new submodule)
198 test_expect_success
'given commit' "
199 git diff-index -p --submodule-summary HEAD^ >actual &&
201 Submodule sm1 $head6...0000000 (submodule deleted)
202 Submodule sm2 0000000...$head7 (new submodule)