Skip to content

checkout.c: use fscache stat only in usable place #1443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

This comment was marked as off-topic.

This comment was marked as off-topic.

for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (ce->ce_flags & CE_MATCHED) {
Expand All @@ -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))
Expand Down
11 changes: 7 additions & 4 deletions compat/win32/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions compat/win32/fscache.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

This comment was marked as off-topic.

This comment was marked as off-topic.

}

/*
Expand Down
2 changes: 2 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down