]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5702-protocol-v2.sh
e112b6086c96e4cb0ad7bc10dcd685e7570d496f
[thirdparty/git.git] / t / t5702-protocol-v2.sh
1 #!/bin/sh
2
3 test_description='test git wire-protocol version 2'
4
5 TEST_NO_CREATE_REPO=1
6
7 . ./test-lib.sh
8
9 # Test protocol v2 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 'list refs with git:// using protocol v2' '
21 test_when_finished "rm -f log" &&
22
23 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
24 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
25
26 # Client requested to use protocol v2
27 grep "git> .*\\\0\\\0version=2\\\0$" log &&
28 # Server responded using protocol v2
29 grep "git< version 2" log &&
30
31 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
32 test_cmp expect actual
33 '
34
35 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
36 test_when_finished "rm -f log" &&
37
38 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
39 ls-remote "$GIT_DAEMON_URL/parent" master >actual &&
40
41 cat >expect <<-EOF &&
42 $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
43 EOF
44
45 test_cmp expect actual
46 '
47
48 test_expect_success 'clone with git:// using protocol v2' '
49 test_when_finished "rm -f log" &&
50
51 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
52 clone "$GIT_DAEMON_URL/parent" daemon_child &&
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 v2
59 grep "clone> .*\\\0\\\0version=2\\\0$" log &&
60 # Server responded using protocol v2
61 grep "clone< version 2" log
62 '
63
64 test_expect_success 'fetch with git:// using protocol v2' '
65 test_when_finished "rm -f log" &&
66
67 test_commit -C "$daemon_parent" two &&
68
69 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
70 fetch &&
71
72 git -C daemon_child log -1 --format=%s origin/master >actual &&
73 git -C "$daemon_parent" log -1 --format=%s >expect &&
74 test_cmp expect actual &&
75
76 # Client requested to use protocol v2
77 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
78 # Server responded using protocol v2
79 grep "fetch< version 2" log
80 '
81
82 test_expect_success 'fetch by hash without tag following with protocol v2 does not list refs' '
83 test_when_finished "rm -f log" &&
84
85 test_commit -C "$daemon_parent" two_a &&
86 git -C "$daemon_parent" rev-parse two_a >two_a_hash &&
87
88 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
89 fetch --no-tags origin $(cat two_a_hash) &&
90
91 grep "fetch< version 2" log &&
92 ! grep "fetch> command=ls-refs" log
93 '
94
95 test_expect_success 'pull with git:// using protocol v2' '
96 test_when_finished "rm -f log" &&
97
98 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
99 pull &&
100
101 git -C daemon_child log -1 --format=%s >actual &&
102 git -C "$daemon_parent" log -1 --format=%s >expect &&
103 test_cmp expect actual &&
104
105 # Client requested to use protocol v2
106 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
107 # Server responded using protocol v2
108 grep "fetch< version 2" log
109 '
110
111 test_expect_success 'push with git:// and a config of v2 does not request v2' '
112 test_when_finished "rm -f log" &&
113
114 # Till v2 for push is designed, make sure that if a client has
115 # protocol.version configured to use v2, that the client instead falls
116 # back and uses v0.
117
118 test_commit -C daemon_child three &&
119
120 # Push to another branch, as the target repository has the
121 # master branch checked out and we cannot push into it.
122 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
123 push origin HEAD:client_branch &&
124
125 git -C daemon_child log -1 --format=%s >actual &&
126 git -C "$daemon_parent" log -1 --format=%s client_branch >expect &&
127 test_cmp expect actual &&
128
129 # Client requested to use protocol v2
130 ! grep "push> .*\\\0\\\0version=2\\\0$" log &&
131 # Server responded using protocol v2
132 ! grep "push< version 2" log
133 '
134
135 stop_git_daemon
136
137 # Test protocol v2 with 'file://' transport
138 #
139 test_expect_success 'create repo to be served by file:// transport' '
140 git init file_parent &&
141 test_commit -C file_parent one
142 '
143
144 test_expect_success 'list refs with file:// using protocol v2' '
145 test_when_finished "rm -f log" &&
146
147 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
148 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
149
150 # Server responded using protocol v2
151 grep "git< version 2" log &&
152
153 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
154 test_cmp expect actual
155 '
156
157 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
158 test_when_finished "rm -f log" &&
159
160 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
161 ls-remote "file://$(pwd)/file_parent" master >actual &&
162
163 cat >expect <<-EOF &&
164 $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
165 EOF
166
167 test_cmp expect actual
168 '
169
170 test_expect_success 'server-options are sent when using ls-remote' '
171 test_when_finished "rm -f log" &&
172
173 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
174 ls-remote -o hello -o world "file://$(pwd)/file_parent" master >actual &&
175
176 cat >expect <<-EOF &&
177 $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
178 EOF
179
180 test_cmp expect actual &&
181 grep "server-option=hello" log &&
182 grep "server-option=world" log
183 '
184
185
186 test_expect_success 'clone with file:// using protocol v2' '
187 test_when_finished "rm -f log" &&
188
189 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
190 clone "file://$(pwd)/file_parent" file_child &&
191
192 git -C file_child log -1 --format=%s >actual &&
193 git -C file_parent log -1 --format=%s >expect &&
194 test_cmp expect actual &&
195
196 # Server responded using protocol v2
197 grep "clone< version 2" log &&
198
199 # Client sent ref-prefixes to filter the ref-advertisement
200 grep "ref-prefix HEAD" log &&
201 grep "ref-prefix refs/heads/" log &&
202 grep "ref-prefix refs/tags/" log
203 '
204
205 test_expect_success 'fetch with file:// using protocol v2' '
206 test_when_finished "rm -f log" &&
207
208 test_commit -C file_parent two &&
209
210 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
211 fetch origin &&
212
213 git -C file_child log -1 --format=%s origin/master >actual &&
214 git -C file_parent log -1 --format=%s >expect &&
215 test_cmp expect actual &&
216
217 # Server responded using protocol v2
218 grep "fetch< version 2" log
219 '
220
221 test_expect_success 'ref advertisment is filtered during fetch using protocol v2' '
222 test_when_finished "rm -f log" &&
223
224 test_commit -C file_parent three &&
225 git -C file_parent branch unwanted-branch three &&
226
227 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
228 fetch origin master &&
229
230 git -C file_child log -1 --format=%s origin/master >actual &&
231 git -C file_parent log -1 --format=%s >expect &&
232 test_cmp expect actual &&
233
234 grep "refs/heads/master" log &&
235 ! grep "refs/heads/unwanted-branch" log
236 '
237
238 test_expect_success 'server-options are sent when fetching' '
239 test_when_finished "rm -f log" &&
240
241 test_commit -C file_parent four &&
242
243 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
244 fetch -o hello -o world origin master &&
245
246 git -C file_child log -1 --format=%s origin/master >actual &&
247 git -C file_parent log -1 --format=%s >expect &&
248 test_cmp expect actual &&
249
250 grep "server-option=hello" log &&
251 grep "server-option=world" log
252 '
253
254 test_expect_success 'upload-pack respects config using protocol v2' '
255 git init server &&
256 write_script server/.git/hook <<-\EOF &&
257 touch hookout
258 "$@"
259 EOF
260 test_commit -C server one &&
261
262 test_config_global uploadpack.packobjectshook ./hook &&
263 test_path_is_missing server/.git/hookout &&
264 git -c protocol.version=2 clone "file://$(pwd)/server" client &&
265 test_path_is_file server/.git/hookout
266 '
267
268 test_expect_success 'setup filter tests' '
269 rm -rf server client &&
270 git init server &&
271
272 # 1 commit to create a file, and 1 commit to modify it
273 test_commit -C server message1 a.txt &&
274 test_commit -C server message2 a.txt &&
275 git -C server config protocol.version 2 &&
276 git -C server config uploadpack.allowfilter 1 &&
277 git -C server config uploadpack.allowanysha1inwant 1 &&
278 git -C server config protocol.version 2
279 '
280
281 test_expect_success 'partial clone' '
282 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
283 clone --filter=blob:none "file://$(pwd)/server" client &&
284 grep "version 2" trace &&
285
286 # Ensure that the old version of the file is missing
287 git -C client rev-list --quiet --objects --missing=print master \
288 >observed.oids &&
289 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
290
291 # Ensure that client passes fsck
292 git -C client fsck
293 '
294
295 test_expect_success 'dynamically fetch missing object' '
296 rm "$(pwd)/trace" &&
297 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
298 cat-file -p $(git -C server rev-parse message1:a.txt) &&
299 grep "version 2" trace
300 '
301
302 test_expect_success 'when dynamically fetching missing object, do not list refs' '
303 ! grep "git> command=ls-refs" trace
304 '
305
306 test_expect_success 'partial fetch' '
307 rm -rf client "$(pwd)/trace" &&
308 git init client &&
309 SERVER="file://$(pwd)/server" &&
310 test_config -C client extensions.partialClone "$SERVER" &&
311
312 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
313 fetch --filter=blob:none "$SERVER" master:refs/heads/other &&
314 grep "version 2" trace &&
315
316 # Ensure that the old version of the file is missing
317 git -C client rev-list --quiet --objects --missing=print other \
318 >observed.oids &&
319 grep "$(git -C server rev-parse message1:a.txt)" observed.oids &&
320
321 # Ensure that client passes fsck
322 git -C client fsck
323 '
324
325 test_expect_success 'do not advertise filter if not configured to do so' '
326 SERVER="file://$(pwd)/server" &&
327
328 rm "$(pwd)/trace" &&
329 git -C server config uploadpack.allowfilter 1 &&
330 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
331 ls-remote "$SERVER" &&
332 grep "fetch=.*filter" trace &&
333
334 rm "$(pwd)/trace" &&
335 git -C server config uploadpack.allowfilter 0 &&
336 GIT_TRACE_PACKET="$(pwd)/trace" git -c protocol.version=2 \
337 ls-remote "$SERVER" &&
338 grep "fetch=" trace >fetch_capabilities &&
339 ! grep filter fetch_capabilities
340 '
341
342 test_expect_success 'partial clone warns if filter is not advertised' '
343 rm -rf client &&
344 git -C server config uploadpack.allowfilter 0 &&
345 git -c protocol.version=2 \
346 clone --filter=blob:none "file://$(pwd)/server" client 2>err &&
347 test_i18ngrep "filtering not recognized by server, ignoring" err
348 '
349
350 test_expect_success 'even with handcrafted request, filter does not work if not advertised' '
351 git -C server config uploadpack.allowfilter 0 &&
352
353 # Custom request that tries to filter even though it is not advertised.
354 test-tool pkt-line pack >in <<-EOF &&
355 command=fetch
356 0001
357 want $(git -C server rev-parse master)
358 filter blob:none
359 0000
360 EOF
361
362 test_must_fail git -C server serve --stateless-rpc <in >/dev/null 2>err &&
363 grep "unexpected line: .filter blob:none." err &&
364
365 # Exercise to ensure that if advertised, filter works
366 git -C server config uploadpack.allowfilter 1 &&
367 git -C server serve --stateless-rpc <in >/dev/null
368 '
369
370 test_expect_success 'default refspec is used to filter ref when fetchcing' '
371 test_when_finished "rm -f log" &&
372
373 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
374 fetch origin &&
375
376 git -C file_child log -1 --format=%s three >actual &&
377 git -C file_parent log -1 --format=%s three >expect &&
378 test_cmp expect actual &&
379
380 grep "ref-prefix refs/heads/" log &&
381 grep "ref-prefix refs/tags/" log
382 '
383
384 test_expect_success 'fetch supports various ways of have lines' '
385 rm -rf server client trace &&
386 git init server &&
387 test_commit -C server dwim &&
388 TREE=$(git -C server rev-parse HEAD^{tree}) &&
389 git -C server tag exact \
390 $(git -C server commit-tree -m a "$TREE") &&
391 git -C server tag dwim-unwanted \
392 $(git -C server commit-tree -m b "$TREE") &&
393 git -C server tag exact-unwanted \
394 $(git -C server commit-tree -m c "$TREE") &&
395 git -C server tag prefix1 \
396 $(git -C server commit-tree -m d "$TREE") &&
397 git -C server tag prefix2 \
398 $(git -C server commit-tree -m e "$TREE") &&
399 git -C server tag fetch-by-sha1 \
400 $(git -C server commit-tree -m f "$TREE") &&
401 git -C server tag completely-unrelated \
402 $(git -C server commit-tree -m g "$TREE") &&
403
404 git init client &&
405 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
406 fetch "file://$(pwd)/server" \
407 dwim \
408 refs/tags/exact \
409 refs/tags/prefix*:refs/tags/prefix* \
410 "$(git -C server rev-parse fetch-by-sha1)" &&
411
412 # Ensure that the appropriate prefixes are sent (using a sample)
413 grep "fetch> ref-prefix dwim" trace &&
414 grep "fetch> ref-prefix refs/heads/dwim" trace &&
415 grep "fetch> ref-prefix refs/tags/prefix" trace &&
416
417 # Ensure that the correct objects are returned
418 git -C client cat-file -e $(git -C server rev-parse dwim) &&
419 git -C client cat-file -e $(git -C server rev-parse exact) &&
420 git -C client cat-file -e $(git -C server rev-parse prefix1) &&
421 git -C client cat-file -e $(git -C server rev-parse prefix2) &&
422 git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) &&
423 test_must_fail git -C client cat-file -e \
424 $(git -C server rev-parse dwim-unwanted) &&
425 test_must_fail git -C client cat-file -e \
426 $(git -C server rev-parse exact-unwanted) &&
427 test_must_fail git -C client cat-file -e \
428 $(git -C server rev-parse completely-unrelated)
429 '
430
431 test_expect_success 'fetch supports include-tag and tag following' '
432 rm -rf server client trace &&
433 git init server &&
434
435 test_commit -C server to_fetch &&
436 git -C server tag -a annotated_tag -m message &&
437
438 git init client &&
439 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
440 fetch "$(pwd)/server" to_fetch:to_fetch &&
441
442 grep "fetch> ref-prefix to_fetch" trace &&
443 grep "fetch> ref-prefix refs/tags/" trace &&
444 grep "fetch> include-tag" trace &&
445
446 git -C client cat-file -e $(git -C client rev-parse annotated_tag)
447 '
448
449 test_expect_success 'upload-pack respects client shallows' '
450 rm -rf server client trace &&
451
452 git init server &&
453 test_commit -C server base &&
454 test_commit -C server client_has &&
455
456 git clone --depth=1 "file://$(pwd)/server" client &&
457
458 # Add extra commits to the client so that the whole fetch takes more
459 # than 1 request (due to negotiation)
460 for i in $(test_seq 1 32)
461 do
462 test_commit -C client c$i
463 done &&
464
465 git -C server checkout -b newbranch base &&
466 test_commit -C server client_wants &&
467
468 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
469 fetch origin newbranch &&
470 # Ensure that protocol v2 is used
471 grep "fetch< version 2" trace
472 '
473
474 test_expect_success 'ensure that multiple fetches in same process from a shallow repo works' '
475 rm -rf server client trace &&
476
477 test_create_repo server &&
478 test_commit -C server one &&
479 test_commit -C server two &&
480 test_commit -C server three &&
481 git clone --shallow-exclude two "file://$(pwd)/server" client &&
482
483 git -C server tag -a -m "an annotated tag" twotag two &&
484
485 # Triggers tag following (thus, 2 fetches in one process)
486 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
487 fetch --shallow-exclude one origin &&
488 # Ensure that protocol v2 is used
489 grep "fetch< version 2" trace
490 '
491
492 test_expect_success 'deepen-relative' '
493 rm -rf server client trace &&
494
495 test_create_repo server &&
496 test_commit -C server one &&
497 test_commit -C server two &&
498 test_commit -C server three &&
499 git clone --depth 1 "file://$(pwd)/server" client &&
500 test_commit -C server four &&
501
502 # Sanity check that only "three" is downloaded
503 git -C client log --pretty=tformat:%s master >actual &&
504 echo three >expected &&
505 test_cmp expected actual &&
506
507 GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
508 fetch --deepen=1 origin &&
509 # Ensure that protocol v2 is used
510 grep "fetch< version 2" trace &&
511
512 git -C client log --pretty=tformat:%s origin/master >actual &&
513 cat >expected <<-\EOF &&
514 four
515 three
516 two
517 EOF
518 test_cmp expected actual
519 '
520
521 # Test protocol v2 with 'http://' transport
522 #
523 . "$TEST_DIRECTORY"/lib-httpd.sh
524 start_httpd
525
526 test_expect_success 'create repo to be served by http:// transport' '
527 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
528 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" config http.receivepack true &&
529 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one
530 '
531
532 test_expect_success 'clone with http:// using protocol v2' '
533 test_when_finished "rm -f log" &&
534
535 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
536 clone "$HTTPD_URL/smart/http_parent" http_child &&
537
538 git -C http_child log -1 --format=%s >actual &&
539 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
540 test_cmp expect actual &&
541
542 # Client requested to use protocol v2
543 grep "Git-Protocol: version=2" log &&
544 # Server responded using protocol v2
545 grep "git< version 2" log &&
546 # Verify that the chunked encoding sending codepath is NOT exercised
547 ! grep "Send header: Transfer-Encoding: chunked" log
548 '
549
550 test_expect_success 'clone big repository with http:// using protocol v2' '
551 test_when_finished "rm -f log" &&
552
553 git init "$HTTPD_DOCUMENT_ROOT_PATH/big" &&
554 # Ensure that the list of wants is greater than http.postbuffer below
555 for i in $(test_seq 1 1500)
556 do
557 # do not use here-doc, because it requires a process
558 # per loop iteration
559 echo "commit refs/heads/too-many-refs-$i" &&
560 echo "committer git <git@example.com> $i +0000" &&
561 echo "data 0" &&
562 echo "M 644 inline bla.txt" &&
563 echo "data 4" &&
564 echo "bla"
565 done | git -C "$HTTPD_DOCUMENT_ROOT_PATH/big" fast-import &&
566
567 GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git \
568 -c protocol.version=2 -c http.postbuffer=65536 \
569 clone "$HTTPD_URL/smart/big" big_child &&
570
571 # Client requested to use protocol v2
572 grep "Git-Protocol: version=2" log &&
573 # Server responded using protocol v2
574 grep "git< version 2" log &&
575 # Verify that the chunked encoding sending codepath is exercised
576 grep "Send header: Transfer-Encoding: chunked" log
577 '
578
579 test_expect_success 'fetch with http:// using protocol v2' '
580 test_when_finished "rm -f log" &&
581
582 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
583
584 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
585 fetch &&
586
587 git -C http_child log -1 --format=%s origin/master >actual &&
588 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s >expect &&
589 test_cmp expect actual &&
590
591 # Server responded using protocol v2
592 grep "git< version 2" log
593 '
594
595 test_expect_success 'fetch from namespaced repo respects namespaces' '
596 test_when_finished "rm -f log" &&
597
598 git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
599 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
600 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
601 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
602 update-ref refs/namespaces/ns/refs/heads/master one &&
603
604 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
605 fetch "$HTTPD_URL/smart_namespace/nsrepo" \
606 refs/heads/master:refs/heads/theirs &&
607
608 # Server responded using protocol v2
609 grep "fetch< version 2" log &&
610
611 git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
612 git -C http_child rev-parse theirs >actual &&
613 test_cmp expect actual
614 '
615
616 test_expect_success 'push with http:// and a config of v2 does not request v2' '
617 test_when_finished "rm -f log" &&
618 # Till v2 for push is designed, make sure that if a client has
619 # protocol.version configured to use v2, that the client instead falls
620 # back and uses v0.
621
622 test_commit -C http_child three &&
623
624 # Push to another branch, as the target repository has the
625 # master branch checked out and we cannot push into it.
626 GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
627 push origin HEAD:client_branch &&
628
629 git -C http_child log -1 --format=%s >actual &&
630 git -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" log -1 --format=%s client_branch >expect &&
631 test_cmp expect actual &&
632
633 # Client didnt request to use protocol v2
634 ! grep "Git-Protocol: version=2" log &&
635 # Server didnt respond using protocol v2
636 ! grep "git< version 2" log
637 '
638
639 test_expect_success 'when server sends "ready", expect DELIM' '
640 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child &&
641
642 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
643 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
644
645 git clone "$HTTPD_URL/smart/http_parent" http_child &&
646
647 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
648
649 # After "ready" in the acknowledgments section, pretend that a FLUSH
650 # (0000) was sent instead of a DELIM (0001).
651 printf "/ready/,$ s/0001/0000/" \
652 >"$HTTPD_ROOT_PATH/one-time-sed" &&
653
654 test_must_fail git -C http_child -c protocol.version=2 \
655 fetch "$HTTPD_URL/one_time_sed/http_parent" 2> err &&
656 test_i18ngrep "expected packfile to be sent after .ready." err
657 '
658
659 test_expect_success 'when server does not send "ready", expect FLUSH' '
660 rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log &&
661
662 git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
663 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&
664
665 git clone "$HTTPD_URL/smart/http_parent" http_child &&
666
667 test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" two &&
668
669 # Create many commits to extend the negotiation phase across multiple
670 # requests, so that the server does not send "ready" in the first
671 # request.
672 for i in $(test_seq 1 32)
673 do
674 test_commit -C http_child c$i
675 done &&
676
677 # After the acknowledgments section, pretend that a DELIM
678 # (0001) was sent instead of a FLUSH (0000).
679 printf "/acknowledgments/,$ s/0000/0001/" \
680 >"$HTTPD_ROOT_PATH/one-time-sed" &&
681
682 test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" git -C http_child \
683 -c protocol.version=2 \
684 fetch "$HTTPD_URL/one_time_sed/http_parent" 2> err &&
685 grep "fetch< .*acknowledgments" log &&
686 ! grep "fetch< .*ready" log &&
687 test_i18ngrep "expected no other sections to be sent after no .ready." err
688 '
689
690 stop_httpd
691
692 test_done