diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2021-07-23 20:52:22 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-07-23 23:21:57 +0200 |
commit | b2896d27391afcbc990439e63972bb33693a7d6b (patch) | |
tree | 952dfb651420982f59f61cb4b2ed6d62a17effb8 /read-cache.c | |
parent | The sixth batch (diff) | |
download | git-b2896d27391afcbc990439e63972bb33693a7d6b.tar.xz git-b2896d27391afcbc990439e63972bb33693a7d6b.zip |
unpack-trees: refactor prefetching code
Refactor the prefetching code in unpack-trees.c into its own function,
because it will be used elsewhere in a subsequent commit.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c index ba2b012a6c..4e396bf17f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -27,6 +27,7 @@ #include "progress.h" #include "sparse-index.h" #include "csum-file.h" +#include "promisor-remote.h" /* Mask for the name length in ce_flags in the on-disk index */ @@ -3657,3 +3658,25 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta strbuf_add(sb, &buffer, sizeof(uint32_t)); } } + +void prefetch_cache_entries(const struct index_state *istate, + must_prefetch_predicate must_prefetch) +{ + int i; + struct oid_array to_fetch = OID_ARRAY_INIT; + + for (i = 0; i < istate->cache_nr; i++) { + struct cache_entry *ce = istate->cache[i]; + + if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce)) + continue; + if (!oid_object_info_extended(the_repository, &ce->oid, + NULL, + OBJECT_INFO_FOR_PREFETCH)) + continue; + oid_array_append(&to_fetch, &ce->oid); + } + promisor_remote_get_direct(the_repository, + to_fetch.oid, to_fetch.nr); + oid_array_clear(&to_fetch); +} |