Skip to content
Permalink
Browse files

Merge pull request #1344 from jeffhostetler/perf_add_excludes_with_fs…

…cache

dir.c: make add_excludes aware of fscache during status
  • Loading branch information...
dscho committed Nov 1, 2017
2 parents 00897b8 + 4a87ffe commit fe8b815da3a01bd996df29979b8e8f6bfcd9139e
Showing with 33 additions and 6 deletions.
  1. +5 −0 compat/win32/fscache.c
  2. +3 −0 compat/win32/fscache.h
  3. +21 −6 dir.c
  4. +4 −0 git-compat-util.h
@@ -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.
@@ -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);

27 dir.c
@@ -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;
@@ -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 **);

/*

0 comments on commit fe8b815

Please sign in to comment.
You can’t perform that action at this time.