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
67 test_must_be_empty actual
70 test_expect_success
'added submodule (subdirectory with explicit path)' "
73 git submodule summary ../sm1 >../actual
75 cat >expected <<-EOF &&
76 * ../sm1 0000000...$head1 (2):
80 test_cmp expected actual
84 head2
=$
(add_file sm1 foo3
)
86 test_expect_success
'modified submodule(forward)' "
87 git submodule summary >actual &&
88 cat >expected <<-EOF &&
89 * sm1 $head1...$head2 (1):
93 test_cmp expected actual
96 test_expect_success
'modified submodule(forward), --files' "
97 git submodule summary --files >actual &&
98 cat >expected <<-EOF &&
99 * sm1 $head1...$head2 (1):
103 test_cmp expected actual
106 test_expect_success
'no ignore=all setting has any effect' "
107 git config -f .gitmodules submodule.sm1.path sm1 &&
108 git config -f .gitmodules submodule.sm1.ignore all &&
109 git config submodule.sm1.ignore all &&
110 git config diff.ignoreSubmodules all &&
111 git submodule summary >actual &&
112 cat >expected <<-EOF &&
113 * sm1 $head1...$head2 (1):
117 test_cmp expected actual &&
118 git config --unset diff.ignoreSubmodules &&
119 git config --remove-section submodule.sm1 &&
120 git config -f .gitmodules --remove-section submodule.sm1
127 git
reset --hard HEAD~
2 >/dev
/null
&&
128 git rev-parse
--verify HEAD | cut
-c1-7
131 test_expect_success
'modified submodule(backward)' "
132 git submodule summary >actual &&
133 cat >expected <<-EOF &&
134 * sm1 $head2...$head3 (2):
139 test_cmp expected actual
142 head4
=$
(add_file sm1 foo4 foo5
) &&
143 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
144 test_expect_success
'modified submodule(backward and forward)' "
145 git submodule summary >actual &&
146 cat >expected <<-EOF &&
147 * sm1 $head2...$head4 (4):
154 test_cmp expected actual
157 test_expect_success
'--summary-limit' "
158 git submodule summary -n 3 >actual &&
159 cat >expected <<-EOF &&
160 * sm1 $head2...$head4 (4):
166 test_cmp expected actual
172 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
177 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
178 git submodule summary --cached >actual &&
179 cat >expected <<-EOF &&
180 * sm1 $head4(submodule)->$head5(blob) (3):
184 test_i18ncmp actual expected
187 test_expect_success
'typechanged submodule(submodule->blob), --files' "
188 git submodule summary --files >actual &&
189 cat >expected <<-EOF &&
190 * sm1 $head5(blob)->$head4(submodule) (3):
194 test_i18ncmp actual expected
198 git checkout-index sm1
199 test_expect_success
'typechanged submodule(submodule->blob)' "
200 git submodule summary >actual &&
201 cat >expected <<-EOF &&
202 * sm1 $head4(submodule)->$head5(blob):
205 test_i18ncmp actual expected
209 test_create_repo sm1
&&
210 head6
=$
(add_file sm1 foo6 foo7
)
211 test_expect_success
'nonexistent commit' "
212 git submodule summary >actual &&
213 cat >expected <<-EOF &&
214 * sm1 $head4...$head6:
215 Warn: sm1 doesn't contain commit $head4_full
218 test_i18ncmp actual expected
222 test_expect_success
'typechanged submodule(blob->submodule)' "
223 git submodule summary >actual &&
224 cat >expected <<-EOF &&
225 * sm1 $head5(blob)->$head6(submodule) (2):
229 test_i18ncmp expected actual
234 test_expect_success
'deleted submodule' "
235 git submodule summary >actual &&
236 cat >expected <<-EOF &&
237 * sm1 $head6...0000000:
240 test_cmp expected actual
243 test_expect_success
'create second submodule' '
244 test_create_repo sm2 &&
245 head7=$(add_file sm2 foo8 foo9) &&
249 test_expect_success
'multiple submodules' "
250 git submodule summary >actual &&
251 cat >expected <<-EOF &&
252 * sm1 $head6...0000000:
254 * sm2 0000000...$head7 (2):
258 test_cmp expected actual
261 test_expect_success
'path filter' "
262 git submodule summary sm2 >actual &&
263 cat >expected <<-EOF &&
264 * sm2 0000000...$head7 (2):
268 test_cmp expected actual
272 test_expect_success
'given commit' "
273 git submodule summary HEAD^ >actual &&
274 cat >expected <<-EOF &&
275 * sm1 $head6...0000000:
277 * sm2 0000000...$head7 (2):
281 test_cmp expected actual
284 test_expect_success
'--for-status' "
285 git submodule summary --for-status HEAD^ >actual &&
286 test_i18ncmp actual - <<EOF
287 * sm1 $head6...0000000:
289 * sm2 0000000...$head7 (2):
295 test_expect_success
'fail when using --files together with --cached' "
296 test_must_fail git submodule summary --files --cached
299 test_expect_success
'should not fail in an empty repo' "
302 git submodule summary >output 2>&1 &&
303 test_must_be_empty output