aboutsummaryrefslogtreecommitdiffstats
path: root/read-cache.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2021-07-23 11:52:22 -0700
committerJunio C Hamano <gitster@pobox.com>2021-07-23 14:21:57 -0700
commitb2896d27391afcbc990439e63972bb33693a7d6b (patch)
tree952dfb651420982f59f61cb4b2ed6d62a17effb8 /read-cache.c
parenteb27b338a3e71c7c4079fbac8aeae3f8fbb5c687 (diff)
downloadgit-b2896d27391afcbc990439e63972bb33693a7d6b.tar.gz
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.c23
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);
+}