Skip to content

Commit

Permalink
Export the preload_index() function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho authored and jamill committed Sep 10, 2018
1 parent e951899 commit 40f3f25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions cache.h
Expand Up @@ -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! */
Expand Down
6 changes: 2 additions & 4 deletions preload-index.c
Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 40f3f25

Please sign in to comment.