Skip to content
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

dir.c: make add_excludes aware of fscache during status #1344

Merged
Merged
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
5 changes: 5 additions & 0 deletions compat/win32/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ static struct hashmap map;
static CRITICAL_SECTION mutex;
static struct trace_key trace_fscache = TRACE_KEY_INIT(FSCACHE);

int fscache_is_enabled(void)
{
return enabled;
}

/*
* An entry in the file system cache. Used for both entire directory listings
* and file entries.
Expand Down
3 changes: 3 additions & 0 deletions compat/win32/fscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
int fscache_enable(int enable);
#define enable_fscache(x) fscache_enable(x)

int fscache_is_enabled(void);
#define is_fscache_enabled() (fscache_is_enabled())

DIR *fscache_opendir(const char *dir);
int fscache_lstat(const char *file_name, struct stat *buf);

Expand Down
27 changes: 21 additions & 6 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,27 @@ static int add_excludes(const char *fname, const char *base, int baselen,
size_t size = 0;
char *buf, *entry;

fd = open(fname, O_RDONLY);
if (fd < 0 || fstat(fd, &st) < 0) {
if (fd < 0)
warn_on_fopen_errors(fname);
else
close(fd);
if (is_fscache_enabled()) {
if (lstat(fname, &st) < 0) {
fd = -1;
} else {
fd = open(fname, O_RDONLY);
if (fd < 0)
warn_on_fopen_errors(fname);
}
} else {
fd = open(fname, O_RDONLY);
if (fd < 0 || fstat(fd, &st) < 0) {
if (fd < 0)
warn_on_fopen_errors(fname);
else {
close(fd);
fd = -1;
}
}
}

if (fd < 0) {
if (!istate ||
(buf = read_skip_worktree_file_from_index(istate, fname, &size, sha1_stat)) == NULL)
return -1;
Expand Down
4 changes: 4 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,10 @@ static inline int is_missing_file_error(int errno_)
#define enable_fscache(x) /* noop */
#endif

#ifndef is_fscache_enabled
#define is_fscache_enabled() (0)
#endif

extern int cmd_main(int, const char **);

/*
Expand Down