http-fetch: support fetching packfiles by URL
Teach http-fetch the ability to download packfiles directly, given a URL, and to verify them. The http_pack_request suite has been augmented with a function that takes a URL directly. With this function, the hash is only used to determine the name of the temporary file. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8e6adb69e1
commit
8d5d2a34df
@ -199,6 +199,28 @@ test_expect_success 'fetch packed objects' '
|
||||
git clone $HTTPD_URL/dumb/repo_pack.git
|
||||
'
|
||||
|
||||
test_expect_success 'http-fetch --packfile' '
|
||||
# Arbitrary hash. Use rev-parse so that we get one of the correct
|
||||
# length.
|
||||
ARBITRARY=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
|
||||
|
||||
git init packfileclient &&
|
||||
p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && ls objects/pack/pack-*.pack) &&
|
||||
git -C packfileclient http-fetch --packfile=$ARBITRARY "$HTTPD_URL"/dumb/repo_pack.git/$p >out &&
|
||||
|
||||
grep "^keep.[0-9a-f]\{16,\}$" out &&
|
||||
cut -c6- out >packhash &&
|
||||
|
||||
# Ensure that the expected files are generated
|
||||
test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).pack" &&
|
||||
test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).idx" &&
|
||||
test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).keep" &&
|
||||
|
||||
# Ensure that it has the HEAD of repo_pack, at least
|
||||
HASH=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
|
||||
git -C packfileclient cat-file -e "$HASH"
|
||||
'
|
||||
|
||||
test_expect_success 'fetch notices corrupt pack' '
|
||||
cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
|
||||
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
|
||||
@ -214,6 +236,14 @@ test_expect_success 'fetch notices corrupt pack' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'http-fetch --packfile with corrupt pack' '
|
||||
rm -rf packfileclient &&
|
||||
git init packfileclient &&
|
||||
p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git && ls objects/pack/pack-*.pack) &&
|
||||
test_must_fail git -C packfileclient http-fetch --packfile \
|
||||
"$HTTPD_URL"/dumb/repo_bad1.git/$p
|
||||
'
|
||||
|
||||
test_expect_success 'fetch notices corrupt idx' '
|
||||
cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
|
||||
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
|
||||
|
Reference in New Issue
Block a user