diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2015-03-08 17:12:31 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-12 13:45:16 -0700 |
commit | 27b099ae8742f014700edba92036db288750e44a (patch) | |
tree | b5d278c75c3ec51a9f695cca00b6974f03bcb23e | |
parent | 26cb0182b8b2e119f469750b3511fac4624f6667 (diff) | |
download | git-27b099ae8742f014700edba92036db288750e44a.tar.gz |
untracked cache: don't open non-existent .gitignore
This cuts down a signficant number of open(.gitignore) because most
directories usually don't have .gitignore files.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | dir.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -1020,7 +1020,21 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen) /* Try to read per-directory file */ hashclr(sha1_stat.sha1); sha1_stat.valid = 0; - if (dir->exclude_per_dir) { + if (dir->exclude_per_dir && + /* + * If we know that no files have been added in + * this directory (i.e. valid_cached_dir() has + * been executed and set untracked->valid) .. + */ + (!untracked || !untracked->valid || + /* + * .. and .gitignore does not exist before + * (i.e. null exclude_sha1 and skip_worktree is + * not set). Then we can skip loading .gitignore, + * which would result in ENOENT anyway. + * skip_worktree is taken care in read_directory() + */ + !is_null_sha1(untracked->exclude_sha1))) { /* * dir->basebuf gets reused by the traversal, but we * need fname to remain unchanged to ensure the src @@ -1783,6 +1797,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d const struct pathspec *pathspec) { struct untracked_cache_dir *root; + int i; if (!dir->untracked) return NULL; @@ -1834,6 +1849,15 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d if (dir->exclude_list_group[EXC_CMDL].nr) return NULL; + /* + * An optimization in prep_exclude() does not play well with + * CE_SKIP_WORKTREE. It's a rare case anyway, if a single + * entry has that bit set, disable the whole untracked cache. + */ + for (i = 0; i < active_nr; i++) + if (ce_skip_worktree(active_cache[i])) + return NULL; + if (!dir->untracked->root) { const int len = sizeof(*dir->untracked->root); dir->untracked->root = xmalloc(len); |