diff --git a/promisor-remote.c b/promisor-remote.c index 96fa215b06..35c7aab93d 100644 --- a/promisor-remote.c +++ b/promisor-remote.c @@ -42,6 +42,13 @@ static int fetch_objects(struct repository *repo, child.in = -1; if (repo != the_repository) prepare_other_repo_env(&child.env, repo->gitdir); + /* + * Prevent the child's index-pack from recursing back into + * fetch_objects() when resolving REF_DELTA bases it does not + * have. With noop negotiation the server should never need + * to send such deltas, so a depth-2 fetch would not help. + */ + strvec_pushf(&child.env, "%s=1", NO_LAZY_FETCH_ENVIRONMENT); strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop", "fetch", remote_name, "--no-tags", "--no-write-fetch-head", "--recurse-submodules=no", diff --git a/t/t0411-clone-from-partial.sh b/t/t0411-clone-from-partial.sh index 9e6bca5625..10a829fb80 100755 --- a/t/t0411-clone-from-partial.sh +++ b/t/t0411-clone-from-partial.sh @@ -78,4 +78,30 @@ test_expect_success 'promisor lazy-fetching can be re-enabled' ' test_path_is_file script-executed ' +test_expect_success 'lazy-fetch child has GIT_NO_LAZY_FETCH=1' ' + test_create_repo nolazy-server && + test_commit -C nolazy-server foo && + git -C nolazy-server repack -a -d --write-bitmap-index && + + git clone "file://$(pwd)/nolazy-server" nolazy-client && + HASH=$(git -C nolazy-client rev-parse foo) && + rm -rf nolazy-client/.git/objects/* && + + git -C nolazy-client config core.repositoryformatversion 1 && + git -C nolazy-client config extensions.partialclone "origin" && + + # Install a reference-transaction hook to record the env var + # as seen by processes inside the child fetch. + test_hook -C nolazy-client reference-transaction <<-\EOF && + echo "$GIT_NO_LAZY_FETCH" >>../env-in-child + EOF + + rm -f env-in-child && + git -C nolazy-client cat-file -p "$HASH" && + + # The hook runs inside the child fetch, which should have + # GIT_NO_LAZY_FETCH=1 in its environment. + grep "^1$" env-in-child +' + test_done