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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2016-11-23 20:59:44 +01:00
parent 433d0d12ab
commit 5e498de5b8
2 changed files with 3 additions and 4 deletions

View File

@@ -597,6 +597,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! */

View File

@@ -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];