Merge branch 'jk/for-each-ref-icase'
[git/git-svn.git] / t / t5700-protocol-v1.sh
blobba86a44eb183921e844dff6f9d6a5bb27c7d5e91
1 #!/bin/sh
3 test_description='test git wire-protocol transition'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
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 \
38 fetch 2>log &&
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 \
52 pull 2>log &&
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
82 stop_git_daemon
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 \
107 fetch 2>log &&
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 \
119 pull 2>log &&
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" &&
149 export GIT_SSH &&
150 GIT_SSH_VARIANT=ssh &&
151 export GIT_SSH_VARIANT &&
152 export TRASH_DIRECTORY &&
153 >"$TRASH_DIRECTORY"/ssh-output
156 expect_ssh () {
157 test_when_finished '(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)' &&
158 echo "ssh: -o SendEnv=GIT_PROTOCOL myhost $1 '$PWD/ssh_parent'" >"$TRASH_DIRECTORY/ssh-expect" &&
159 (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
162 test_expect_success 'create repo to be served by ssh:// transport' '
163 git init ssh_parent &&
164 test_commit -C ssh_parent one
167 test_expect_success 'clone with ssh:// using protocol v1' '
168 GIT_TRACE_PACKET=1 git -c protocol.version=1 \
169 clone "ssh://myhost:$(pwd)/ssh_parent" ssh_child 2>log &&
170 expect_ssh git-upload-pack &&
172 git -C ssh_child log -1 --format=%s >actual &&
173 git -C ssh_parent log -1 --format=%s >expect &&
174 test_cmp expect actual &&
176 # Server responded using protocol v1
177 grep "clone< version 1" log
180 test_expect_success 'fetch with ssh:// using protocol v1' '
181 test_commit -C ssh_parent two &&
183 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
184 fetch 2>log &&
185 expect_ssh git-upload-pack &&
187 git -C ssh_child log -1 --format=%s origin/master >actual &&
188 git -C ssh_parent log -1 --format=%s >expect &&
189 test_cmp expect actual &&
191 # Server responded using protocol v1
192 grep "fetch< version 1" log
195 test_expect_success 'pull with ssh:// using protocol v1' '
196 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
197 pull 2>log &&
198 expect_ssh git-upload-pack &&
200 git -C ssh_child log -1 --format=%s >actual &&
201 git -C ssh_parent log -1 --format=%s >expect &&
202 test_cmp expect actual &&
204 # Server responded using protocol v1
205 grep "fetch< version 1" log
208 test_expect_success 'push with ssh:// using protocol v1' '
209 test_commit -C ssh_child three &&
211 # Push to another branch, as the target repository has the
212 # master branch checked out and we cannot push into it.
213 GIT_TRACE_PACKET=1 git -C ssh_child -c protocol.version=1 \
214 push origin HEAD:client_branch 2>log &&
215 expect_ssh git-receive-pack &&
217 git -C ssh_child log -1 --format=%s >actual &&
218 git -C ssh_parent log -1 --format=%s client_branch >expect &&
219 test_cmp expect actual &&
221 # Server responded using protocol v1
222 grep "push< version 1" log
225 # Test protocol v1 with 'http://' transport
227 . "$TEST_DIRECTORY"/lib-httpd.sh
228 start_httpd
230 test_expect_success 'create repo to be served by http:// transport' '
231 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
232 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
233 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
236 test_expect_success 'clone with http:// using protocol v1' '
237 GIT_TRACE_PACKET=1 GIT_TRACE_CURL=1 git -c protocol.version=1 \
238 clone "$HTTPD_URL/smart/http_parent" http_child 2>log &&
240 git -C http_child log -1 --format=%s >actual &&
241 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
242 test_cmp expect actual &&
244 # Client requested to use protocol v1
245 grep "Git-Protocol: version=1" log &&
246 # Server responded using protocol v1
247 grep "git< version 1" log
250 test_expect_success 'fetch with http:// using protocol v1' '
251 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
253 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
254 fetch 2>log &&
256 git -C http_child log -1 --format=%s origin/master >actual &&
257 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
258 test_cmp expect actual &&
260 # Server responded using protocol v1
261 grep "git< version 1" log
264 test_expect_success 'pull with http:// using protocol v1' '
265 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
266 pull 2>log &&
268 git -C http_child log -1 --format=%s >actual &&
269 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
270 test_cmp expect actual &&
272 # Server responded using protocol v1
273 grep "git< version 1" log
276 test_expect_success 'push with http:// using protocol v1' '
277 test_commit -C http_child three &&
279 # Push to another branch, as the target repository has the
280 # master branch checked out and we cannot push into it.
281 GIT_TRACE_PACKET=1 git -C http_child -c protocol.version=1 \
282 push origin HEAD:client_branch && #2>log &&
284 git -C http_child log -1 --format=%s >actual &&
285 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
286 test_cmp expect actual &&
288 # Server responded using protocol v1
289 grep "git< version 1" log
292 stop_httpd
294 test_done