737
sed 's/\(..\)/'$1'\1/g'
738
}
739
740
-# Create a one-time-perl command to replace the existing packfile with $1.
740
+# Create a one-time-script command to replace the existing packfile with $1.
741
replace_packfile () {
742
- # The protocol requires that the packfile be sent in sideband 1, hence
743
- # the extra \x01 byte at the beginning.
744
- cp $1 "$HTTPD_ROOT_PATH/one-time-pack" &&
745
- echo 'if (/packfile/) {
746
- print;
747
- my $length = -s "one-time-pack";
748
- printf "%04x\x01", $length + 5;
749
- print `cat one-time-pack` . "0000";
750
- last
751
- }' >"$HTTPD_ROOT_PATH/one-time-perl"
742
+ cp "$1" one-time-pack &&
743
+ write_script "$HTTPD_ROOT_PATH/one-time-script" <<-EOF
744
+ if grep packfile "\$1" >/dev/null
745
+ then
746
+ sed '/packfile/q' "\$1" &&
747
+ # The protocol requires that the packfile be sent in sideband
748
+ # 1, hence the extra \001 byte at the beginning.
749
+ printf "%04x\001" \$((\$(wc -c <"$PWD/one-time-pack") + 5)) &&
750
+ cat "$PWD/one-time-pack" &&
751
+ printf "0000"
752
+ else
753
+ cat "\$1"
754
+ fi
755
+ EOF
756
}
757
754
-test_expect_success PERL_TEST_HELPERS 'upon cloning, check that all refs point to objects' '
758
+test_expect_success 'upon cloning, check that all refs point to objects' '
759
SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
760
rm -rf "$SERVER" repo &&
761
test_create_repo "$SERVER" &&
780
# section header.
781
test_config -C "$SERVER" protocol.version 2 &&
782
test_must_fail git -c protocol.version=2 clone \
779
- --filter=blob:none $HTTPD_URL/one_time_perl/server repo 2>err &&
783
+ --filter=blob:none $HTTPD_URL/one_time_script/server repo 2>err &&
784
785
test_grep "did not send all necessary objects" err &&
786
783
- # Ensure that the one-time-perl script was used.
784
- ! test -e "$HTTPD_ROOT_PATH/one-time-perl"
787
+ # Ensure that the one-time-script script was used.
788
+ ! test -e "$HTTPD_ROOT_PATH/one-time-script"
789
'
790
787
-test_expect_success PERL_TEST_HELPERS 'when partial cloning, tolerate server not sending target of tag' '
791
+test_expect_success 'when partial cloning, tolerate server not sending target of tag' '
792
SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
793
rm -rf "$SERVER" repo &&
794
test_create_repo "$SERVER" &&
822
823
# Exercise to make sure it works.
824
git -c protocol.version=2 clone \
821
- --filter=blob:none $HTTPD_URL/one_time_perl/server repo 2> err &&
825
+ --filter=blob:none $HTTPD_URL/one_time_script/server repo 2> err &&
826
! grep "missing object referenced by" err &&
827
824
- # Ensure that the one-time-perl script was used.
825
- ! test -e "$HTTPD_ROOT_PATH/one-time-perl"
828
+ # Ensure that the one-time-script script was used.
829
+ ! test -e "$HTTPD_ROOT_PATH/one-time-script"
830
'
831
832
test_expect_success PERL_TEST_HELPERS 'tolerate server sending REF_DELTA against missing promisor objects' '
849
850
# Clone. The client has deltabase_have but not deltabase_missing.
851
git -c protocol.version=2 clone --no-checkout \
848
- --filter=blob:none $HTTPD_URL/one_time_perl/server repo &&
852
+ --filter=blob:none $HTTPD_URL/one_time_script/server repo &&
853
git -C repo hash-object -w -- "$SERVER/have.txt" &&
854
855
# Sanity check to ensure that the client does not have
903
grep "want $(cat deltabase_missing)" trace &&
904
! grep "want $(cat deltabase_have)" trace &&
905
902
- # Ensure that the one-time-perl script was used.
903
- ! test -e "$HTTPD_ROOT_PATH/one-time-perl"
906
+ # Ensure that the one-time-script script was used.
907
+ ! test -e "$HTTPD_ROOT_PATH/one-time-script"
908
'
909
910
# DO NOT add non-httpd-specific tests here, because the last part of this