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):
59 test_expect_success 'modified submodule(forward), --files' "
60 git submodule summary --files >actual &&
62 * sm1 $head1...$head2 (1):
70 git reset --hard HEAD~2 >/dev/null &&
71 head3=$(git rev-parse --verify HEAD | cut -c1-7) &&
74 test_expect_success 'modified submodule(backward)' "
75 git submodule summary >actual &&
77 * sm1 $head2...$head3 (2):
84 head4=$(add_file sm1 foo4 foo5) &&
85 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
86 test_expect_success 'modified submodule(backward and forward)' "
87 git submodule summary >actual &&
89 * sm1 $head2...$head4 (4):
98 test_expect_success '--summary-limit' "
99 git submodule summary -n 3 >actual &&
101 * sm1 $head2...$head4 (4):
112 head5=$(git hash-object sm1 | cut -c1-7) &&
117 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
118 git submodule summary --cached >actual &&
120 * sm1 $head4(submodule)->$head5(blob) (3):
126 test_expect_success 'typechanged submodule(submodule->blob), --files' "
127 git submodule summary --files >actual &&
129 * sm1 $head5(blob)->$head4(submodule) (3):
136 git checkout-index sm1
137 test_expect_success 'typechanged submodule(submodule->blob)' "
138 git submodule summary >actual &&
140 * sm1 $head4(submodule)->$head5(blob):
146 test_create_repo sm1 &&
147 head6=$(add_file sm1 foo6 foo7)
148 test_expect_success 'nonexistent commit' "
149 git submodule summary >actual &&
151 * sm1 $head4...$head6:
152 Warn: sm1 doesn't contain commit $head4_full
158 test_expect_success 'typechanged submodule(blob->submodule)' "
159 git submodule summary >actual &&
161 * sm1 $head5(blob)->$head6(submodule) (2):
169 test_expect_success 'deleted submodule' "
170 git submodule summary >actual &&
172 * sm1 $head6...0000000:
177 test_create_repo sm2 &&
178 head7=$(add_file sm2 foo8 foo9) &&
181 test_expect_success 'multiple submodules' "
182 git submodule summary >actual &&
184 * sm1 $head6...0000000:
186 * sm2 0000000...$head7 (2):
192 test_expect_success 'path filter' "
193 git submodule summary sm2 >actual &&
195 * sm2 0000000...$head7 (2):
202 test_expect_success 'given commit' "
203 git submodule summary HEAD^ >actual &&
205 * sm1 $head6...0000000:
207 * sm2 0000000...$head7 (2):
213 test_expect_success '--for-status' "
214 git submodule summary --for-status HEAD^ >actual &&
215 test_cmp actual - <<EOF
216 # Modified submodules:
218 # * sm1 $head6...0000000:
220 # * sm2 0000000...$head7 (2):
226 test_expect_success 'fail when using --files together with --cached' "
227 test_must_fail git submodule summary --files --cached