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):
74 git
reset --hard HEAD~
2 >/dev
/null
&&
75 head3
=$
(git rev-parse
--verify HEAD | cut
-c1-7) &&
78 test_expect_success
'modified submodule(backward)' "
79 git submodule summary >actual &&
80 test_cmp actual - <<-EOF
81 * sm1 $head2...$head3 (2):
88 head4
=$
(add_file sm1 foo4 foo5
) &&
89 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
90 test_expect_success
'modified submodule(backward and forward)' "
91 git submodule summary >actual &&
92 test_cmp actual - <<-EOF
93 * sm1 $head2...$head4 (4):
102 test_expect_success
'--summary-limit' "
103 git submodule summary -n 3 >actual &&
104 test_cmp actual - <<-EOF
105 * sm1 $head2...$head4 (4):
116 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
121 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
122 git submodule summary --cached >actual &&
123 test_cmp actual - <<-EOF
124 * sm1 $head4(submodule)->$head5(blob) (3):
130 test_expect_success
'typechanged submodule(submodule->blob), --files' "
131 git submodule summary --files >actual &&
133 * sm1 $head5(blob)->$head4(submodule) (3):
140 git checkout-index sm1
141 test_expect_success
'typechanged submodule(submodule->blob)' "
142 git submodule summary >actual &&
143 test_cmp actual - <<-EOF
144 * sm1 $head4(submodule)->$head5(blob):
150 test_create_repo sm1
&&
151 head6
=$
(add_file sm1 foo6 foo7
)
152 test_expect_success
'nonexistent commit' "
153 git submodule summary >actual &&
154 test_cmp actual - <<-EOF
155 * sm1 $head4...$head6:
156 Warn: sm1 doesn't contain commit $head4_full
162 test_expect_success
'typechanged submodule(blob->submodule)' "
163 git submodule summary >actual &&
164 test_cmp actual - <<-EOF
165 * sm1 $head5(blob)->$head6(submodule) (2):
173 test_expect_success
'deleted submodule' "
174 git submodule summary >actual &&
175 test_cmp actual - <<-EOF
176 * sm1 $head6...0000000:
181 test_create_repo sm2
&&
182 head7
=$
(add_file sm2 foo8 foo9
) &&
185 test_expect_success
'multiple submodules' "
186 git submodule summary >actual &&
187 test_cmp actual - <<-EOF
188 * sm1 $head6...0000000:
190 * sm2 0000000...$head7 (2):
196 test_expect_success
'path filter' "
197 git submodule summary sm2 >actual &&
198 test_cmp actual - <<-EOF
199 * sm2 0000000...$head7 (2):
206 test_expect_success
'given commit' "
207 git submodule summary HEAD^ >actual &&
208 test_cmp actual - <<-EOF
209 * sm1 $head6...0000000:
211 * sm2 0000000...$head7 (2):
217 test_expect_success
'--for-status' "
218 git submodule summary --for-status HEAD^ >actual &&
219 test_cmp actual - <<EOF
220 # Submodule changes to be committed:
222 # * sm1 $head6...0000000:
224 # * sm2 0000000...$head7 (2):
230 test_expect_success
'fail when using --files together with --cached' "
231 test_must_fail git submodule summary --files --cached