diff --git a/builtin/checkout.c b/builtin/checkout.c index 95688d6e6ba73e..80b698b09ff333 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -359,7 +359,7 @@ static int checkout_paths(const struct checkout_opts *opts, state.istate = &the_index; enable_delayed_checkout(&state); - enable_fscache(1); + enable_explicit_fscache(1); for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (ce->ce_flags & CE_MATCHED) { @@ -374,7 +374,7 @@ static int checkout_paths(const struct checkout_opts *opts, pos = skip_same_name(ce, pos) - 1; } } - enable_fscache(0); + enable_explicit_fscache(0); errs |= finish_delayed_checkout(&state); if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index ee2b0dea0cfcc9..a0bb7ca7cae338 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -377,8 +377,9 @@ static struct fsentry *fscache_get(struct fsentry *key) /* * Enables or disables the cache. Note that the cache is read-only, changes to * the working directory are NOT reflected in the cache while enabled. + * If explicit_only is set, only explicit call of fscache_lstat uses fscache. */ -int fscache_enable(int enable) +int fscache_enable(int enable, int explicit_only) { int result; @@ -396,9 +397,11 @@ int fscache_enable(int enable) : InterlockedDecrement(&enabled); if (enable && result == 1) { - /* redirect opendir and lstat to the fscache implementations */ - opendir = fscache_opendir; - lstat = fscache_lstat; + if (!explicit_only) { + /* redirect opendir and lstat to the fscache implementations */ + opendir = fscache_opendir; + lstat = fscache_lstat; + } } else if (!enable && !result) { /* reset opendir and lstat to the original implementations */ opendir = dirent_opendir; diff --git a/compat/win32/fscache.h b/compat/win32/fscache.h index 660ada053b4309..767a72b5ba37cb 100644 --- a/compat/win32/fscache.h +++ b/compat/win32/fscache.h @@ -1,8 +1,10 @@ #ifndef FSCACHE_H #define FSCACHE_H -int fscache_enable(int enable); -#define enable_fscache(x) fscache_enable(x) +int fscache_enable(int enable, int explicit_only); +#define enable_fscache(x) fscache_enable(x, 0) + +#define enable_explicit_fscache(x) fscache_enable(x, 1) int fscache_enabled(const char *path); #define is_fscache_enabled(path) fscache_enabled(path) diff --git a/entry.c b/entry.c index 30211447ac8398..a19c75080d2c7a 100644 --- a/entry.c +++ b/entry.c @@ -5,6 +5,7 @@ #include "submodule.h" #include "progress.h" #include "fsmonitor.h" +#include "git-compat-util.h" static void create_directories(const char *path, int path_len, const struct checkout *state) @@ -395,7 +396,7 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen) errno = ENOENT; return -1; } - return lstat(path, st); + return fscache_lstat(path, st); } /* diff --git a/git-compat-util.h b/git-compat-util.h index aebb3e2b1cec4a..6cf7fcd2ce2a46 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1276,6 +1276,8 @@ static inline int is_missing_file_error(int errno_) */ #ifndef enable_fscache #define enable_fscache(x) /* noop */ +#define enable_explicit_fscache(x) /* noop */ +#define fscache_lstat lstat #endif #ifndef is_fscache_enabled