3 test_description='test git wire-protocol transition'
7 # This is a protocol-specific test.
8 GIT_TEST_PROTOCOL_VERSION=
12 # Test protocol v1 with 'git://' transport
14 . "$TEST_DIRECTORY"/lib-git-daemon.sh
15 start_git_daemon --export-all --enable=receive-pack
16 daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
18 test_expect_success 'create repo to be served by git-daemon' '
19 git init "$daemon_parent" &&
20 test_commit -C "$daemon_parent" one
23 test_expect_success 'clone with git:// using protocol v1' '
24 GIT_TRACE_PACKET=1 git -c protocol.version=1 \
25 clone "$GIT_DAEMON_URL/parent" daemon_child 2>log &&
27 git -C daemon_child log -1 --format=%s >actual &&
28 git -C "$daemon_parent" log -1 --format=%s >expect &&
29 test_cmp expect actual &&
31 # Client requested to use protocol v1
32 grep "clone> .*\\\0\\\0version=1\\\0$" log &&
33 # Server responded using protocol v1
34 grep "clone< version 1" log
37 test_expect_success 'fetch with git:// using protocol v1' '
38 test_commit -C "$daemon_parent" two &&
40 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
43 git -C daemon_child log -1 --format=%s origin/master >actual &&
44 git -C "$daemon_parent" log -1 --format=%s >expect &&
45 test_cmp expect actual &&
47 # Client requested to use protocol v1
48 grep "fetch> .*\\\0\\\0version=1\\\0$" log &&
49 # Server responded using protocol v1
50 grep "fetch< version 1" log
53 test_expect_success 'pull with git:// using protocol v1' '
54 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
57 git -C daemon_child log -1 --format=%s >actual &&
58 git -C "$daemon_parent" log -1 --format=%s >expect &&
59 test_cmp expect actual &&
61 # Client requested to use protocol v1
62 grep "fetch> .*\\\0\\\0version=1\\\0$" log &&
63 # Server responded using protocol v1
64 grep "fetch< version 1" log
67 test_expect_success 'push with git:// using protocol v1' '
68 test_commit -C daemon_child three &&
70 # Push to another branch, as the target repository has the
71 # master branch checked out and we cannot push into it.
72 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
73 push origin HEAD:client_branch 2>log &&
75 git -C daemon_child log -1 --format=%s >actual &&
76 git -C "$daemon_parent" log -1 --format=%s client_branch >expect &&
77 test_cmp expect actual &&
79 # Client requested to use protocol v1
80 grep "push> .*\\\0\\\0version=1\\\0$" log &&
81 # Server responded using protocol v1
82 grep "push< version 1" log
87 # Test protocol v1 with 'file://' transport
89 test_expect_success 'create repo to be served by file:// transport' '
90 git init file_parent &&
91 test_commit -C file_parent one
94 test_expect_success 'clone with file:// using protocol v1' '
95 GIT_TRACE_PACKET=1 git -c protocol.version=1 \
96 clone "file://$(pwd)/file_parent" file_child 2>log &&
98 git -C file_child log -1 --format=%s >actual &&
99 git -C file_parent log -1 --format=%s >expect &&
100 test_cmp expect actual &&
102 # Server responded using protocol v1
103 grep "clone< version 1" log
106 test_expect_success 'fetch with file:// using protocol v1' '
107 test_commit -C file_parent two &&
109 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
112 git -C file_child log -1 --format=%s origin/master >actual &&
113 git -C file_parent log -1 --format=%s >expect &&
114 test_cmp expect actual &&
116 # Server responded using protocol v1
117 grep "fetch< version 1" log
120 test_expect_success 'pull with file:// using protocol v1' '
121 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
124 git -C file_child log -1 --format=%s >actual &&
125 git -C file_parent log -1 --format=%s >expect &&
126 test_cmp expect actual &&
128 # Server responded using protocol v1
129 grep "fetch< version 1" log
132 test_expect_success 'push with file:// using protocol v1' '
133 test_commit -C file_child three &&
135 # Push to another branch, as the target repository has the
136 # master branch checked out and we cannot push into it.
137 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=1 \
138 push origin HEAD:client_branch 2>log &&
140 git -C file_child log -1 --format=%s >actual &&
141 git -C file_parent log -1 --format=%s client_branch >expect &&
142 test_cmp expect actual &&
144 # Server responded using protocol v1
145 grep "push< version 1" log
148 # Test protocol v1 with 'ssh://' transport
150 test_expect_success 'setup ssh wrapper' '
151 GIT_SSH="$GIT_BUILD_DIR/t/helper/test-fake-ssh" &&
153 GIT_SSH_VARIANT=ssh &&
154 export GIT_SSH_VARIANT &&
155 export TRASH_DIRECTORY &&
156 >"$TRASH_DIRECTORY"/ssh-output
160 test_when_finished '(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)' &&
161 echo "ssh: -o SendEnv=GIT_PROTOCOL myhost $1 '$PWD/ssh_parent'" >"$TRASH_DIRECTORY/ssh-expect" &&
162 (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
165 test_expect_success 'create repo to be served by ssh:// transport' '
166 git init ssh_parent &&
167 test_commit -C ssh_parent one
170 test_expect_success 'clone with ssh:// using protocol v1' '
171 GIT_TRACE_PACKET=1 git -c protocol.version=1 \
172 clone "ssh://myhost:$(pwd)/ssh_parent" ssh_child 2>log &&
173 expect_ssh git-upload-pack &&
175 git -C ssh_child log -1 --format=%s >actual &&
176 git -C ssh_parent log -1 --format=%s >expect &&
177 test_cmp expect actual &&
179 # Server responded using protocol v1
180 grep "clone< version 1" log
183 test_expect_success 'fetch with ssh:// using protocol v1' '
184 test_commit -C ssh_parent two &&
186 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
188 expect_ssh git-upload-pack &&
190 git -C ssh_child log -1 --format=%s origin/master >actual &&
191 git -C ssh_parent log -1 --format=%s >expect &&
192 test_cmp expect actual &&
194 # Server responded using protocol v1
195 grep "fetch< version 1" log
198 test_expect_success 'pull with ssh:// using protocol v1' '
199 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
201 expect_ssh git-upload-pack &&
203 git -C ssh_child log -1 --format=%s >actual &&
204 git -C ssh_parent log -1 --format=%s >expect &&
205 test_cmp expect actual &&
207 # Server responded using protocol v1
208 grep "fetch< version 1" log
211 test_expect_success 'push with ssh:// using protocol v1' '
212 test_commit -C ssh_child three &&
214 # Push to another branch, as the target repository has the
215 # master branch checked out and we cannot push into it.
216 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
217 push origin HEAD:client_branch 2>log &&
218 expect_ssh git-receive-pack &&
220 git -C ssh_child log -1 --format=%s >actual &&
221 git -C ssh_parent log -1 --format=%s client_branch >expect &&
222 test_cmp expect actual &&
224 # Server responded using protocol v1
225 grep "push< version 1" log
228 # Test protocol v1 with 'http://' transport
230 . "$TEST_DIRECTORY"/lib-httpd.sh
233 test_expect_success 'create repo to be served by http:// transport' '
234 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
235 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
236 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
239 test_expect_success 'clone with http:// using protocol v1' '
240 GIT_TRACE_PACKET=1 GIT_TRACE_CURL=1 git -c protocol.version=1 \
241 clone "$HTTPD_URL/smart/http_parent" http_child 2>log &&
243 git -C http_child log -1 --format=%s >actual &&
244 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
245 test_cmp expect actual &&
247 # Client requested to use protocol v1
248 grep "Git-Protocol: version=1" log &&
249 # Server responded using protocol v1
250 grep "git< version 1" log
253 test_expect_success 'fetch with http:// using protocol v1' '
254 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
256 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
259 git -C http_child log -1 --format=%s origin/master >actual &&
260 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
261 test_cmp expect actual &&
263 # Server responded using protocol v1
264 grep "git< version 1" log
267 test_expect_success 'pull with http:// using protocol v1' '
268 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
271 git -C http_child log -1 --format=%s >actual &&
272 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
273 test_cmp expect actual &&
275 # Server responded using protocol v1
276 grep "git< version 1" log
279 test_expect_success 'push with http:// using protocol v1' '
280 test_commit -C http_child three &&
282 # Push to another branch, as the target repository has the
283 # master branch checked out and we cannot push into it.
284 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
285 push origin HEAD:client_branch && #2>log &&
287 git -C http_child log -1 --format=%s >actual &&
288 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
289 test_cmp expect actual &&
291 # Server responded using protocol v1
292 grep "git< version 1" log