3 test_description
='test git wire-protocol transition'
9 # Test protocol v1 with 'git://' transport
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
15 test_expect_success
'create repo to be served by git-daemon' '
16 git init "$daemon_parent" &&
17 test_commit -C "$daemon_parent" one
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 &&
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 &&
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
34 test_expect_success
'fetch with git:// using protocol v1' '
35 test_commit -C "$daemon_parent" two &&
37 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
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 &&
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
50 test_expect_success
'pull with git:// using protocol v1' '
51 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
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 &&
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
64 test_expect_success
'push with git:// using protocol v1' '
65 test_commit -C daemon_child three &&
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 &&
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 &&
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
84 # Test protocol v1 with 'file://' transport
86 test_expect_success
'create repo to be served by file:// transport' '
87 git init file_parent &&
88 test_commit -C file_parent one
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 &&
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 &&
99 # Server responded using protocol v1
100 grep "clone< version 1" log
103 test_expect_success
'fetch with file:// using protocol v1' '
104 test_commit -C file_parent two &&
106 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
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 &&
113 # Server responded using protocol v1
114 grep "fetch< version 1" log
117 test_expect_success
'pull with file:// using protocol v1' '
118 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
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 &&
125 # Server responded using protocol v1
126 grep "fetch< version 1" log
129 test_expect_success
'push with file:// using protocol v1' '
130 test_commit -C file_child three &&
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 &&
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 &&
141 # Server responded using protocol v1
142 grep "push< version 1" log
145 # Test protocol v1 with 'ssh://' transport
147 test_expect_success
'setup ssh wrapper' '
148 GIT_SSH="$GIT_BUILD_DIR/t/helper/test-fake-ssh" &&
150 export TRASH_DIRECTORY &&
151 >"$TRASH_DIRECTORY"/ssh-output
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
)
160 test_expect_success
'create repo to be served by ssh:// transport' '
161 git init ssh_parent &&
162 test_commit -C ssh_parent one
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 &&
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 &&
174 # Server responded using protocol v1
175 grep "clone< version 1" log
178 test_expect_success
'fetch with ssh:// using protocol v1' '
179 test_commit -C ssh_parent two &&
181 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
183 expect_ssh git-upload-pack &&
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 &&
189 # Server responded using protocol v1
190 grep "fetch< version 1" log
193 test_expect_success
'pull with ssh:// using protocol v1' '
194 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
196 expect_ssh git-upload-pack &&
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 &&
202 # Server responded using protocol v1
203 grep "fetch< version 1" log
206 test_expect_success
'push with ssh:// using protocol v1' '
207 test_commit -C ssh_child three &&
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 &&
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 &&
219 # Server responded using protocol v1
220 grep "push< version 1" log
223 # Test protocol v1 with 'http://' transport
225 .
"$TEST_DIRECTORY"/lib-httpd.sh
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
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 &&
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 &&
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
248 test_expect_success
'fetch with http:// using protocol v1' '
249 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
251 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
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 &&
258 # Server responded using protocol v1
259 grep "git< version 1" log
262 test_expect_success
'pull with http:// using protocol v1' '
263 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
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 &&
270 # Server responded using protocol v1
271 grep "git< version 1" log
274 test_expect_success
'push with http:// using protocol v1' '
275 test_commit -C http_child three &&
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 &&
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 &&
286 # Server responded using protocol v1
287 grep "git< version 1" log