From 2c1eb104543265c2d26cf36303b35e426dcacf68 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 5 May 2017 12:53:33 -0700 Subject: [PATCH] dir: convert read_directory to take an index Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- dir.c | 16 ++++++++-------- dir.h | 4 +++- unpack-trees.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/dir.c b/dir.c index 3318ebbcb4..4eb8cb6a21 100644 --- a/dir.c +++ b/dir.c @@ -190,7 +190,7 @@ int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec) prefix = prefix_len ? pathspec->items[0].match : ""; /* Read the directory and prune it */ - read_directory(dir, prefix, prefix_len, pathspec); + read_directory(dir, &the_index, prefix, prefix_len, pathspec); return prefix_len; } @@ -2071,8 +2071,8 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d return root; } -int read_directory(struct dir_struct *dir, const char *path, - int len, const struct pathspec *pathspec) +int read_directory(struct dir_struct *dir, struct index_state *istate, + const char *path, int len, const struct pathspec *pathspec) { struct untracked_cache_dir *untracked; @@ -2086,8 +2086,8 @@ int read_directory(struct dir_struct *dir, const char *path, * e.g. prep_exclude() */ dir->untracked = NULL; - if (!len || treat_leading_path(dir, &the_index, path, len, pathspec)) - read_directory_recursive(dir, &the_index, path, len, untracked, 0, pathspec); + if (!len || treat_leading_path(dir, istate, path, len, pathspec)) + read_directory_recursive(dir, istate, path, len, untracked, 0, pathspec); QSORT(dir->entries, dir->nr, cmp_name); QSORT(dir->ignored, dir->ignored_nr, cmp_name); if (dir->untracked) { @@ -2101,12 +2101,12 @@ int read_directory(struct dir_struct *dir, const char *path, dir->untracked->gitignore_invalidated, dir->untracked->dir_invalidated, dir->untracked->dir_opened); - if (dir->untracked == the_index.untracked && + if (dir->untracked == istate->untracked && (dir->untracked->dir_opened || dir->untracked->gitignore_invalidated || dir->untracked->dir_invalidated)) - the_index.cache_changed |= UNTRACKED_CHANGED; - if (dir->untracked != the_index.untracked) { + istate->cache_changed |= UNTRACKED_CHANGED; + if (dir->untracked != istate->untracked) { free(dir->untracked); dir->untracked = NULL; } diff --git a/dir.h b/dir.h index b745f1e5d7..a23bcd005c 100644 --- a/dir.h +++ b/dir.h @@ -215,7 +215,9 @@ extern int report_path_error(const char *ps_matched, const struct pathspec *path extern int within_depth(const char *name, int namelen, int depth, int max_depth); extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec); -extern int read_directory(struct dir_struct *, const char *path, int len, const struct pathspec *pathspec); +extern int read_directory(struct dir_struct *, struct index_state *istate, + const char *path, int len, + const struct pathspec *pathspec); extern int is_excluded_from_list(const char *pathname, int pathlen, const char *basename, int *dtype, diff --git a/unpack-trees.c b/unpack-trees.c index d5b401450f..cff6b3f8c4 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1592,7 +1592,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce, memset(&d, 0, sizeof(d)); if (o->dir) d.exclude_per_dir = o->dir->exclude_per_dir; - i = read_directory(&d, pathbuf, namelen+1, NULL); + i = read_directory(&d, &the_index, pathbuf, namelen+1, NULL); if (i) return o->gently ? -1 : add_rejected_path(o, ERROR_NOT_UPTODATE_DIR, ce->name);