diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-09-03 12:37:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-03 12:37:01 -0700 |
commit | bdccf5e086e5e45e5feccc22f9da0633c2492da1 (patch) | |
tree | bc91bd2d76286801ab6064cfc0c954ae25e4ece7 | |
parent | Merge branch 'ss/t7401-modernize' (diff) | |
parent | fetch-pack: make packfile URIs work with transfer.fsckobjects (diff) | |
download | tgif-bdccf5e086e5e45e5feccc22f9da0633c2492da1.tar.xz |
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
-rw-r--r-- | fetch-pack.c | 6 | ||||
-rw-r--r-- | fetch-pack.h | 8 | ||||
-rw-r--r-- | remote-curl.c | 3 | ||||
-rwxr-xr-x | t/t5702-protocol-v2.sh | 53 | ||||
-rw-r--r-- | transport.h | 3 |
5 files changed, 72 insertions, 1 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index d467edc24e..5eb6ed6165 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -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 diff --git a/fetch-pack.h b/fetch-pack.h index 85d1e39fe7..5e747daea8 100644 --- a/fetch-pack.h +++ b/fetch-pack.h @@ -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; /* diff --git a/remote-curl.c b/remote-curl.c index 62b3a45cde..0c1833dcb6 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -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; diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 5a60fbe3ed..7d5b17909b 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -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. diff --git a/transport.h b/transport.h index 1be4013dec..298d9eedc9 100644 --- a/transport.h +++ b/transport.h @@ -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; /* |