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 &&
41 * sm1 0000000...$head1 (2):
48 head2
=$
(add_file sm1 foo3
)
50 test_expect_success
'modified submodule(forward)' "
51 git submodule summary >actual &&
53 * sm1 $head1...$head2 (1):
61 git
reset --hard HEAD~
2 >/dev
/null
&&
62 head3
=$
(git rev-parse
--verify HEAD | cut
-c1-7) &&
65 test_expect_success
'modified submodule(backward)' "
66 git submodule summary >actual &&
68 * sm1 $head2...$head3 (2):
75 head4
=$
(add_file sm1 foo4 foo5
) &&
76 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
77 test_expect_success
'modified submodule(backward and forward)' "
78 git submodule summary >actual &&
80 * sm1 $head2...$head4 (4):
89 test_expect_success
'--summary-limit' "
90 git submodule summary -n 3 >actual &&
92 * sm1 $head2...$head4 (4):
103 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
108 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
109 git submodule summary --cached >actual &&
111 * sm1 $head4(submodule)->$head5(blob) (3):
118 git checkout-index sm1
119 test_expect_success
'typechanged submodule(submodule->blob)' "
120 git submodule summary >actual &&
122 * sm1 $head4(submodule)->$head5(blob):
128 test_create_repo sm1
&&
129 head6
=$
(add_file sm1 foo6 foo7
)
130 test_expect_success
'nonexistent commit' "
131 git submodule summary >actual &&
133 * sm1 $head4...$head6:
134 Warn: sm1 doesn't contain commit $head4_full
140 test_expect_success
'typechanged submodule(blob->submodule)' "
141 git submodule summary >actual &&
143 * sm1 $head5(blob)->$head6(submodule) (2):
151 test_expect_success
'deleted submodule' "
152 git submodule summary >actual &&
154 * sm1 $head6...0000000:
159 test_create_repo sm2
&&
160 head7
=$
(add_file sm2 foo8 foo9
) &&
163 test_expect_success
'multiple submodules' "
164 git submodule summary >actual &&
166 * sm1 $head6...0000000:
168 * sm2 0000000...$head7 (2):
174 test_expect_success
'path filter' "
175 git submodule summary sm2 >actual &&
177 * sm2 0000000...$head7 (2):
184 test_expect_success
'given commit' "
185 git submodule summary HEAD^ >actual &&
187 * sm1 $head6...0000000:
189 * sm2 0000000...$head7 (2):
195 test_expect_success
'--for-status' "
196 git submodule summary --for-status HEAD^ >actual &&
197 test_cmp actual - <<EOF
198 # Modified submodules:
200 # * sm1 $head6...0000000:
202 # * sm2 0000000...$head7 (2):