mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'jt/fetch-pack-loosen-validation-with-packfile-uri'
Bugfix for "git fetch" when the packfile URI capability is in use. * jt/fetch-pack-loosen-validation-with-packfile-uri: fetch-pack: make packfile URIs work with transfer.fsckobjects fetch-pack: document only_packfile in get_pack() (various): document from_promisor parameter
This commit is contained in:
commit
bdccf5e086
|
@ -794,6 +794,10 @@ static void write_promisor_file(const char *keep_name,
|
|||
strbuf_release(&promisor_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass 1 as "only_packfile" if the pack received is the only pack in this
|
||||
* fetch request (that is, if there were no packfile URIs provided).
|
||||
*/
|
||||
static int get_pack(struct fetch_pack_args *args,
|
||||
int xd[2], struct string_list *pack_lockfiles,
|
||||
int only_packfile,
|
||||
|
@ -895,7 +899,7 @@ static int get_pack(struct fetch_pack_args *args,
|
|||
: transfer_fsck_objects >= 0
|
||||
? transfer_fsck_objects
|
||||
: 0) {
|
||||
if (args->from_promisor)
|
||||
if (args->from_promisor || !only_packfile)
|
||||
/*
|
||||
* We cannot use --strict in index-pack because it
|
||||
* checks both broken objects and links, but we only
|
||||
|
|
|
@ -40,6 +40,14 @@ struct fetch_pack_args {
|
|||
unsigned cloning:1;
|
||||
unsigned update_shallow:1;
|
||||
unsigned deepen:1;
|
||||
|
||||
/*
|
||||
* Indicate that the remote of this request is a promisor remote. The
|
||||
* pack received does not need all referred-to objects to be present in
|
||||
* the local object store, and fetch-pack will store the pack received
|
||||
* together with a ".promisor" file indicating that the aforementioned
|
||||
* pack is a promisor pack.
|
||||
*/
|
||||
unsigned from_promisor:1;
|
||||
|
||||
/*
|
||||
|
|
|
@ -39,7 +39,10 @@ struct options {
|
|||
/* One of the SEND_PACK_PUSH_CERT_* constants. */
|
||||
push_cert : 2,
|
||||
deepen_relative : 1,
|
||||
|
||||
/* see documentation of corresponding flag in fetch-pack.h */
|
||||
from_promisor : 1,
|
||||
|
||||
no_dependents : 1,
|
||||
atomic : 1,
|
||||
object_format : 1;
|
||||
|
|
|
@ -883,6 +883,59 @@ test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
|
|||
test_i18ngrep "pack downloaded from.*does not match expected hash" err
|
||||
'
|
||||
|
||||
test_expect_success 'packfile-uri with transfer.fsckobjects' '
|
||||
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 &&
|
||||
git -C "$P" commit -m x &&
|
||||
|
||||
configure_exclusion "$P" my-blob >h &&
|
||||
|
||||
sane_unset GIT_TEST_SIDEBAND_ALL &&
|
||||
git -c protocol.version=2 -c transfer.fsckobjects=1 \
|
||||
-c fetch.uriprotocols=http,https \
|
||||
clone "$HTTPD_URL/smart/http_parent" http_child &&
|
||||
|
||||
# Ensure that there are exactly 4 files (2 .pack and 2 .idx).
|
||||
ls http_child/.git/objects/pack/* >filelist &&
|
||||
test_line_count = 4 filelist
|
||||
'
|
||||
|
||||
test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' '
|
||||
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
|
||||
rm -rf "$P" http_child log &&
|
||||
|
||||
git init "$P" &&
|
||||
git -C "$P" config "uploadpack.allowsidebandall" "true" &&
|
||||
|
||||
cat >bogus-commit <<-EOF &&
|
||||
tree $EMPTY_TREE
|
||||
author Bugs Bunny 1234567890 +0000
|
||||
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
|
||||
|
||||
This commit object intentionally broken
|
||||
EOF
|
||||
BOGUS=$(git -C "$P" hash-object -t commit -w --stdin <bogus-commit) &&
|
||||
git -C "$P" branch bogus-branch "$BOGUS" &&
|
||||
|
||||
echo my-blob >"$P/my-blob" &&
|
||||
git -C "$P" add my-blob &&
|
||||
git -C "$P" commit -m x &&
|
||||
|
||||
configure_exclusion "$P" my-blob >h &&
|
||||
|
||||
sane_unset GIT_TEST_SIDEBAND_ALL &&
|
||||
test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
|
||||
-c fetch.uriprotocols=http,https \
|
||||
clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
|
||||
test_i18ngrep "invalid author/committer line - missing email" error
|
||||
'
|
||||
|
||||
# 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.
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ struct git_transport_options {
|
|||
unsigned self_contained_and_connected : 1;
|
||||
unsigned update_shallow : 1;
|
||||
unsigned deepen_relative : 1;
|
||||
|
||||
/* see documentation of corresponding flag in fetch-pack.h */
|
||||
unsigned from_promisor : 1;
|
||||
|
||||
unsigned no_dependents : 1;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue