aboutsummaryrefslogtreecommitdiffstats
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-08-02 14:06:42 -0700
committerJunio C Hamano <gitster@pobox.com>2021-08-02 14:06:42 -0700
commit8230107f336b29d25111c517639b8cd5717c8416 (patch)
treeb24d756b13a4877290c6369d9833d8e6e8f28120 /read-cache.c
parente9fe413fc29efac6d223cf1bd0cad10231e37df3 (diff)
parentd3da223f2214ebc1527ccf66428aa975de916682 (diff)
downloadgit-8230107f336b29d25111c517639b8cd5717c8416.tar.gz
Merge branch 'jt/bulk-prefetch'
"git read-tree" had a codepath where blobs are fetched one-by-one from the promisor remote, which has been corrected to fetch in bulk. * jt/bulk-prefetch: cache-tree: prefetch in partial clone read-tree unpack-trees: refactor prefetching code
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 46ccd66f34..99a174b91e 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 */
@@ -3663,3 +3664,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);
+}