]>
Commit | Line | Data |
---|---|---|
0c2f0d27 BW |
1 | #!/bin/sh |
2 | ||
3 | test_description='test git wire-protocol transition' | |
4 | ||
5 | TEST_NO_CREATE_REPO=1 | |
6 | ||
7 | . ./test-lib.sh | |
8 | ||
9 | # Test protocol v1 with 'git://' transport | |
10 | # | |
11 | . "$TEST_DIRECTORY"/lib-git-daemon.sh | |
12 | start_git_daemon --export-all --enable=receive-pack | |
13 | daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent | |
14 | ||
15 | test_expect_success 'create repo to be served by git-daemon' ' | |
16 | git init "$daemon_parent" && | |
17 | test_commit -C "$daemon_parent" one | |
18 | ' | |
19 | ||
20 | test_expect_success 'clone with git:// using protocol v1' ' | |
21 | GIT_TRACE_PACKET=1 git -c protocol.version=1 \ | |
22 | clone "$GIT_DAEMON_URL/parent" daemon_child 2>log && | |
23 | ||
24 | git -C daemon_child log -1 --format=%s >actual && | |
25 | git -C "$daemon_parent" log -1 --format=%s >expect && | |
26 | test_cmp expect actual && | |
27 | ||
28 | # Client requested to use protocol v1 | |
29 | grep "clone> .*\\\0\\\0version=1\\\0$" log && | |
30 | # Server responded using protocol v1 | |
31 | grep "clone< version 1" log | |
32 | ' | |
33 | ||
34 | test_expect_success 'fetch with git:// using protocol v1' ' | |
35 | test_commit -C "$daemon_parent" two && | |
36 | ||
37 | GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \ | |
38 | fetch 2>log && | |
39 | ||
40 | git -C daemon_child log -1 --format=%s origin/master >actual && | |
41 | git -C "$daemon_parent" log -1 --format=%s >expect && | |
42 | test_cmp expect actual && | |
43 | ||
44 | # Client requested to use protocol v1 | |
45 | grep "fetch> .*\\\0\\\0version=1\\\0$" log && | |
46 | # Server responded using protocol v1 | |
47 | grep "fetch< version 1" log | |
48 | ' | |
49 | ||
50 | test_expect_success 'pull with git:// using protocol v1' ' | |
51 | GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \ | |
52 | pull 2>log && | |
53 | ||
54 | git -C daemon_child log -1 --format=%s >actual && | |
55 | git -C "$daemon_parent" log -1 --format=%s >expect && | |
56 | test_cmp expect actual && | |
57 | ||
58 | # Client requested to use protocol v1 | |
59 | grep "fetch> .*\\\0\\\0version=1\\\0$" log && | |
60 | # Server responded using protocol v1 | |
61 | grep "fetch< version 1" log | |
62 | ' | |
63 | ||
64 | test_expect_success 'push with git:// using protocol v1' ' | |
65 | test_commit -C daemon_child three && | |
66 | ||
67 | # Push to another branch, as the target repository has the | |
68 | # master branch checked out and we cannot push into it. | |
69 | GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \ | |
70 | push origin HEAD:client_branch 2>log && | |
71 | ||
72 | git -C daemon_child log -1 --format=%s >actual && | |
73 | git -C "$daemon_parent" log -1 --format=%s client_branch >expect && | |
74 | test_cmp expect actual && | |
75 | ||
76 | # Client requested to use protocol v1 | |
77 | grep "push> .*\\\0\\\0version=1\\\0$" log && | |
78 | # Server responded using protocol v1 | |
79 | grep "push< version 1" log | |
80 | ' | |
81 | ||
82 | stop_git_daemon | |
83 | ||
84 | # Test protocol v1 with 'file://' transport | |
85 | # | |
86 | test_expect_success 'create repo to be served by file:// transport' ' | |
87 | git init file_parent && | |
88 | test_commit -C file_parent one | |
89 | ' | |
90 | ||
91 | test_expect_success 'clone with file:// using protocol v1' ' | |
92 | GIT_TRACE_PACKET=1 git -c protocol.version=1 \ | |
93 | clone "file://$(pwd)/file_parent" file_child 2>log && | |
94 | ||
95 | git -C file_child log -1 --format=%s >actual && | |
96 | git -C file_parent log -1 --format=%s >expect && | |
97 | test_cmp expect actual && | |
98 | ||
99 | # Server responded using protocol v1 | |
100 | grep "clone< version 1" log | |
101 | ' | |
102 | ||
103 | test_expect_success 'fetch with file:// using protocol v1' ' | |
104 | test_commit -C file_parent two && | |
105 | ||
106 | GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \ | |
107 | fetch 2>log && | |
108 | ||
109 | git -C file_child log -1 --format=%s origin/master >actual && | |
110 | git -C file_parent log -1 --format=%s >expect && | |
111 | test_cmp expect actual && | |
112 | ||
113 | # Server responded using protocol v1 | |
114 | grep "fetch< version 1" log | |
115 | ' | |
116 | ||
117 | test_expect_success 'pull with file:// using protocol v1' ' | |
118 | GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \ | |
119 | pull 2>log && | |
120 | ||
121 | git -C file_child log -1 --format=%s >actual && | |
122 | git -C file_parent log -1 --format=%s >expect && | |
123 | test_cmp expect actual && | |
124 | ||
125 | # Server responded using protocol v1 | |
126 | grep "fetch< version 1" log | |
127 | ' | |
128 | ||
129 | test_expect_success 'push with file:// using protocol v1' ' | |
130 | test_commit -C file_child three && | |
131 | ||
132 | # Push to another branch, as the target repository has the | |
133 | # master branch checked out and we cannot push into it. | |
134 | GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \ | |
135 | push origin HEAD:client_branch 2>log && | |
136 | ||
137 | git -C file_child log -1 --format=%s >actual && | |
138 | git -C file_parent log -1 --format=%s client_branch >expect && | |
139 | test_cmp expect actual && | |
140 | ||
141 | # Server responded using protocol v1 | |
142 | grep "push< version 1" log | |
143 | ' | |
144 | ||
145 | # Test protocol v1 with 'ssh://' transport | |
146 | # | |
147 | test_expect_success 'setup ssh wrapper' ' | |
148 | GIT_SSH="$GIT_BUILD_DIR/t/helper/test-fake-ssh" && | |
149 | export GIT_SSH && | |
150 | export TRASH_DIRECTORY && | |
151 | >"$TRASH_DIRECTORY"/ssh-output | |
152 | ' | |
153 | ||
154 | expect_ssh () { | |
155 | test_when_finished '(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)' && | |
156 | echo "ssh: -o SendEnv=GIT_PROTOCOL myhost $1 '$PWD/ssh_parent'" >"$TRASH_DIRECTORY/ssh-expect" && | |
157 | (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output) | |
158 | } | |
159 | ||
160 | test_expect_success 'create repo to be served by ssh:// transport' ' | |
161 | git init ssh_parent && | |
162 | test_commit -C ssh_parent one | |
163 | ' | |
164 | ||
165 | test_expect_success 'clone with ssh:// using protocol v1' ' | |
166 | GIT_TRACE_PACKET=1 git -c protocol.version=1 \ | |
167 | clone "ssh://myhost:$(pwd)/ssh_parent" ssh_child 2>log && | |
168 | expect_ssh git-upload-pack && | |
169 | ||
170 | git -C ssh_child log -1 --format=%s >actual && | |
171 | git -C ssh_parent log -1 --format=%s >expect && | |
172 | test_cmp expect actual && | |
173 | ||
174 | # Server responded using protocol v1 | |
175 | grep "clone< version 1" log | |
176 | ' | |
177 | ||
178 | test_expect_success 'fetch with ssh:// using protocol v1' ' | |
179 | test_commit -C ssh_parent two && | |
180 | ||
181 | GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \ | |
182 | fetch 2>log && | |
183 | expect_ssh git-upload-pack && | |
184 | ||
185 | git -C ssh_child log -1 --format=%s origin/master >actual && | |
186 | git -C ssh_parent log -1 --format=%s >expect && | |
187 | test_cmp expect actual && | |
188 | ||
189 | # Server responded using protocol v1 | |
190 | grep "fetch< version 1" log | |
191 | ' | |
192 | ||
193 | test_expect_success 'pull with ssh:// using protocol v1' ' | |
194 | GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \ | |
195 | pull 2>log && | |
196 | expect_ssh git-upload-pack && | |
197 | ||
198 | git -C ssh_child log -1 --format=%s >actual && | |
199 | git -C ssh_parent log -1 --format=%s >expect && | |
200 | test_cmp expect actual && | |
201 | ||
202 | # Server responded using protocol v1 | |
203 | grep "fetch< version 1" log | |
204 | ' | |
205 | ||
206 | test_expect_success 'push with ssh:// using protocol v1' ' | |
207 | test_commit -C ssh_child three && | |
208 | ||
209 | # Push to another branch, as the target repository has the | |
210 | # master branch checked out and we cannot push into it. | |
211 | GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \ | |
212 | push origin HEAD:client_branch 2>log && | |
213 | expect_ssh git-receive-pack && | |
214 | ||
215 | git -C ssh_child log -1 --format=%s >actual && | |
216 | git -C ssh_parent log -1 --format=%s client_branch >expect && | |
217 | test_cmp expect actual && | |
218 | ||
219 | # Server responded using protocol v1 | |
220 | grep "push< version 1" log | |
221 | ' | |
222 | ||
19113a26 BW |
223 | # Test protocol v1 with 'http://' transport |
224 | # | |
225 | . "$TEST_DIRECTORY"/lib-httpd.sh | |
226 | start_httpd | |
227 | ||
228 | test_expect_success 'create repo to be served by http:// transport' ' | |
229 | git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && | |
230 | git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true && | |
231 | test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one | |
232 | ' | |
233 | ||
234 | test_expect_success 'clone with http:// using protocol v1' ' | |
235 | GIT_TRACE_PACKET=1 GIT_TRACE_CURL=1 git -c protocol.version=1 \ | |
236 | clone "$HTTPD_URL/smart/http_parent" http_child 2>log && | |
237 | ||
238 | git -C http_child log -1 --format=%s >actual && | |
239 | git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && | |
240 | test_cmp expect actual && | |
241 | ||
242 | # Client requested to use protocol v1 | |
243 | grep "Git-Protocol: version=1" log && | |
244 | # Server responded using protocol v1 | |
245 | grep "git< version 1" log | |
246 | ' | |
247 | ||
248 | test_expect_success 'fetch with http:// using protocol v1' ' | |
249 | test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two && | |
250 | ||
251 | GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \ | |
252 | fetch 2>log && | |
253 | ||
254 | git -C http_child log -1 --format=%s origin/master >actual && | |
255 | git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && | |
256 | test_cmp expect actual && | |
257 | ||
258 | # Server responded using protocol v1 | |
259 | grep "git< version 1" log | |
260 | ' | |
261 | ||
262 | test_expect_success 'pull with http:// using protocol v1' ' | |
263 | GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \ | |
264 | pull 2>log && | |
265 | ||
266 | git -C http_child log -1 --format=%s >actual && | |
267 | git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect && | |
268 | test_cmp expect actual && | |
269 | ||
270 | # Server responded using protocol v1 | |
271 | grep "git< version 1" log | |
272 | ' | |
273 | ||
274 | test_expect_success 'push with http:// using protocol v1' ' | |
275 | test_commit -C http_child three && | |
276 | ||
277 | # Push to another branch, as the target repository has the | |
278 | # master branch checked out and we cannot push into it. | |
279 | GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \ | |
280 | push origin HEAD:client_branch && #2>log && | |
281 | ||
282 | git -C http_child log -1 --format=%s >actual && | |
283 | git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect && | |
284 | test_cmp expect actual && | |
285 | ||
286 | # Server responded using protocol v1 | |
287 | grep "git< version 1" log | |
288 | ' | |
289 | ||
290 | stop_httpd | |
291 | ||
0c2f0d27 | 292 | test_done |