Re: [PATCH v3 2/3] t5702: support for excluding commit objects
flat view
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-07-26 15:16:33
On Mon, Jul 26 2021, Teng Long wrote:
quoted hunk ↗ jump to hunk
Signed-off-by: Teng Long <redacted> --- t/t5702-protocol-v2.sh | 166 +++++++++++++++++++++++++++++++++-------- 1 file changed, 133 insertions(+), 33 deletions(-)diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 2e1243ca40..bcf21e1445 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh@@ -753,7 +753,7 @@ test_expect_success 'ls-remote with v2 http sends only one POST' ' ' test_expect_success 'push with http:// and a config of v2 does not request v2' ' - test_when_finished "rm -f log" && + test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH/http_parent\" http_child log" && # Till v2 for push is designed, make sure that if a client has # protocol.version configured to use v2, that the client instead falls # back and uses v0.@@ -776,7 +776,7 @@ test_expect_success 'push with http:// and a config of v2 does not request v2' ' ' test_expect_success 'when server sends "ready", expect DELIM' ' - rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child && + test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH/http_parent\" http_child" && git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&@@ -796,7 +796,7 @@ test_expect_success 'when server sends "ready", expect DELIM' ' ' test_expect_success 'when server does not send "ready", expect FLUSH' ' - rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log && + test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH/http_parent\" http_child log" && git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" one &&@@ -824,17 +824,44 @@ test_expect_success 'when server does not send "ready", expect FLUSH' ' '
This looks like a good cleanup, but should be split into another cleanup commit. It looks unrelated.
quoted hunk ↗ jump to hunk
configure_exclusion () { - git -C "$1" hash-object "$2" >objh && - git -C "$1" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh && - git -C "$1" config --add \ - "uploadpack.blobpackfileuri" \ - "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" && - cat objh + objt="$1" + P="$2" + version="$3" + + oldc="uploadpack.blobpackfileuri" + newc="uploadpack.excludeobject" + configkey="" + if test "$version" = "0" + then + configkey="$oldc" + else + configkey="$newc" + fi
You've got all sorts of mixed space/tab indent here.
quoted hunk ↗ jump to hunk
+ if test "$objt" = "blob" + then + git -C "$P" hash-object "$3" >objh && + git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh && + git -C "$P" config --add \ + "$configkey" \ + "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" && + cat objh + elif test "$objt" = "commit" || test "$objt" = "tag" + then + echo "$3" >objh + git -C "$2" pack-objects --revs "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh + git -C "$P" config --add \ + "$configkey" \ + "$(cat objh) $(cat packh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" && + cat objh + else + echo "unsupported object type in configure_exclusion (got $objt)" + fi } test_expect_success 'part of packfile response provided as URI' ' P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && - rm -rf "$P" http_child log && + test_when_finished "rm -rf \"$P\" http_child log" && git init "$P" && git -C "$P" config "uploadpack.allowsidebandall" "true" &&@@ -843,10 +870,10 @@ test_expect_success 'part of packfile response provided as URI' ' git -C "$P" add my-blob && echo other-blob >"$P/other-blob" && git -C "$P" add other-blob && - git -C "$P" commit -m x && + test_commit -C "$P" A && - configure_exclusion "$P" my-blob >h && - configure_exclusion "$P" other-blob >h2 && + configure_exclusion blob "$P" my-blob 0 >h && + configure_exclusion blob "$P" other-blob 0 >h2 && GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \ git -c protocol.version=2 \@@ -881,18 +908,40 @@ test_expect_success 'part of packfile response provided as URI' ' test_line_count = 6 filelist ' -test_expect_success 'packfile URIs with fetch instead of clone' ' +test_expect_success 'blobs packfile URIs with fetch instead of clone' ' P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && - rm -rf "$P" http_child log && + test_when_finished "rm -rf \"$P\" http_child log" && git init "$P" && git -C "$P" config "uploadpack.allowsidebandall" "true" && echo my-blob >"$P/my-blob" && git -C "$P" add my-blob && - git -C "$P" commit -m x && + test_commit -C "$P" A && + + configure_exclusion blob "$P" my-blob >h && + + git init http_child && + + GIT_TEST_SIDEBAND_ALL=1 \ + git -C http_child -c protocol.version=2 \ + -c fetch.uriprotocols=http,https \
Isn't accepting http and https the default? Is this guarding against config leak from a previous test? Ditto some later changes.