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.
12 *MINGW
*) GIT_TEST_CMP
="diff -uw";;
23 echo "$name" > "$name" &&
26 git commit
-m "Add $name"
28 git rev-parse
--verify HEAD | cut
-c1-7
33 git commit
"$@" -m "Commit $*" >/dev
/null
36 test_create_repo sm1
&&
37 add_file . foo
>/dev
/null
39 head1
=$
(add_file sm1 foo1 foo2
)
41 test_expect_success
'added submodule' "
43 git submodule summary >actual &&
44 test_cmp actual - <<-EOF
45 * sm1 0000000...$head1 (2):
52 head2
=$
(add_file sm1 foo3
)
54 test_expect_success
'modified submodule(forward)' "
55 git submodule summary >actual &&
56 test_cmp actual - <<-EOF
57 * sm1 $head1...$head2 (1):
63 test_expect_success
'modified submodule(forward), --files' "
64 git submodule summary --files >actual &&
66 * sm1 $head1...$head2 (1):
75 git
reset --hard HEAD~
2 >/dev
/null
&&
76 git rev-parse
--verify HEAD | cut
-c1-7
79 test_expect_success
'modified submodule(backward)' "
80 git submodule summary >actual &&
81 test_cmp actual - <<-EOF
82 * sm1 $head2...$head3 (2):
89 head4
=$
(add_file sm1 foo4 foo5
) &&
90 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
91 test_expect_success
'modified submodule(backward and forward)' "
92 git submodule summary >actual &&
93 test_cmp actual - <<-EOF
94 * sm1 $head2...$head4 (4):
103 test_expect_success
'--summary-limit' "
104 git submodule summary -n 3 >actual &&
105 test_cmp actual - <<-EOF
106 * sm1 $head2...$head4 (4):
117 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
122 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
123 git submodule summary --cached >actual &&
124 test_cmp actual - <<-EOF
125 * sm1 $head4(submodule)->$head5(blob) (3):
131 test_expect_success
'typechanged submodule(submodule->blob), --files' "
132 git submodule summary --files >actual &&
134 * sm1 $head5(blob)->$head4(submodule) (3):
141 git checkout-index sm1
142 test_expect_success
'typechanged submodule(submodule->blob)' "
143 git submodule summary >actual &&
144 test_cmp actual - <<-EOF
145 * sm1 $head4(submodule)->$head5(blob):
151 test_create_repo sm1
&&
152 head6
=$
(add_file sm1 foo6 foo7
)
153 test_expect_success
'nonexistent commit' "
154 git submodule summary >actual &&
155 test_cmp actual - <<-EOF
156 * sm1 $head4...$head6:
157 Warn: sm1 doesn't contain commit $head4_full
163 test_expect_success
'typechanged submodule(blob->submodule)' "
164 git submodule summary >actual &&
165 test_cmp actual - <<-EOF
166 * sm1 $head5(blob)->$head6(submodule) (2):
174 test_expect_success
'deleted submodule' "
175 git submodule summary >actual &&
176 test_cmp actual - <<-EOF
177 * sm1 $head6...0000000:
182 test_create_repo sm2
&&
183 head7
=$
(add_file sm2 foo8 foo9
) &&
186 test_expect_success
'multiple submodules' "
187 git submodule summary >actual &&
188 test_cmp actual - <<-EOF
189 * sm1 $head6...0000000:
191 * sm2 0000000...$head7 (2):
197 test_expect_success
'path filter' "
198 git submodule summary sm2 >actual &&
199 test_cmp actual - <<-EOF
200 * sm2 0000000...$head7 (2):
207 test_expect_success
'given commit' "
208 git submodule summary HEAD^ >actual &&
209 test_cmp actual - <<-EOF
210 * sm1 $head6...0000000:
212 * sm2 0000000...$head7 (2):
218 test_expect_success
'--for-status' "
219 git submodule summary --for-status HEAD^ >actual &&
220 test_cmp actual - <<EOF
221 # Submodule changes to be committed:
223 # * sm1 $head6...0000000:
225 # * sm2 0000000...$head7 (2):
231 test_expect_success
'fail when using --files together with --cached' "
232 test_must_fail git submodule summary --files --cached
235 test_expect_success
'should not fail in an empty repo' "
238 git submodule summary >output 2>&1 &&
239 test_cmp output /dev/null