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):
71 git reset --hard HEAD~2 >/dev/null &&
72 git rev-parse --verify HEAD | cut -c1-7
75 test_expect_success 'modified submodule(backward)' "
76 git submodule summary >actual &&
78 * sm1 $head2...$head3 (2):
85 head4=$(add_file sm1 foo4 foo5) &&
86 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
87 test_expect_success 'modified submodule(backward and forward)' "
88 git submodule summary >actual &&
90 * sm1 $head2...$head4 (4):
99 test_expect_success '--summary-limit' "
100 git submodule summary -n 3 >actual &&
102 * sm1 $head2...$head4 (4):
113 head5=$(git hash-object sm1 | cut -c1-7) &&
118 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
119 git submodule summary --cached >actual &&
121 * sm1 $head4(submodule)->$head5(blob) (3):
127 test_expect_success 'typechanged submodule(submodule->blob), --files' "
128 git submodule summary --files >actual &&
130 * sm1 $head5(blob)->$head4(submodule) (3):
137 git checkout-index sm1
138 test_expect_success 'typechanged submodule(submodule->blob)' "
139 git submodule summary >actual &&
141 * sm1 $head4(submodule)->$head5(blob):
147 test_create_repo sm1 &&
148 head6=$(add_file sm1 foo6 foo7)
149 test_expect_success 'nonexistent commit' "
150 git submodule summary >actual &&
152 * sm1 $head4...$head6:
153 Warn: sm1 doesn't contain commit $head4_full
159 test_expect_success 'typechanged submodule(blob->submodule)' "
160 git submodule summary >actual &&
162 * sm1 $head5(blob)->$head6(submodule) (2):
170 test_expect_success 'deleted submodule' "
171 git submodule summary >actual &&
173 * sm1 $head6...0000000:
178 test_create_repo sm2 &&
179 head7=$(add_file sm2 foo8 foo9) &&
182 test_expect_success 'multiple submodules' "
183 git submodule summary >actual &&
185 * sm1 $head6...0000000:
187 * sm2 0000000...$head7 (2):
193 test_expect_success 'path filter' "
194 git submodule summary sm2 >actual &&
196 * sm2 0000000...$head7 (2):
203 test_expect_success 'given commit' "
204 git submodule summary HEAD^ >actual &&
206 * sm1 $head6...0000000:
208 * sm2 0000000...$head7 (2):
214 test_expect_success '--for-status' "
215 git submodule summary --for-status HEAD^ >actual &&
216 test_cmp actual - <<EOF
217 # Submodule changes to be committed:
219 # * sm1 $head6...0000000:
221 # * sm2 0000000...$head7 (2):
227 test_expect_success 'fail when using --files together with --cached' "
228 test_must_fail git submodule summary --files --cached
231 test_expect_success 'should not fail in an empty repo' "
234 git submodule summary >output 2>&1 &&
235 test_cmp output /dev/null