1
0
mirror of https://github.com/git/git.git synced 2024-10-20 20:28:13 +02:00

Merge branch 'jt/avoid-lazy-fetching-upon-have-check' into master

Fetching from a lazily cloned repository resulted at the server
side in attempts to lazy fetch objects that the client side has,
many of which will not be available from the third-party anyway.

* jt/avoid-lazy-fetching-upon-have-check:
  upload-pack: do not lazy-fetch "have" objects
This commit is contained in:
Junio C Hamano 2020-07-30 13:20:32 -07:00
commit 37f382a924
2 changed files with 42 additions and 2 deletions

@ -422,6 +422,44 @@ test_expect_success 'single-branch tag following respects partial clone' '
test_must_fail git -C single rev-parse --verify refs/tags/C
'
test_expect_success 'fetch from a partial clone, protocol v0' '
rm -rf server client trace &&
# Pretend that the server is a partial clone
git init server &&
git -C server remote add a_remote "file://$(pwd)/" &&
test_config -C server core.repositoryformatversion 1 &&
test_config -C server extensions.partialclone a_remote &&
test_config -C server protocol.version 0 &&
test_commit -C server foo &&
# Fetch from the server
git init client &&
test_config -C client protocol.version 0 &&
test_commit -C client bar &&
GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "file://$(pwd)/server" &&
! grep "version 2" trace
'
test_expect_success 'fetch from a partial clone, protocol v2' '
rm -rf server client trace &&
# Pretend that the server is a partial clone
git init server &&
git -C server remote add a_remote "file://$(pwd)/" &&
test_config -C server core.repositoryformatversion 1 &&
test_config -C server extensions.partialclone a_remote &&
test_config -C server protocol.version 2 &&
test_commit -C server foo &&
# Fetch from the server
git init client &&
test_config -C client protocol.version 2 &&
test_commit -C client bar &&
GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "file://$(pwd)/server" &&
grep "version 2" trace
'
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd

@ -482,7 +482,8 @@ static int got_oid(struct upload_pack_data *data,
{
if (get_oid_hex(hex, oid))
die("git upload-pack: expected SHA1 object, got '%s'", hex);
if (!has_object_file(oid))
if (!has_object_file_with_flags(oid,
OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
return -1;
return do_got_oid(data, oid);
}
@ -1423,7 +1424,8 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
for (i = 0; i < data->haves.nr; i++) {
const struct object_id *oid = &data->haves.oid[i];
if (!has_object_file(oid))
if (!has_object_file_with_flags(oid,
OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT))
continue;
oid_array_append(common, oid);