From d771fefe7e83dc2765baa37cdc227a54c7ddf314 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 23 Nov 2016 20:59:44 +0100 Subject: [PATCH] Export the preload_index() function The purpose of this function is to stat() the files listed in the index in a multi-threaded fashion. It is called directly after reading the index in the read_index_preloaded() function. However, in some cases we may want to separate the index reading from the preloading step, e.g. in builtin/add.c, where we need to load the index before we parse the pathspecs (which needs to error out if one of the pathspecs refers to a path within a submodule, for which the index must have been read already), and only then will we want to preload, possibly limited by the just-parsed pathspecs. So let's just export that function to allow calling it separately. Signed-off-by: Johannes Schindelin --- cache.h | 1 + preload-index.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cache.h b/cache.h index be2989efdb..2054dc9f88 100644 --- a/cache.h +++ b/cache.h @@ -659,6 +659,7 @@ extern int daemonize(void); /* Initialize and use the cache information */ struct lock_file; extern int read_index(struct index_state *); +extern void preload_index(struct index_state *, const struct pathspec *pathspec); extern int read_index_preload(struct index_state *, const struct pathspec *pathspec); extern int do_read_index(struct index_state *istate, const char *path, int must_exist); /* for testting only! */ diff --git a/preload-index.c b/preload-index.c index 9c22a0705f..6857573ce6 100644 --- a/preload-index.c +++ b/preload-index.c @@ -7,8 +7,7 @@ #include "fsmonitor.h" #ifdef NO_PTHREADS -static void preload_index(struct index_state *index, - const struct pathspec *pathspec) +void preload_index(struct index_state *index, const struct pathspec *pathspec) { ; /* nothing */ } @@ -73,8 +72,7 @@ static void *preload_thread(void *_data) return NULL; } -static void preload_index(struct index_state *index, - const struct pathspec *pathspec) +void preload_index(struct index_state *index, const struct pathspec *pathspec) { int threads, i, work, offset; struct thread_data data[MAX_PARALLEL];