3 # Copyright (c) 2008 Ping Yin
6 test_description
='Summary support for submodules
8 This test tries to verify the sanity of summary subcommand of git submodule.
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 submodule summary >actual &&
40 cat >expected <<-EOF &&
41 * sm1 0000000...$head1 (2):
45 test_cmp expected actual
48 test_expect_success
'added submodule (subdirectory)' "
52 git submodule summary >../actual
54 cat >expected <<-EOF &&
55 * ../sm1 0000000...$head1 (2):
59 test_cmp expected actual
62 test_expect_success
'added submodule (subdirectory only)' "
65 git submodule summary . >../actual
68 test_cmp expected actual
71 test_expect_success
'added submodule (subdirectory with explicit path)' "
74 git submodule summary ../sm1 >../actual
76 cat >expected <<-EOF &&
77 * ../sm1 0000000...$head1 (2):
81 test_cmp expected actual
85 head2
=$
(add_file sm1 foo3
)
87 test_expect_success
'modified submodule(forward)' "
88 git submodule summary >actual &&
89 cat >expected <<-EOF &&
90 * sm1 $head1...$head2 (1):
94 test_cmp expected actual
97 test_expect_success
'modified submodule(forward), --files' "
98 git submodule summary --files >actual &&
99 cat >expected <<-EOF &&
100 * sm1 $head1...$head2 (1):
104 test_cmp expected actual
110 git
reset --hard HEAD~
2 >/dev
/null
&&
111 git rev-parse
--verify HEAD | cut
-c1-7
114 test_expect_success
'modified submodule(backward)' "
115 git submodule summary >actual &&
116 cat >expected <<-EOF &&
117 * sm1 $head2...$head3 (2):
122 test_cmp expected actual
125 head4
=$
(add_file sm1 foo4 foo5
) &&
126 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
127 test_expect_success
'modified submodule(backward and forward)' "
128 git submodule summary >actual &&
129 cat >expected <<-EOF &&
130 * sm1 $head2...$head4 (4):
137 test_cmp expected actual
140 test_expect_success
'--summary-limit' "
141 git submodule summary -n 3 >actual &&
142 cat >expected <<-EOF &&
143 * sm1 $head2...$head4 (4):
149 test_cmp expected actual
155 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
160 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
161 git submodule summary --cached >actual &&
162 cat >expected <<-EOF &&
163 * sm1 $head4(submodule)->$head5(blob) (3):
167 test_i18ncmp actual expected
170 test_expect_success
'typechanged submodule(submodule->blob), --files' "
171 git submodule summary --files >actual &&
172 cat >expected <<-EOF &&
173 * sm1 $head5(blob)->$head4(submodule) (3):
177 test_i18ncmp actual expected
181 git checkout-index sm1
182 test_expect_success
'typechanged submodule(submodule->blob)' "
183 git submodule summary >actual &&
184 cat >expected <<-EOF &&
185 * sm1 $head4(submodule)->$head5(blob):
188 test_i18ncmp actual expected
192 test_create_repo sm1
&&
193 head6
=$
(add_file sm1 foo6 foo7
)
194 test_expect_success
'nonexistent commit' "
195 git submodule summary >actual &&
196 cat >expected <<-EOF &&
197 * sm1 $head4...$head6:
198 Warn: sm1 doesn't contain commit $head4_full
201 test_i18ncmp actual expected
205 test_expect_success
'typechanged submodule(blob->submodule)' "
206 git submodule summary >actual &&
207 cat >expected <<-EOF &&
208 * sm1 $head5(blob)->$head6(submodule) (2):
212 test_i18ncmp expected actual
217 test_expect_success
'deleted submodule' "
218 git submodule summary >actual &&
219 cat >expected <<-EOF &&
220 * sm1 $head6...0000000:
223 test_cmp expected actual
226 test_create_repo sm2
&&
227 head7
=$
(add_file sm2 foo8 foo9
) &&
230 test_expect_success
'multiple submodules' "
231 git submodule summary >actual &&
232 cat >expected <<-EOF &&
233 * sm1 $head6...0000000:
235 * sm2 0000000...$head7 (2):
239 test_cmp expected actual
242 test_expect_success
'path filter' "
243 git submodule summary sm2 >actual &&
244 cat >expected <<-EOF &&
245 * sm2 0000000...$head7 (2):
249 test_cmp expected actual
253 test_expect_success
'given commit' "
254 git submodule summary HEAD^ >actual &&
255 cat >expected <<-EOF &&
256 * sm1 $head6...0000000:
258 * sm2 0000000...$head7 (2):
262 test_cmp expected actual
265 test_expect_success
'--for-status' "
266 git submodule summary --for-status HEAD^ >actual &&
267 test_i18ncmp actual - <<EOF
268 * sm1 $head6...0000000:
270 * sm2 0000000...$head7 (2):
276 test_expect_success
'fail when using --files together with --cached' "
277 test_must_fail git submodule summary --files --cached
280 test_expect_success
'should not fail in an empty repo' "
283 git submodule summary >output 2>&1 &&
284 test_cmp output /dev/null