*/
void validate_cache_entries(const struct index_state *istate);
+/*
+ * Bulk prefetch all missing cache entries that are not GITLINKs and that match
+ * the given predicate. This function should only be called if
+ * has_promisor_remote() returns true.
+ */
+typedef int (*must_prefetch_predicate)(const struct cache_entry *);
+void prefetch_cache_entries(const struct index_state *istate,
+ must_prefetch_predicate must_prefetch);
+
#ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
extern struct index_state the_index;
#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 */
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);
+}
string_list_clear(&list, 0);
}
+static int must_checkout(const struct cache_entry *ce)
+{
+ return ce->ce_flags & CE_UPDATE;
+}
+
static int check_updates(struct unpack_trees_options *o,
struct index_state *index)
{
if (should_update_submodules())
load_gitmodules_file(index, &state);
- if (has_promisor_remote()) {
+ if (has_promisor_remote())
/*
* Prefetch the objects that are to be checked out in the loop
* below.
*/
- struct oid_array to_fetch = OID_ARRAY_INIT;
- for (i = 0; i < index->cache_nr; i++) {
- struct cache_entry *ce = index->cache[i];
-
- if (!(ce->ce_flags & CE_UPDATE) ||
- S_ISGITLINK(ce->ce_mode))
- 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);
- }
+ prefetch_cache_entries(index, must_checkout);
get_parallel_checkout_configs(&pc_workers, &pc_threshold);
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
- if (ce->ce_flags & CE_UPDATE) {
+ if (must_checkout(ce)) {
size_t last_pc_queue_size = pc_queue_size();
if (ce->ce_flags & CE_WT_REMOVE)