http-push: Normalise directory names when pushing to some WebDAV servers
[git.git] / t / t7401-submodule-summary.sh
blob294584452bbc3226e631ce0b81c546b04cd8d992
1 #!/bin/sh
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.
11 . ./test-lib.sh
13 add_file () {
14 sm=$1
15 shift
16 owd=$(pwd)
17 cd "$sm"
18 for name; do
19 echo "$name" > "$name" &&
20 git add "$name" &&
21 test_tick &&
22 git commit -m "Add $name"
23 done >/dev/null
24 git rev-parse --verify HEAD | cut -c1-7
25 cd "$owd"
27 commit_file () {
28 test_tick &&
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' "
38 git add sm1 &&
39 git submodule summary >actual &&
40 diff actual - <<-EOF
41 * sm1 0000000...$head1 (2):
42 > Add foo2
44 EOF
47 commit_file sm1 &&
48 head2=$(add_file sm1 foo3)
50 test_expect_success 'modified submodule(forward)' "
51 git submodule summary >actual &&
52 diff actual - <<-EOF
53 * sm1 $head1...$head2 (1):
54 > Add foo3
56 EOF
59 test_expect_success 'modified submodule(forward), --files' "
60 git submodule summary --files >actual &&
61 diff actual - <<-EOF
62 * sm1 $head1...$head2 (1):
63 > Add foo3
65 EOF
68 commit_file sm1 &&
69 head3=$(
70 cd sm1 &&
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 &&
77 diff actual - <<-EOF
78 * sm1 $head2...$head3 (2):
79 < Add foo3
80 < Add foo2
82 EOF
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 &&
89 diff actual - <<-EOF
90 * sm1 $head2...$head4 (4):
91 > Add foo5
92 > Add foo4
93 < Add foo3
94 < Add foo2
96 EOF
99 test_expect_success '--summary-limit' "
100 git submodule summary -n 3 >actual &&
101 diff actual - <<-EOF
102 * sm1 $head2...$head4 (4):
103 > Add foo5
104 > Add foo4
105 < Add foo3
110 commit_file sm1 &&
111 mv sm1 sm1-bak &&
112 echo sm1 >sm1 &&
113 head5=$(git hash-object sm1 | cut -c1-7) &&
114 git add sm1 &&
115 rm -f sm1 &&
116 mv sm1-bak sm1
118 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
119 git submodule summary --cached >actual &&
120 diff actual - <<-EOF
121 * sm1 $head4(submodule)->$head5(blob) (3):
122 < Add foo5
127 test_expect_success 'typechanged submodule(submodule->blob), --files' "
128 git submodule summary --files >actual &&
129 diff actual - <<-EOF
130 * sm1 $head5(blob)->$head4(submodule) (3):
131 > Add foo5
136 rm -rf sm1 &&
137 git checkout-index sm1
138 test_expect_success 'typechanged submodule(submodule->blob)' "
139 git submodule summary >actual &&
140 diff actual - <<-EOF
141 * sm1 $head4(submodule)->$head5(blob):
146 rm -f sm1 &&
147 test_create_repo sm1 &&
148 head6=$(add_file sm1 foo6 foo7)
149 test_expect_success 'nonexistent commit' "
150 git submodule summary >actual &&
151 diff actual - <<-EOF
152 * sm1 $head4...$head6:
153 Warn: sm1 doesn't contain commit $head4_full
158 commit_file
159 test_expect_success 'typechanged submodule(blob->submodule)' "
160 git submodule summary >actual &&
161 diff actual - <<-EOF
162 * sm1 $head5(blob)->$head6(submodule) (2):
163 > Add foo7
168 commit_file sm1 &&
169 rm -rf sm1
170 test_expect_success 'deleted submodule' "
171 git submodule summary >actual &&
172 diff actual - <<-EOF
173 * sm1 $head6...0000000:
178 test_create_repo sm2 &&
179 head7=$(add_file sm2 foo8 foo9) &&
180 git add sm2
182 test_expect_success 'multiple submodules' "
183 git submodule summary >actual &&
184 diff actual - <<-EOF
185 * sm1 $head6...0000000:
187 * sm2 0000000...$head7 (2):
188 > Add foo9
193 test_expect_success 'path filter' "
194 git submodule summary sm2 >actual &&
195 diff actual - <<-EOF
196 * sm2 0000000...$head7 (2):
197 > Add foo9
202 commit_file sm2
203 test_expect_success 'given commit' "
204 git submodule summary HEAD^ >actual &&
205 diff actual - <<-EOF
206 * sm1 $head6...0000000:
208 * sm2 0000000...$head7 (2):
209 > Add foo9
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):
222 # > Add foo9
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' "
232 git init xyzzy &&
233 cd xyzzy &&
234 git submodule summary >output 2>&1 &&
235 test_cmp output /dev/null
238 test_done