diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2020-07-16 18:09:50 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-07-16 21:07:19 (GMT) |
commit | 77aa0941ce8ac2dc0027f85e0c79632034cd47f0 (patch) | |
tree | 522566e2c589bbce3523f8351f7dd7e262cad136 /upload-pack.c | |
parent | bd42bbe1a46c0fe486fc33e82969275e27e4dc19 (diff) | |
download | git-77aa0941ce8ac2dc0027f85e0c79632034cd47f0.zip git-77aa0941ce8ac2dc0027f85e0c79632034cd47f0.tar.gz git-77aa0941ce8ac2dc0027f85e0c79632034cd47f0.tar.bz2 |
upload-pack: do not lazy-fetch "have" objects
When upload-pack receives a request containing "have" hashes, it (among
other things) checks if the served repository has the corresponding
objects. However, it does not do so with the
OBJECT_INFO_SKIP_FETCH_OBJECT flag, so if serving a partial clone, a
lazy fetch will be triggered first.
This was discovered at $DAYJOB when a user fetched from a partial clone
(into another partial clone - although this would also happen if the
repo to be fetched into is not a partial clone).
Therefore, whenever "have" hashes are checked for existence, pass the
OBJECT_INFO_SKIP_FETCH_OBJECT flag. Also add the OBJECT_INFO_QUICK flag
to improve performance, as it is typical that such objects do not exist
in the serving repo, and the consequences of a false negative are minor
(usually, a slightly larger pack sent).
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r-- | upload-pack.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/upload-pack.c b/upload-pack.c index 951a2b2..8673741 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -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); |