diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2020-07-21 15:50:20 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-07-21 16:27:22 -0700 |
commit | a64d2aae5a593f4fb8b2020dc39556b256d1846e (patch) | |
tree | 2f97e6b0d233db7b60615b61f5dce4f3ce8d4b38 /sha1-file.c | |
parent | af6b65d45ef179ed52087e80cb089f6b2349f4ec (diff) | |
download | git-a64d2aae5a593f4fb8b2020dc39556b256d1846e.tar.gz |
sha1-file: make pretend_object_file() not prefetch
When pretend_object_file() is invoked with an object that does not exist
(as is the typical case), there is no need to fetch anything from the
promisor remote, because the caller already knows what the object is
supposed to contain. Therefore, suppress the fetch. (The
OBJECT_INFO_QUICK flag is added for the same reason.)
This was noticed at $DAYJOB when "blame" was run on a file that had
uncommitted modifications.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-file.c')
-rw-r--r-- | sha1-file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sha1-file.c b/sha1-file.c index 616886799e..60765dbaa0 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -1589,7 +1589,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type, struct cached_object *co; hash_object_file(the_hash_algo, buf, len, type_name(type), oid); - if (has_object_file(oid) || find_cached_object(oid)) + if (has_object_file_with_flags(oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) || + find_cached_object(oid)) return 0; ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc); co = &cached_objects[cached_object_nr++]; |