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):
65 git
reset --hard HEAD~
2 >/dev
/null
&&
66 head3
=$
(git rev-parse
--verify HEAD | cut
-c1-7) &&
69 test_expect_success
'modified submodule(backward)' "
70 git submodule summary >actual &&
71 test_cmp actual - <<-EOF
72 * sm1 $head2...$head3 (2):
79 head4
=$
(add_file sm1 foo4 foo5
) &&
80 head4_full
=$
(GIT_DIR
=sm
1/.git git rev-parse
--verify HEAD
)
81 test_expect_success
'modified submodule(backward and forward)' "
82 git submodule summary >actual &&
83 test_cmp actual - <<-EOF
84 * sm1 $head2...$head4 (4):
93 test_expect_success
'--summary-limit' "
94 git submodule summary -n 3 >actual &&
95 test_cmp actual - <<-EOF
96 * sm1 $head2...$head4 (4):
107 head5
=$
(git hash-object sm1 | cut
-c1-7) &&
112 test_expect_success
'typechanged submodule(submodule->blob), --cached' "
113 git submodule summary --cached >actual &&
114 test_cmp actual - <<-EOF
115 * sm1 $head4(submodule)->$head5(blob) (3):
122 git checkout-index sm1
123 test_expect_success
'typechanged submodule(submodule->blob)' "
124 git submodule summary >actual &&
125 test_cmp actual - <<-EOF
126 * sm1 $head4(submodule)->$head5(blob):
132 test_create_repo sm1
&&
133 head6
=$
(add_file sm1 foo6 foo7
)
134 test_expect_success
'nonexistent commit' "
135 git submodule summary >actual &&
136 test_cmp actual - <<-EOF
137 * sm1 $head4...$head6:
138 Warn: sm1 doesn't contain commit $head4_full
144 test_expect_success
'typechanged submodule(blob->submodule)' "
145 git submodule summary >actual &&
146 test_cmp actual - <<-EOF
147 * sm1 $head5(blob)->$head6(submodule) (2):
155 test_expect_success
'deleted submodule' "
156 git submodule summary >actual &&
157 test_cmp actual - <<-EOF
158 * sm1 $head6...0000000:
163 test_create_repo sm2
&&
164 head7
=$
(add_file sm2 foo8 foo9
) &&
167 test_expect_success
'multiple submodules' "
168 git submodule summary >actual &&
169 test_cmp actual - <<-EOF
170 * sm1 $head6...0000000:
172 * sm2 0000000...$head7 (2):
178 test_expect_success
'path filter' "
179 git submodule summary sm2 >actual &&
180 test_cmp actual - <<-EOF
181 * sm2 0000000...$head7 (2):
188 test_expect_success
'given commit' "
189 git submodule summary HEAD^ >actual &&
190 test_cmp actual - <<-EOF
191 * sm1 $head6...0000000:
193 * sm2 0000000...$head7 (2):
199 test_expect_success
'--for-status' "
200 git submodule summary --for-status HEAD^ >actual &&
201 test_cmp actual - <<EOF
202 # Modified submodules:
204 # * sm1 $head6...0000000:
206 # * sm2 0000000...$head7 (2):