]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5702-protocol-v2.sh
fetch: fix negotiate-only error message
[thirdparty/git.git] / t / t5702-protocol-v2.sh
CommitLineData
e52449b6
BW
1#!/bin/sh
2
3test_description='test git wire-protocol version 2'
4
5TEST_NO_CREATE_REPO=1
6
95cf2c01 7GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
8export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
e52449b6
BW
10. ./test-lib.sh
11
12# Test protocol v2 with 'git://' transport
13#
14. "$TEST_DIRECTORY"/lib-git-daemon.sh
15start_git_daemon --export-all --enable=receive-pack
16daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
17
18test_expect_success 'create repo to be served by git-daemon' '
19 git init "$daemon_parent" &&
20 test_commit -C "$daemon_parent" one
21'
22
23test_expect_success 'list refs with git:// using protocol v2' '
24 test_when_finished "rm -f log" &&
25
26 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
27 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
28
29 # Client requested to use protocol v2
30 grep "git> .*\\\0\\\0version=2\\\0$" log &&
31 # Server responded using protocol v2
32 grep "git< version 2" log &&
33
34 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
dcbaa0b3 35 test_cmp expect actual
e52449b6
BW
36'
37
4dc8b1c1 38test_expect_success 'ref advertisement is filtered with ls-remote using protocol v2' '
b4be7410
BW
39 test_when_finished "rm -f log" &&
40
41 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
95cf2c01 42 ls-remote "$GIT_DAEMON_URL/parent" main >actual &&
b4be7410
BW
43
44 cat >expect <<-EOF &&
95cf2c01 45 $(git -C "$daemon_parent" rev-parse refs/heads/main)$(printf "\t")refs/heads/main
b4be7410
BW
46 EOF
47
dcbaa0b3 48 test_cmp expect actual
b4be7410
BW
49'
50
685fbd32
BW
51test_expect_success 'clone with git:// using protocol v2' '
52 test_when_finished "rm -f log" &&
53
54 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
55 clone "$GIT_DAEMON_URL/parent" daemon_child &&
56
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 &&
60
61 # Client requested to use protocol v2
62 grep "clone> .*\\\0\\\0version=2\\\0$" log &&
63 # Server responded using protocol v2
64 grep "clone< version 2" log
65'
66
67test_expect_success 'fetch with git:// using protocol v2' '
68 test_when_finished "rm -f log" &&
69
70 test_commit -C "$daemon_parent" two &&
71
72 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
73 fetch &&
74
95cf2c01 75 git -C daemon_child log -1 --format=%s origin/main >actual &&
685fbd32
BW
76 git -C "$daemon_parent" log -1 --format=%s >expect &&
77 test_cmp expect actual &&
78
79 # Client requested to use protocol v2
80 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
81 # Server responded using protocol v2
82 grep "fetch< version 2" log
83'
84
e70a3030
JT
85test_expect_success 'fetch by hash without tag following with protocol v2 does not list refs' '
86 test_when_finished "rm -f log" &&
87
88 test_commit -C "$daemon_parent" two_a &&
89 git -C "$daemon_parent" rev-parse two_a >two_a_hash &&
90
91 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
92 fetch --no-tags origin $(cat two_a_hash) &&
93
94 grep "fetch< version 2" log &&
95 ! grep "fetch> command=ls-refs" log
96'
97
685fbd32
BW
98test_expect_success 'pull with git:// using protocol v2' '
99 test_when_finished "rm -f log" &&
100
101 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
102 pull &&
103
104 git -C daemon_child log -1 --format=%s >actual &&
105 git -C "$daemon_parent" log -1 --format=%s >expect &&
106 test_cmp expect actual &&
107
108 # Client requested to use protocol v2
109 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
110 # Server responded using protocol v2
111 grep "fetch< version 2" log
112'
113
1aa8dded
BW
114test_expect_success 'push with git:// and a config of v2 does not request v2' '
115 test_when_finished "rm -f log" &&
116
117 # Till v2 for push is designed, make sure that if a client has
118 # protocol.version configured to use v2, that the client instead falls
119 # back and uses v0.
120
121 test_commit -C daemon_child three &&
122
123 # Push to another branch, as the target repository has the
95cf2c01 124 # main branch checked out and we cannot push into it.
1aa8dded
BW
125 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
126 push origin HEAD:client_branch &&
127
128 git -C daemon_child log -1 --format=%s >actual &&
129 git -C "$daemon_parent" log -1 --format=%s client_branch >expect &&
130 test_cmp expect actual &&
131
132 # Client requested to use protocol v2
133 ! grep "push> .*\\\0\\\0version=2\\\0$" log &&
134 # Server responded using protocol v2
135 ! grep "push< version 2" log
136'
137
e52449b6
BW
138stop_git_daemon
139
140# Test protocol v2 with 'file://' transport
141#
142test_expect_success 'create repo to be served by file:// transport' '
143 git init file_parent &&
144 test_commit -C file_parent one
145'
146
147test_expect_success 'list refs with file:// using protocol v2' '
148 test_when_finished "rm -f log" &&
149
150 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
151 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
152
153 # Server responded using protocol v2
154 grep "git< version 2" log &&
155
156 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
dcbaa0b3 157 test_cmp expect actual
e52449b6
BW
158'
159
4dc8b1c1 160test_expect_success 'ref advertisement is filtered with ls-remote using protocol v2' '
b4be7410
BW
161 test_when_finished "rm -f log" &&
162
163 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
95cf2c01 164 ls-remote "file://$(pwd)/file_parent" main >actual &&
b4be7410
BW
165
166 cat >expect <<-EOF &&
95cf2c01 167 $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main
b4be7410
BW
168 EOF
169
dcbaa0b3 170 test_cmp expect actual
b4be7410
BW
171'
172
ff473221
BW
173test_expect_success 'server-options are sent when using ls-remote' '
174 test_when_finished "rm -f log" &&
175
176 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
95cf2c01 177 ls-remote -o hello -o world "file://$(pwd)/file_parent" main >actual &&
ff473221
BW
178
179 cat >expect <<-EOF &&
95cf2c01 180 $(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main
ff473221
BW
181 EOF
182
dcbaa0b3 183 test_cmp expect actual &&
ff473221
BW
184 grep "server-option=hello" log &&
185 grep "server-option=world" log
186'
187
35eb8240
JT
188test_expect_success 'warn if using server-option with ls-remote with legacy protocol' '
189 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
95cf2c01 190 ls-remote -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
35eb8240
JT
191
192 test_i18ngrep "see protocol.version in" err &&
193 test_i18ngrep "server options require protocol version 2 or later" err
194'
ff473221 195
685fbd32
BW
196test_expect_success 'clone with file:// using protocol v2' '
197 test_when_finished "rm -f log" &&
198
199 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
200 clone "file://$(pwd)/file_parent" file_child &&
201
202 git -C file_child log -1 --format=%s >actual &&
203 git -C file_parent log -1 --format=%s >expect &&
204 test_cmp expect actual &&
205
206 # Server responded using protocol v2
402c47d9
BW
207 grep "clone< version 2" log &&
208
209 # Client sent ref-prefixes to filter the ref-advertisement
210 grep "ref-prefix HEAD" log &&
211 grep "ref-prefix refs/heads/" log &&
212 grep "ref-prefix refs/tags/" log
685fbd32
BW
213'
214
4f37d457
JT
215test_expect_success 'clone of empty repo propagates name of default branch' '
216 test_when_finished "rm -rf file_empty_parent file_empty_child" &&
217
218 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
219 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
220
221 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
222 git -c init.defaultBranch=main -c protocol.version=2 \
223 clone "file://$(pwd)/file_empty_parent" file_empty_child &&
224 grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
225'
226
227test_expect_success '...but not if explicitly forbidden by config' '
228 test_when_finished "rm -rf file_empty_parent file_empty_child" &&
229
230 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
231 git -c init.defaultBranch=mydefaultbranch init file_empty_parent &&
232 test_config -C file_empty_parent lsrefs.unborn ignore &&
233
234 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
235 git -c init.defaultBranch=main -c protocol.version=2 \
236 clone "file://$(pwd)/file_empty_parent" file_empty_child &&
237 ! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
238'
239
685fbd32
BW
240test_expect_success 'fetch with file:// using protocol v2' '
241 test_when_finished "rm -f log" &&
242
243 test_commit -C file_parent two &&
244
245 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
246 fetch origin &&
247
95cf2c01 248 git -C file_child log -1 --format=%s origin/main >actual &&
685fbd32
BW
249 git -C file_parent log -1 --format=%s >expect &&
250 test_cmp expect actual &&
251
252 # Server responded using protocol v2
253 grep "fetch< version 2" log
254'
255
4dc8b1c1 256test_expect_success 'ref advertisement is filtered during fetch using protocol v2' '
685fbd32
BW
257 test_when_finished "rm -f log" &&
258
259 test_commit -C file_parent three &&
2b554353 260 git -C file_parent branch unwanted-branch three &&
685fbd32
BW
261
262 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
95cf2c01 263 fetch origin main &&
685fbd32 264
95cf2c01 265 git -C file_child log -1 --format=%s origin/main >actual &&
685fbd32
BW
266 git -C file_parent log -1 --format=%s >expect &&
267 test_cmp expect actual &&
268
95cf2c01 269 grep "refs/heads/main" log &&
2b554353 270 ! grep "refs/heads/unwanted-branch" log
685fbd32
BW
271'
272
5e3548ef
BW
273test_expect_success 'server-options are sent when fetching' '
274 test_when_finished "rm -f log" &&
275
276 test_commit -C file_parent four &&
277
278 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
95cf2c01 279 fetch -o hello -o world origin main &&
5e3548ef 280
95cf2c01 281 git -C file_child log -1 --format=%s origin/main >actual &&
5e3548ef
BW
282 git -C file_parent log -1 --format=%s >expect &&
283 test_cmp expect actual &&
284
285 grep "server-option=hello" log &&
286 grep "server-option=world" log
287'
288
35eb8240
JT
289test_expect_success 'warn if using server-option with fetch with legacy protocol' '
290 test_when_finished "rm -rf temp_child" &&
291
292 git init temp_child &&
293
294 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C temp_child -c protocol.version=0 \
95cf2c01 295 fetch -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
35eb8240
JT
296
297 test_i18ngrep "see protocol.version in" err &&
298 test_i18ngrep "server options require protocol version 2 or later" err
299'
300
6e983059
JT
301test_expect_success 'server-options are sent when cloning' '
302 test_when_finished "rm -rf log myclone" &&
303
304 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
305 clone --server-option=hello --server-option=world \
306 "file://$(pwd)/file_parent" myclone &&
307
308 grep "server-option=hello" log &&
309 grep "server-option=world" log
310'
311
312test_expect_success 'warn if using server-option with clone with legacy protocol' '
313 test_when_finished "rm -rf myclone" &&
314
315 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
316 clone --server-option=hello --server-option=world \
317 "file://$(pwd)/file_parent" myclone 2>err &&
318
319 test_i18ngrep "see protocol.version in" err &&
320 test_i18ngrep "server options require protocol version 2 or later" err
321'
322
54592687
JT
323test_expect_success 'upload-pack respects config using protocol v2' '
324 git init server &&
325 write_script server/.git/hook <<-\EOF &&
326 touch hookout
327 "$@"
328 EOF
329 test_commit -C server one &&
330
331 test_config_global uploadpack.packobjectshook ./hook &&
332 test_path_is_missing server/.git/hookout &&
333 git -c protocol.version=2 clone "file://$(pwd)/server" client &&
334 test_path_is_file server/.git/hookout
335'
336
ba95710a
JT
337test_expect_success 'setup filter tests' '
338 rm -rf server client &&
339 git init server &&
340
341 # 1 commit to create a file, and 1 commit to modify it
342 test_commit -C server message1 a.txt &&
343 test_commit -C server message2 a.txt &&
344 git -C server config protocol.version 2 &&
345 git -C server config uploadpack.allowfilter 1 &&
346 git -C server config uploadpack.allowanysha1inwant 1 &&
347 git -C server config protocol.version 2
348'
349
350test_expect_success 'partial clone' '
351 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
352 clone --filter=blob:none "file://$(pwd)/server" client &&
353 grep "version 2" trace &&
354
355 # Ensure that the old version of the file is missing
95cf2c01 356 git -C client rev-list --quiet --objects --missing=print main \
ba95710a
JT
357 >observed.oids &&
358 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
359
360 # Ensure that client passes fsck
361 git -C client fsck
362'
363
364test_expect_success 'dynamically fetch missing object' '
365 rm "$(pwd)/trace" &&
366 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
367 cat-file -p $(git -C server rev-parse message1:a.txt) &&
368 grep "version 2" trace
369'
370
01775651
JT
371test_expect_success 'when dynamically fetching missing object, do not list refs' '
372 ! grep "git> command=ls-refs" trace
373'
374
ba95710a
JT
375test_expect_success 'partial fetch' '
376 rm -rf client "$(pwd)/trace" &&
377 git init client &&
378 SERVER="file://$(pwd)/server" &&
ba95710a
JT
379
380 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
95cf2c01 381 fetch --filter=blob:none "$SERVER" main:refs/heads/other &&
ba95710a
JT
382 grep "version 2" trace &&
383
384 # Ensure that the old version of the file is missing
8d6ba495 385 git -C client rev-list --quiet --objects --missing=print other \
ba95710a
JT
386 >observed.oids &&
387 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
388
389 # Ensure that client passes fsck
390 git -C client fsck
391'
392
393test_expect_success 'do not advertise filter if not configured to do so' '
394 SERVER="file://$(pwd)/server" &&
395
396 rm "$(pwd)/trace" &&
397 git -C server config uploadpack.allowfilter 1 &&
398 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
399 ls-remote "$SERVER" &&
400 grep "fetch=.*filter" trace &&
401
402 rm "$(pwd)/trace" &&
403 git -C server config uploadpack.allowfilter 0 &&
404 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
405 ls-remote "$SERVER" &&
406 grep "fetch=" trace >fetch_capabilities &&
407 ! grep filter fetch_capabilities
408'
409
410test_expect_success 'partial clone warns if filter is not advertised' '
411 rm -rf client &&
412 git -C server config uploadpack.allowfilter 0 &&
413 git -c protocol.version=2 \
414 clone --filter=blob:none "file://$(pwd)/server" client 2>err &&
415 test_i18ngrep "filtering not recognized by server, ignoring" err
416'
417
418test_expect_success 'even with handcrafted request, filter does not work if not advertised' '
419 git -C server config uploadpack.allowfilter 0 &&
420
421 # Custom request that tries to filter even though it is not advertised.
8ea40cc5 422 test-tool pkt-line pack >in <<-EOF &&
ba95710a 423 command=fetch
8fc70035 424 object-format=$(test_oid algo)
ba95710a 425 0001
95cf2c01 426 want $(git -C server rev-parse main)
ba95710a
JT
427 filter blob:none
428 0000
429 EOF
430
b7ce24d0
JS
431 test_must_fail test-tool -C server serve-v2 --stateless-rpc \
432 <in >/dev/null 2>err &&
ba95710a
JT
433 grep "unexpected line: .filter blob:none." err &&
434
435 # Exercise to ensure that if advertised, filter works
436 git -C server config uploadpack.allowfilter 1 &&
b7ce24d0 437 test-tool -C server serve-v2 --stateless-rpc <in >/dev/null
ba95710a
JT
438'
439
dcc73cf7
BW
440test_expect_success 'default refspec is used to filter ref when fetchcing' '
441 test_when_finished "rm -f log" &&
442
443 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
444 fetch origin &&
445
446 git -C file_child log -1 --format=%s three >actual &&
447 git -C file_parent log -1 --format=%s three >expect &&
448 test_cmp expect actual &&
449
450 grep "ref-prefix refs/heads/" log &&
451 grep "ref-prefix refs/tags/" log
452'
453
15cfc985
JT
454test_expect_success 'fetch supports various ways of have lines' '
455 rm -rf server client trace &&
456 git init server &&
457 test_commit -C server dwim &&
458 TREE=$(git -C server rev-parse HEAD^{tree}) &&
459 git -C server tag exact \
460 $(git -C server commit-tree -m a "$TREE") &&
461 git -C server tag dwim-unwanted \
462 $(git -C server commit-tree -m b "$TREE") &&
463 git -C server tag exact-unwanted \
464 $(git -C server commit-tree -m c "$TREE") &&
465 git -C server tag prefix1 \
466 $(git -C server commit-tree -m d "$TREE") &&
467 git -C server tag prefix2 \
468 $(git -C server commit-tree -m e "$TREE") &&
469 git -C server tag fetch-by-sha1 \
470 $(git -C server commit-tree -m f "$TREE") &&
471 git -C server tag completely-unrelated \
472 $(git -C server commit-tree -m g "$TREE") &&
473
474 git init client &&
475 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
476 fetch "file://$(pwd)/server" \
477 dwim \
478 refs/tags/exact \
479 refs/tags/prefix*:refs/tags/prefix* \
480 "$(git -C server rev-parse fetch-by-sha1)" &&
481
482 # Ensure that the appropriate prefixes are sent (using a sample)
483 grep "fetch> ref-prefix dwim" trace &&
484 grep "fetch> ref-prefix refs/heads/dwim" trace &&
485 grep "fetch> ref-prefix refs/tags/prefix" trace &&
486
487 # Ensure that the correct objects are returned
488 git -C client cat-file -e $(git -C server rev-parse dwim) &&
489 git -C client cat-file -e $(git -C server rev-parse exact) &&
490 git -C client cat-file -e $(git -C server rev-parse prefix1) &&
491 git -C client cat-file -e $(git -C server rev-parse prefix2) &&
492 git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) &&
493 test_must_fail git -C client cat-file -e \
494 $(git -C server rev-parse dwim-unwanted) &&
495 test_must_fail git -C client cat-file -e \
496 $(git -C server rev-parse exact-unwanted) &&
497 test_must_fail git -C client cat-file -e \
498 $(git -C server rev-parse completely-unrelated)
499'
500
2b554353
JT
501test_expect_success 'fetch supports include-tag and tag following' '
502 rm -rf server client trace &&
503 git init server &&
504
505 test_commit -C server to_fetch &&
506 git -C server tag -a annotated_tag -m message &&
507
508 git init client &&
509 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
510 fetch "$(pwd)/server" to_fetch:to_fetch &&
511
512 grep "fetch> ref-prefix to_fetch" trace &&
513 grep "fetch> ref-prefix refs/tags/" trace &&
514 grep "fetch> include-tag" trace &&
515
516 git -C client cat-file -e $(git -C client rev-parse annotated_tag)
517'
518
d1035cac
JT
519test_expect_success 'upload-pack respects client shallows' '
520 rm -rf server client trace &&
521
522 git init server &&
523 test_commit -C server base &&
524 test_commit -C server client_has &&
525
526 git clone --depth=1 "file://$(pwd)/server" client &&
527
528 # Add extra commits to the client so that the whole fetch takes more
529 # than 1 request (due to negotiation)
9516345e 530 test_commit_bulk -C client --id=c 32 &&
d1035cac
JT
531
532 git -C server checkout -b newbranch base &&
533 test_commit -C server client_wants &&
534
535 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
536 fetch origin newbranch &&
537 # Ensure that protocol v2 is used
538 grep "fetch< version 2" trace
bd0b42ae
JT
539'
540
541test_expect_success 'ensure that multiple fetches in same process from a shallow repo works' '
542 rm -rf server client trace &&
543
544 test_create_repo server &&
545 test_commit -C server one &&
546 test_commit -C server two &&
547 test_commit -C server three &&
548 git clone --shallow-exclude two "file://$(pwd)/server" client &&
549
550 git -C server tag -a -m "an annotated tag" twotag two &&
551
552 # Triggers tag following (thus, 2 fetches in one process)
553 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
554 fetch --shallow-exclude one origin &&
555 # Ensure that protocol v2 is used
556 grep "fetch< version 2" trace
d1035cac
JT
557'
558
5056cf4a
JT
559test_expect_success 'deepen-relative' '
560 rm -rf server client trace &&
561
562 test_create_repo server &&
563 test_commit -C server one &&
564 test_commit -C server two &&
565 test_commit -C server three &&
566 git clone --depth 1 "file://$(pwd)/server" client &&
567 test_commit -C server four &&
568
569 # Sanity check that only "three" is downloaded
95cf2c01 570 git -C client log --pretty=tformat:%s main >actual &&
5056cf4a
JT
571 echo three >expected &&
572 test_cmp expected actual &&
573
574 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
575 fetch --deepen=1 origin &&
576 # Ensure that protocol v2 is used
577 grep "fetch< version 2" trace &&
578
95cf2c01 579 git -C client log --pretty=tformat:%s origin/main >actual &&
5056cf4a
JT
580 cat >expected <<-\EOF &&
581 four
582 three
583 two
584 EOF
585 test_cmp expected actual
586'
587
9c1e657a
JT
588setup_negotiate_only () {
589 SERVER="$1"
590 URI="$2"
591
592 rm -rf "$SERVER" client
593
594 git init "$SERVER"
595 test_commit -C "$SERVER" one
596 test_commit -C "$SERVER" two
597
598 git clone "$URI" client
599 test_commit -C client three
600}
601
eff40457
ÆAB
602test_expect_success 'usage: --negotiate-only without --negotiation-tip' '
603 SERVER="server" &&
604 URI="file://$(pwd)/server" &&
605
606 setup_negotiate_only "$SERVER" "$URI" &&
607
608 cat >err.expect <<-\EOF &&
2826ffad 609 fatal: --negotiate-only needs one or more --negotiation-tip=*
eff40457
ÆAB
610 EOF
611
612 test_must_fail git -c protocol.version=2 -C client fetch \
613 --negotiate-only \
614 origin 2>err.actual &&
615 test_cmp err.expect err.actual
616'
617
9c1e657a
JT
618test_expect_success 'file:// --negotiate-only' '
619 SERVER="server" &&
620 URI="file://$(pwd)/server" &&
621
622 setup_negotiate_only "$SERVER" "$URI" &&
623
624 git -c protocol.version=2 -C client fetch \
625 --no-tags \
626 --negotiate-only \
627 --negotiation-tip=$(git -C client rev-parse HEAD) \
628 origin >out &&
629 COMMON=$(git -C "$SERVER" rev-parse two) &&
630 grep "$COMMON" out
631'
632
633test_expect_success 'file:// --negotiate-only with protocol v0' '
634 SERVER="server" &&
635 URI="file://$(pwd)/server" &&
636
637 setup_negotiate_only "$SERVER" "$URI" &&
638
639 test_must_fail git -c protocol.version=0 -C client fetch \
640 --no-tags \
641 --negotiate-only \
642 --negotiation-tip=$(git -C client rev-parse HEAD) \
643 origin 2>err &&
644 test_i18ngrep "negotiate-only requires protocol v2" err
645'
646
0f1dc53f
BW
647# Test protocol v2 with 'http://' transport
648#
649. "$TEST_DIRECTORY"/lib-httpd.sh
650start_httpd
651
652test_expect_success 'create repo to be served by http:// transport' '
653 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
654 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
655 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
656'
657
658test_expect_success 'clone with http:// using protocol v2' '
659 test_when_finished "rm -f log" &&
660
661 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
662 clone "$HTTPD_URL/smart/http_parent" http_child &&
663
664 git -C http_child log -1 --format=%s >actual &&
665 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
666 test_cmp expect actual &&
667
668 # Client requested to use protocol v2
669 grep "Git-Protocol: version=2" log &&
670 # Server responded using protocol v2
a97d0079
JT
671 grep "git< version 2" log &&
672 # Verify that the chunked encoding sending codepath is NOT exercised
673 ! grep "Send header: Transfer-Encoding: chunked" log
674'
675
74b082ad
DL
676test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline length' '
677 test_when_finished "rm -f log" &&
678
679 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" &&
680 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" file &&
681
682 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
683 clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err &&
684
685 # Client requested to use protocol v2
686 grep "Git-Protocol: version=2" log &&
687 # Server responded using protocol v2
688 grep "git< version 2" log &&
689 # Client reported appropriate failure
690 test_i18ngrep "bytes of length header were received" err
691'
692
693test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline body' '
694 test_when_finished "rm -f log" &&
695
696 git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" &&
697 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" file &&
698
699 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
700 clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err &&
701
702 # Client requested to use protocol v2
703 grep "Git-Protocol: version=2" log &&
704 # Server responded using protocol v2
705 grep "git< version 2" log &&
706 # Client reported appropriate failure
707 test_i18ngrep "bytes of body are still expected" err
708'
709
b0df0c16
DL
710test_expect_success 'clone with http:// using protocol v2 and invalid parameters' '
711 test_when_finished "rm -f log" &&
712
713 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \
714 git -c protocol.version=2 \
715 clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid &&
716
717 # Client requested to use protocol v2
718 grep "Git-Protocol: version=2" log &&
719 # Server responded using protocol v2
720 grep "git< version 2" log
721'
722
a97d0079
JT
723test_expect_success 'clone big repository with http:// using protocol v2' '
724 test_when_finished "rm -f log" &&
725
726 git init "$HTTPD_DOCUMENT_ROOT_PATH/big" &&
727 # Ensure that the list of wants is greater than http.postbuffer below
728 for i in $(test_seq 1 1500)
729 do
730 # do not use here-doc, because it requires a process
731 # per loop iteration
732 echo "commit refs/heads/too-many-refs-$i" &&
733 echo "committer git <git@example.com> $i +0000" &&
734 echo "data 0" &&
735 echo "M 644 inline bla.txt" &&
736 echo "data 4" &&
737 echo "bla"
738 done | git -C "$HTTPD_DOCUMENT_ROOT_PATH/big" fast-import &&
739
740 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git \
741 -c protocol.version=2 -c http.postbuffer=65536 \
742 clone "$HTTPD_URL/smart/big" big_child &&
743
744 # Client requested to use protocol v2
745 grep "Git-Protocol: version=2" log &&
746 # Server responded using protocol v2
747 grep "git< version 2" log &&
748 # Verify that the chunked encoding sending codepath is exercised
749 grep "Send header: Transfer-Encoding: chunked" log
0f1dc53f
BW
750'
751
752test_expect_success 'fetch with http:// using protocol v2' '
753 test_when_finished "rm -f log" &&
754
755 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
756
757 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
758 fetch &&
759
95cf2c01 760 git -C http_child log -1 --format=%s origin/main >actual &&
0f1dc53f
BW
761 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
762 test_cmp expect actual &&
763
764 # Server responded using protocol v2
765 grep "git< version 2" log
766'
767
ac3fda82
JT
768test_expect_success 'fetch with http:// by hash without tag following with protocol v2 does not list refs' '
769 test_when_finished "rm -f log" &&
770
771 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two_a &&
772 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" rev-parse two_a >two_a_hash &&
773
774 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
775 fetch --no-tags origin $(cat two_a_hash) &&
776
777 grep "fetch< version 2" log &&
778 ! grep "fetch> command=ls-refs" log
779'
780
e2f41a0a
JT
781test_expect_success 'fetch from namespaced repo respects namespaces' '
782 test_when_finished "rm -f log" &&
783
784 git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
785 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
786 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
787 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
95cf2c01 788 update-ref refs/namespaces/ns/refs/heads/main one &&
e2f41a0a
JT
789
790 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
791 fetch "$HTTPD_URL/smart_namespace/nsrepo" \
95cf2c01 792 refs/heads/main:refs/heads/theirs &&
e2f41a0a
JT
793
794 # Server responded using protocol v2
795 grep "fetch< version 2" log &&
796
797 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
798 git -C http_child rev-parse theirs >actual &&
799 test_cmp expect actual
800'
801
4d8cab95
JK
802test_expect_success 'ls-remote with v2 http sends only one POST' '
803 test_when_finished "rm -f log" &&
804
805 git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
806 GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
807 ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
808 test_cmp expect actual &&
809
810 grep "Send header: POST" log >posts &&
811 test_line_count = 1 posts
812'
813
a4d78ce2
BW
814test_expect_success 'push with http:// and a config of v2 does not request v2' '
815 test_when_finished "rm -f log" &&
816 # Till v2 for push is designed, make sure that if a client has
817 # protocol.version configured to use v2, that the client instead falls
818 # back and uses v0.
819
820 test_commit -C http_child three &&
821
822 # Push to another branch, as the target repository has the
95cf2c01 823 # main branch checked out and we cannot push into it.
a4d78ce2
BW
824 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
825 push origin HEAD:client_branch &&
826
827 git -C http_child log -1 --format=%s >actual &&
828 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
829 test_cmp expect actual &&
830
7a40cf15 831 # Client did not request to use protocol v2
a4d78ce2 832 ! grep "Git-Protocol: version=2" log &&
7a40cf15 833 # Server did not respond using protocol v2
a4d78ce2
BW
834 ! grep "git< version 2" log
835'
836
5400b2a2
JT
837test_expect_success 'when server sends "ready", expect DELIM' '
838 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child &&
839
840 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
841 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
842
843 git clone "$HTTPD_URL/smart/http_parent" http_child &&
844
845 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
846
847 # After "ready" in the acknowledgments section, pretend that a FLUSH
848 # (0000) was sent instead of a DELIM (0001).
eafff6e4
JS
849 printf "\$ready = 1 if /ready/; \$ready && s/0001/0000/" \
850 >"$HTTPD_ROOT_PATH/one-time-perl" &&
5400b2a2
JT
851
852 test_must_fail git -C http_child -c protocol.version=2 \
eafff6e4 853 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
5400b2a2
JT
854 test_i18ngrep "expected packfile to be sent after .ready." err
855'
856
857test_expect_success 'when server does not send "ready", expect FLUSH' '
858 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log &&
859
860 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
861 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
862
863 git clone "$HTTPD_URL/smart/http_parent" http_child &&
864
865 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
866
867 # Create many commits to extend the negotiation phase across multiple
868 # requests, so that the server does not send "ready" in the first
869 # request.
9516345e 870 test_commit_bulk -C http_child --id=c 32 &&
5400b2a2
JT
871
872 # After the acknowledgments section, pretend that a DELIM
873 # (0001) was sent instead of a FLUSH (0000).
eafff6e4
JS
874 printf "\$ack = 1 if /acknowledgments/; \$ack && s/0000/0001/" \
875 >"$HTTPD_ROOT_PATH/one-time-perl" &&
5400b2a2
JT
876
877 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
878 -c protocol.version=2 \
eafff6e4 879 fetch "$HTTPD_URL/one_time_perl/http_parent" 2> err &&
07c3c2aa
JT
880 grep "fetch< .*acknowledgments" log &&
881 ! grep "fetch< .*ready" log &&
5400b2a2
JT
882 test_i18ngrep "expected no other sections to be sent after no .ready." err
883'
a4d78ce2 884
dd4b732d
JT
885configure_exclusion () {
886 git -C "$1" hash-object "$2" >objh &&
887 git -C "$1" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
888 git -C "$1" config --add \
889 "uploadpack.blobpackfileuri" \
890 "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
891 cat objh
892}
893
894test_expect_success 'part of packfile response provided as URI' '
895 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
896 rm -rf "$P" http_child log &&
897
898 git init "$P" &&
899 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
900
901 echo my-blob >"$P/my-blob" &&
902 git -C "$P" add my-blob &&
903 echo other-blob >"$P/other-blob" &&
904 git -C "$P" add other-blob &&
905 git -C "$P" commit -m x &&
906
907 configure_exclusion "$P" my-blob >h &&
908 configure_exclusion "$P" other-blob >h2 &&
909
910 GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
911 git -c protocol.version=2 \
912 -c fetch.uriprotocols=http,https \
913 clone "$HTTPD_URL/smart/http_parent" http_child &&
914
915 # Ensure that my-blob and other-blob are in separate packfiles.
916 for idx in http_child/.git/objects/pack/*.idx
917 do
e74b606d 918 git verify-pack --object-format=$(test_oid algo) --verbose $idx >out &&
dd4b732d
JT
919 {
920 grep "^[0-9a-f]\{16,\} " out || :
921 } >out.objectlist &&
922 if test_line_count = 1 out.objectlist
923 then
924 if grep $(cat h) out
925 then
926 >hfound
927 fi &&
928 if grep $(cat h2) out
929 then
930 >h2found
931 fi
932 fi
933 done &&
934 test -f hfound &&
935 test -f h2found &&
936
5476e1ef
JT
937 # Ensure that there are exactly 3 packfiles with associated .idx
938 ls http_child/.git/objects/pack/*.pack \
939 http_child/.git/objects/pack/*.idx >filelist &&
dd4b732d
JT
940 test_line_count = 6 filelist
941'
942
2aec3bc4
JT
943test_expect_success 'packfile URIs with fetch instead of clone' '
944 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
945 rm -rf "$P" http_child log &&
946
947 git init "$P" &&
948 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
949
950 echo my-blob >"$P/my-blob" &&
951 git -C "$P" add my-blob &&
952 git -C "$P" commit -m x &&
953
954 configure_exclusion "$P" my-blob >h &&
955
956 git init http_child &&
957
958 GIT_TEST_SIDEBAND_ALL=1 \
959 git -C http_child -c protocol.version=2 \
960 -c fetch.uriprotocols=http,https \
961 fetch "$HTTPD_URL/smart/http_parent"
962'
963
dd4b732d
JT
964test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
965 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
966 rm -rf "$P" http_child log &&
967
968 git init "$P" &&
969 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
970
971 echo my-blob >"$P/my-blob" &&
972 git -C "$P" add my-blob &&
973 echo other-blob >"$P/other-blob" &&
974 git -C "$P" add other-blob &&
975 git -C "$P" commit -m x &&
976
977 configure_exclusion "$P" my-blob >h &&
978 # Configure a URL for other-blob. Just reuse the hash of the object as
979 # the hash of the packfile, since the hash does not matter for this
980 # test as long as it is not the hash of the pack, and it is of the
981 # expected length.
982 git -C "$P" hash-object other-blob >objh &&
983 git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
984 git -C "$P" config --add \
985 "uploadpack.blobpackfileuri" \
986 "$(cat objh) $(cat objh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
987
988 test_must_fail env GIT_TEST_SIDEBAND_ALL=1 \
989 git -c protocol.version=2 \
990 -c fetch.uriprotocols=http,https \
991 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
992 test_i18ngrep "pack downloaded from.*does not match expected hash" err
993'
994
0bd96bea
JT
995test_expect_success 'packfile-uri with transfer.fsckobjects' '
996 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
997 rm -rf "$P" http_child log &&
998
999 git init "$P" &&
1000 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1001
1002 echo my-blob >"$P/my-blob" &&
1003 git -C "$P" add my-blob &&
1004 git -C "$P" commit -m x &&
1005
1006 configure_exclusion "$P" my-blob >h &&
1007
1008 sane_unset GIT_TEST_SIDEBAND_ALL &&
1009 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1010 -c fetch.uriprotocols=http,https \
1011 clone "$HTTPD_URL/smart/http_parent" http_child &&
1012
5476e1ef
JT
1013 # Ensure that there are exactly 2 packfiles with associated .idx
1014 ls http_child/.git/objects/pack/*.pack \
1015 http_child/.git/objects/pack/*.idx >filelist &&
0bd96bea
JT
1016 test_line_count = 4 filelist
1017'
1018
1019test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' '
1020 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1021 rm -rf "$P" http_child log &&
1022
1023 git init "$P" &&
1024 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1025
1026 cat >bogus-commit <<-EOF &&
1027 tree $EMPTY_TREE
1028 author Bugs Bunny 1234567890 +0000
1029 committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
1030
1031 This commit object intentionally broken
1032 EOF
1033 BOGUS=$(git -C "$P" hash-object -t commit -w --stdin <bogus-commit) &&
1034 git -C "$P" branch bogus-branch "$BOGUS" &&
1035
1036 echo my-blob >"$P/my-blob" &&
1037 git -C "$P" add my-blob &&
1038 git -C "$P" commit -m x &&
1039
1040 configure_exclusion "$P" my-blob >h &&
1041
1042 sane_unset GIT_TEST_SIDEBAND_ALL &&
1043 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1044 -c fetch.uriprotocols=http,https \
1045 clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
1046 test_i18ngrep "invalid author/committer line - missing email" error
1047'
1048
5476e1ef
JT
1049test_expect_success 'packfile-uri with transfer.fsckobjects succeeds when .gitmodules is separate from tree' '
1050 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1051 rm -rf "$P" http_child &&
1052
1053 git init "$P" &&
1054 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1055
1056 echo "[submodule libfoo]" >"$P/.gitmodules" &&
1057 echo "path = include/foo" >>"$P/.gitmodules" &&
1058 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1059 git -C "$P" add .gitmodules &&
1060 git -C "$P" commit -m x &&
1061
1062 configure_exclusion "$P" .gitmodules >h &&
1063
1064 sane_unset GIT_TEST_SIDEBAND_ALL &&
1065 git -c protocol.version=2 -c transfer.fsckobjects=1 \
1066 -c fetch.uriprotocols=http,https \
1067 clone "$HTTPD_URL/smart/http_parent" http_child &&
1068
1069 # Ensure that there are exactly 2 packfiles with associated .idx
1070 ls http_child/.git/objects/pack/*.pack \
1071 http_child/.git/objects/pack/*.idx >filelist &&
1072 test_line_count = 4 filelist
1073'
1074
1075test_expect_success 'packfile-uri with transfer.fsckobjects fails when .gitmodules separate from tree is invalid' '
1076 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1077 rm -rf "$P" http_child err &&
1078
1079 git init "$P" &&
1080 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
1081
1082 echo "[submodule \"..\"]" >"$P/.gitmodules" &&
1083 echo "path = include/foo" >>"$P/.gitmodules" &&
1084 echo "url = git://example.com/git/lib.git" >>"$P/.gitmodules" &&
1085 git -C "$P" add .gitmodules &&
1086 git -C "$P" commit -m x &&
1087
1088 configure_exclusion "$P" .gitmodules >h &&
1089
1090 sane_unset GIT_TEST_SIDEBAND_ALL &&
1091 test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
1092 -c fetch.uriprotocols=http,https \
1093 clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
1094 test_i18ngrep "disallowed submodule name" err
1095'
1096
9c1e657a
JT
1097test_expect_success 'http:// --negotiate-only' '
1098 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1099 URI="$HTTPD_URL/smart/server" &&
1100
1101 setup_negotiate_only "$SERVER" "$URI" &&
1102
1103 git -c protocol.version=2 -C client fetch \
1104 --no-tags \
1105 --negotiate-only \
1106 --negotiation-tip=$(git -C client rev-parse HEAD) \
1107 origin >out &&
1108 COMMON=$(git -C "$SERVER" rev-parse two) &&
1109 grep "$COMMON" out
1110'
1111
1112test_expect_success 'http:// --negotiate-only without wait-for-done support' '
1113 SERVER="server" &&
1114 URI="$HTTPD_URL/one_time_perl/server" &&
1115
1116 setup_negotiate_only "$SERVER" "$URI" &&
1117
1118 echo "s/ wait-for-done/ xxxx-xxx-xxxx/" \
1119 >"$HTTPD_ROOT_PATH/one-time-perl" &&
1120
1121 test_must_fail git -c protocol.version=2 -C client fetch \
1122 --no-tags \
1123 --negotiate-only \
1124 --negotiation-tip=$(git -C client rev-parse HEAD) \
1125 origin 2>err &&
1126 test_i18ngrep "server does not support wait-for-done" err
1127'
1128
1129test_expect_success 'http:// --negotiate-only with protocol v0' '
1130 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
1131 URI="$HTTPD_URL/smart/server" &&
1132
1133 setup_negotiate_only "$SERVER" "$URI" &&
1134
1135 test_must_fail git -c protocol.version=0 -C client fetch \
1136 --no-tags \
1137 --negotiate-only \
1138 --negotiation-tip=$(git -C client rev-parse HEAD) \
1139 origin 2>err &&
1140 test_i18ngrep "negotiate-only requires protocol v2" err
1141'
1142
decfe05b
SG
1143# DO NOT add non-httpd-specific tests here, because the last part of this
1144# test script is only executed when httpd is available and enabled.
1145
e52449b6 1146test_done