@@ -429,14 +429,18 @@ intersperse () {
429429 sed ' s/\(..\)/' $1 ' \1/g'
430430}
431431
432- # Create a one-time-sed command to replace the existing packfile with $1.
432+ # Create a one-time-perl command to replace the existing packfile with $1.
433433replace_packfile () {
434434 # The protocol requires that the packfile be sent in sideband 1, hence
435435 # the extra \x01 byte at the beginning.
436- printf " 1,/packfile/!c %04x\\\\ x01%s0000" \
437- " $(( $(wc - c < $1 ) + 5 )) " \
438- " $( hex_unpack < $1 | intersperse ' \\x' ) " \
439- > " $HTTPD_ROOT_PATH /one-time-sed"
436+ cp $1 " $HTTPD_ROOT_PATH /one-time-pack" &&
437+ echo ' if (/packfile/) {
438+ print;
439+ my $length = -s "one-time-pack";
440+ printf "%04x\x01", $length + 5;
441+ print `cat one-time-pack` . "0000";
442+ last
443+ }' > " $HTTPD_ROOT_PATH /one-time-perl"
440444}
441445
442446test_expect_success ' upon cloning, check that all refs point to objects' '
@@ -460,16 +464,16 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
460464 # \x01 byte at the beginning.
461465 replace_packfile incomplete.pack &&
462466
463- # Use protocol v2 because the sed command looks for the "packfile"
467+ # Use protocol v2 because the perl command looks for the "packfile"
464468 # section header.
465469 test_config -C "$SERVER" protocol.version 2 &&
466470 test_must_fail git -c protocol.version=2 clone \
467- --filter=blob:none $HTTPD_URL/one_time_sed /server repo 2>err &&
471+ --filter=blob:none $HTTPD_URL/one_time_perl /server repo 2>err &&
468472
469473 test_i18ngrep "did not send all necessary objects" err &&
470474
471- # Ensure that the one-time-sed script was used.
472- ! test -e "$HTTPD_ROOT_PATH/one-time-sed "
475+ # Ensure that the one-time-perl script was used.
476+ ! test -e "$HTTPD_ROOT_PATH/one-time-perl "
473477'
474478
475479test_expect_success ' when partial cloning, tolerate server not sending target of tag' '
@@ -500,17 +504,17 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
500504 # \x01 byte at the beginning.
501505 replace_packfile incomplete.pack &&
502506
503- # Use protocol v2 because the sed command looks for the "packfile"
507+ # Use protocol v2 because the perl command looks for the "packfile"
504508 # section header.
505509 test_config -C "$SERVER" protocol.version 2 &&
506510
507511 # Exercise to make sure it works.
508512 git -c protocol.version=2 clone \
509- --filter=blob:none $HTTPD_URL/one_time_sed /server repo 2> err &&
513+ --filter=blob:none $HTTPD_URL/one_time_perl /server repo 2> err &&
510514 ! grep "missing object referenced by" err &&
511515
512- # Ensure that the one-time-sed script was used.
513- ! test -e "$HTTPD_ROOT_PATH/one-time-sed "
516+ # Ensure that the one-time-perl script was used.
517+ ! test -e "$HTTPD_ROOT_PATH/one-time-perl "
514518'
515519
516520test_expect_success ' tolerate server sending REF_DELTA against missing promisor objects' '
@@ -533,7 +537,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
533537
534538 # Clone. The client has deltabase_have but not deltabase_missing.
535539 git -c protocol.version=2 clone --no-checkout \
536- --filter=blob:none $HTTPD_URL/one_time_sed /server repo &&
540+ --filter=blob:none $HTTPD_URL/one_time_perl /server repo &&
537541 git -C repo hash-object -w -- "$SERVER/have.txt" &&
538542
539543 # Sanity check to ensure that the client does not have
@@ -574,7 +578,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
574578
575579 replace_packfile thin.pack &&
576580
577- # Use protocol v2 because the sed command looks for the "packfile"
581+ # Use protocol v2 because the perl command looks for the "packfile"
578582 # section header.
579583 test_config -C "$SERVER" protocol.version 2 &&
580584
@@ -587,8 +591,8 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
587591 grep "want $(cat deltabase_missing)" trace &&
588592 ! grep "want $(cat deltabase_have)" trace &&
589593
590- # Ensure that the one-time-sed script was used.
591- ! test -e "$HTTPD_ROOT_PATH/one-time-sed "
594+ # Ensure that the one-time-perl script was used.
595+ ! test -e "$HTTPD_ROOT_PATH/one-time-perl "
592596'
593597
594598# DO NOT add non-httpd-specific tests here, because the last part of this
0 commit comments