3 # Copyright (c) 2008 Ping Yin
6 test_description
='Summary support for submodules
8 This test script tries to verify the sanity of summary subcommand of git submodule.
11 # NOTE: This test script uses 'git add' instead of 'git submodule add' to add
12 # submodules to the superproject. Some submodule subcommands such as init and
13 # deinit might not work as expected in this script. t7421 does not have this
16 # NEEDSWORK: This test script is old fashioned and may need a big cleanup due to
17 # various reasons, one of them being that there are lots of commands taking place
18 # outside of 'test_expect_success' block, which is no longer in good-style.
28 echo "$name" >"$name" &&
31 git commit
-m "Add $name"
33 git rev-parse
--short HEAD
38 git commit
"$@" -m "Commit $*" >/dev
/null
41 test_create_repo sm1
&&
42 add_file . foo
>/dev
/null
44 head1
=$
(add_file sm1 foo1 foo2
)
46 test_expect_success
'added submodule' "
48 git submodule summary >actual &&
49 cat >expected <<-EOF &&
50 * sm1 0000000...$head1 (2):
54 test_cmp expected actual
57 test_expect_success
'added submodule (subdirectory)' "
61 git submodule summary >../actual
63 cat >expected <<-EOF &&
64 * ../sm1 0000000...$head1 (2):
68 test_cmp expected actual
71 test_expect_success
'added submodule (subdirectory only)' "
74 git submodule summary . >../actual
76 test_must_be_empty actual
79 test_expect_success
'added submodule (subdirectory with explicit path)' "
82 git submodule summary ../sm1 >../actual
84 cat >expected <<-EOF &&
85 * ../sm1 0000000...$head1 (2):
89 test_cmp expected actual
93 head2
=$
(add_file sm1 foo3
)
95 test_expect_success
'modified submodule(forward)' "
96 git submodule summary >actual &&
97 cat >expected <<-EOF &&
98 * sm1 $head1...$head2 (1):
102 test_cmp expected actual
105 test_expect_success
'modified submodule(forward), --files' "
106 git submodule summary --files >actual &&
107 cat >expected <<-EOF &&
108 * sm1 $head1...$head2 (1):
112 test_cmp expected actual
115 test_expect_success
'no ignore=all setting has any effect' "
116 git config -f .gitmodules submodule.sm1.path sm1 &&
117 git config -f .gitmodules submodule.sm1.ignore all &&
118 git config submodule.sm1.ignore all &&
119 git config diff.ignoreSubmodules all &&
120 git submodule summary >actual &&
121 cat >expected <<-EOF &&
122 * sm1 $head1...$head2 (1):
126 test_cmp expected actual &&
127 git config --unset diff.ignoreSubmodules &&
128 git config --remove-section submodule.sm1 &&
129 git config -f .gitmodules --remove-section submodule.sm1
136 git
reset --hard HEAD~
2 >/dev
/null
&&
137 git rev-parse
--short HEAD
140 test_expect_success
'modified submodule(backward)' "
141 git submodule summary >actual &&
142 cat >expected <<-EOF &&
143 * sm1 $head2...$head3 (2):
148 test_cmp expected actual
151 head4
=$
(add_file sm1 foo4 foo5
) &&
152 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
153 test_expect_success
'modified submodule(backward and forward)' "
154 git submodule summary >actual &&
155 cat >expected <<-EOF &&
156 * sm1 $head2...$head4 (4):
163 test_cmp expected actual
166 test_expect_success
'--summary-limit' "
167 git submodule summary -n 3 >actual &&
168 cat >expected <<-EOF &&
169 * sm1 $head2...$head4 (4):
175 test_cmp expected actual
181 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
186 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
187 git submodule summary --cached >actual &&
188 cat >expected <<-EOF &&
189 * sm1 $head4(submodule)->$head5(blob) (3):
193 test_cmp expected actual
196 test_expect_success
'typechanged submodule(submodule->blob), --files' "
197 git submodule summary --files >actual &&
198 cat >expected <<-EOF &&
199 * sm1 $head5(blob)->$head4(submodule) (3):
203 test_cmp expected actual
207 git checkout-index sm1
208 test_expect_success
'typechanged submodule(submodule->blob)' "
209 git submodule summary >actual &&
210 cat >expected <<-EOF &&
211 * sm1 $head4(submodule)->$head5(blob):
214 test_cmp expected actual
218 test_create_repo sm1
&&
219 head6
=$
(add_file sm1 foo6 foo7
)
220 test_expect_success
'nonexistent commit' "
221 git submodule summary >actual &&
222 cat >expected <<-EOF &&
223 * sm1 $head4...$head6:
224 Warn: sm1 doesn't contain commit $head4_full
227 test_cmp expected actual
231 test_expect_success
'typechanged submodule(blob->submodule)' "
232 git submodule summary >actual &&
233 cat >expected <<-EOF &&
234 * sm1 $head5(blob)->$head6(submodule) (2):
238 test_cmp expected actual
243 test_expect_success
'deleted submodule' "
244 git submodule summary >actual &&
245 cat >expected <<-EOF &&
246 * sm1 $head6...0000000:
249 test_cmp expected actual
252 test_expect_success
'create second submodule' '
253 test_create_repo sm2 &&
254 head7=$(add_file sm2 foo8 foo9) &&
258 test_expect_success
'multiple submodules' "
259 git submodule summary >actual &&
260 cat >expected <<-EOF &&
261 * sm1 $head6...0000000:
263 * sm2 0000000...$head7 (2):
267 test_cmp expected actual
270 test_expect_success
'path filter' "
271 git submodule summary sm2 >actual &&
272 cat >expected <<-EOF &&
273 * sm2 0000000...$head7 (2):
277 test_cmp expected actual
281 test_expect_success
'given commit' "
282 git submodule summary HEAD^ >actual &&
283 cat >expected <<-EOF &&
284 * sm1 $head6...0000000:
286 * sm2 0000000...$head7 (2):
290 test_cmp expected actual
293 test_expect_success
'--for-status' "
294 git submodule summary --for-status HEAD^ >actual &&
295 test_cmp - actual <<-EOF
296 * sm1 $head6...0000000:
298 * sm2 0000000...$head7 (2):
304 test_expect_success
'fail when using --files together with --cached' "
305 test_must_fail git submodule summary --files --cached
308 test_expect_success
'should not fail in an empty repo' "
311 git submodule summary >output 2>&1 &&
312 test_must_be_empty output