Merge branch 'jt/cdn-offload'
The "fetch/clone" protocol has been updated to allow the server to instruct the clients to grab pre-packaged packfile(s) in addition to the packed object data coming over the wire. * jt/cdn-offload: upload-pack: fix a sparse '0 as NULL pointer' warning upload-pack: send part of packfile response as uri fetch-pack: support more than one pack lockfile upload-pack: refactor reading of pack-objects out Documentation: add Packfile URIs design doc Documentation: order protocol v2 sections http-fetch: support fetching packfiles by URL http-fetch: refactor into function http: refactor finish_http_pack_request() http: use --stdin when indexing dumb HTTP pack
This commit is contained in:
@ -795,6 +795,94 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
|
||||
test_i18ngrep "expected no other sections to be sent after no .ready." err
|
||||
'
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
test_expect_success 'part of packfile response provided as URI' '
|
||||
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
|
||||
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 &&
|
||||
echo other-blob >"$P/other-blob" &&
|
||||
git -C "$P" add other-blob &&
|
||||
git -C "$P" commit -m x &&
|
||||
|
||||
configure_exclusion "$P" my-blob >h &&
|
||||
configure_exclusion "$P" other-blob >h2 &&
|
||||
|
||||
GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
|
||||
git -c protocol.version=2 \
|
||||
-c fetch.uriprotocols=http,https \
|
||||
clone "$HTTPD_URL/smart/http_parent" http_child &&
|
||||
|
||||
# Ensure that my-blob and other-blob are in separate packfiles.
|
||||
for idx in http_child/.git/objects/pack/*.idx
|
||||
do
|
||||
git verify-pack --verbose $idx >out &&
|
||||
{
|
||||
grep "^[0-9a-f]\{16,\} " out || :
|
||||
} >out.objectlist &&
|
||||
if test_line_count = 1 out.objectlist
|
||||
then
|
||||
if grep $(cat h) out
|
||||
then
|
||||
>hfound
|
||||
fi &&
|
||||
if grep $(cat h2) out
|
||||
then
|
||||
>h2found
|
||||
fi
|
||||
fi
|
||||
done &&
|
||||
test -f hfound &&
|
||||
test -f h2found &&
|
||||
|
||||
# Ensure that there are exactly 6 files (3 .pack and 3 .idx).
|
||||
ls http_child/.git/objects/pack/* >filelist &&
|
||||
test_line_count = 6 filelist
|
||||
'
|
||||
|
||||
test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
|
||||
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
|
||||
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 &&
|
||||
echo other-blob >"$P/other-blob" &&
|
||||
git -C "$P" add other-blob &&
|
||||
git -C "$P" commit -m x &&
|
||||
|
||||
configure_exclusion "$P" my-blob >h &&
|
||||
# Configure a URL for other-blob. Just reuse the hash of the object as
|
||||
# the hash of the packfile, since the hash does not matter for this
|
||||
# test as long as it is not the hash of the pack, and it is of the
|
||||
# expected length.
|
||||
git -C "$P" hash-object other-blob >objh &&
|
||||
git -C "$P" pack-objects "$HTTPD_DOCUMENT_ROOT_PATH/mypack" <objh >packh &&
|
||||
git -C "$P" config --add \
|
||||
"uploadpack.blobpackfileuri" \
|
||||
"$(cat objh) $(cat objh) $HTTPD_URL/dumb/mypack-$(cat packh).pack" &&
|
||||
|
||||
test_must_fail env GIT_TEST_SIDEBAND_ALL=1 \
|
||||
git -c protocol.version=2 \
|
||||
-c fetch.uriprotocols=http,https \
|
||||
clone "$HTTPD_URL/smart/http_parent" http_child 2>err &&
|
||||
test_i18ngrep "pack downloaded from.*does not match expected hash" err
|
||||
'
|
||||
|
||||
# DO NOT add non-httpd-specific tests here, because the last part of this
|
||||
# test script is only executed when httpd is available and enabled.
|
||||
|
||||
|
Reference in New Issue
Block a user