Skip to content

Commit 059c38f

Browse files
committed
Merge branch 'pt/promisor-lazy-fetch-no-recurse' into jch
* pt/promisor-lazy-fetch-no-recurse: promisor-remote: prevent lazy-fetch recursion in child fetch
2 parents 74c1696 + 087cc88 commit 059c38f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

promisor-remote.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ static int fetch_objects(struct repository *repo,
4242
child.in = -1;
4343
if (repo != the_repository)
4444
prepare_other_repo_env(&child.env, repo->gitdir);
45+
/*
46+
* Prevent the child's index-pack from recursing back into
47+
* fetch_objects() when resolving REF_DELTA bases it does not
48+
* have. With noop negotiation the server should never need
49+
* to send such deltas, so a depth-2 fetch would not help.
50+
*/
51+
strvec_pushf(&child.env, "%s=1", NO_LAZY_FETCH_ENVIRONMENT);
4552
strvec_pushl(&child.args, "-c", "fetch.negotiationAlgorithm=noop",
4653
"fetch", remote_name, "--no-tags",
4754
"--no-write-fetch-head", "--recurse-submodules=no",

t/t0411-clone-from-partial.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,30 @@ test_expect_success 'promisor lazy-fetching can be re-enabled' '
7878
test_path_is_file script-executed
7979
'
8080

81+
test_expect_success 'lazy-fetch child has GIT_NO_LAZY_FETCH=1' '
82+
test_create_repo nolazy-server &&
83+
test_commit -C nolazy-server foo &&
84+
git -C nolazy-server repack -a -d --write-bitmap-index &&
85+
86+
git clone "file://$(pwd)/nolazy-server" nolazy-client &&
87+
HASH=$(git -C nolazy-client rev-parse foo) &&
88+
rm -rf nolazy-client/.git/objects/* &&
89+
90+
git -C nolazy-client config core.repositoryformatversion 1 &&
91+
git -C nolazy-client config extensions.partialclone "origin" &&
92+
93+
# Install a reference-transaction hook to record the env var
94+
# as seen by processes inside the child fetch.
95+
test_hook -C nolazy-client reference-transaction <<-\EOF &&
96+
echo "$GIT_NO_LAZY_FETCH" >>../env-in-child
97+
EOF
98+
99+
rm -f env-in-child &&
100+
git -C nolazy-client cat-file -p "$HASH" &&
101+
102+
# The hook runs inside the child fetch, which should have
103+
# GIT_NO_LAZY_FETCH=1 in its environment.
104+
grep "^1$" env-in-child
105+
'
106+
81107
test_done

0 commit comments

Comments
 (0)