dir: convert read_directory to take an index

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 5, 2017 at 12:53 UTC 2c1eb104543265c2d26cf36303b35e426dcacf68
3 files changed +12 -10
dir.c
+8 -8
@@ -190,7 +190,7 @@ int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
190 prefix = prefix_len ? pathspec->items[0].match : "";
191
192 /* Read the directory and prune it */
193 - read_directory(dir, prefix, prefix_len, pathspec);
193 + read_directory(dir, &the_index, prefix, prefix_len, pathspec);
194
195 return prefix_len;
196 }
@@ -2071,8 +2071,8 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
2071 return root;
2072 }
2073
2074 -int read_directory(struct dir_struct *dir, const char *path,
2075 - int len, const struct pathspec *pathspec)
2074 +int read_directory(struct dir_struct *dir, struct index_state *istate,
2075 + const char *path, int len, const struct pathspec *pathspec)
2076 {
2077 struct untracked_cache_dir *untracked;
2078
@@ -2086,8 +2086,8 @@ int read_directory(struct dir_struct *dir, const char *path,
2086 * e.g. prep_exclude()
2087 */
2088 dir->untracked = NULL;
2089 - if (!len || treat_leading_path(dir, &the_index, path, len, pathspec))
2090 - read_directory_recursive(dir, &the_index, path, len, untracked, 0, pathspec);
2089 + if (!len || treat_leading_path(dir, istate, path, len, pathspec))
2090 + read_directory_recursive(dir, istate, path, len, untracked, 0, pathspec);
2091 QSORT(dir->entries, dir->nr, cmp_name);
2092 QSORT(dir->ignored, dir->ignored_nr, cmp_name);
2093 if (dir->untracked) {
@@ -2101,12 +2101,12 @@ int read_directory(struct dir_struct *dir, const char *path,
2101 dir->untracked->gitignore_invalidated,
2102 dir->untracked->dir_invalidated,
2103 dir->untracked->dir_opened);
2104 - if (dir->untracked == the_index.untracked &&
2104 + if (dir->untracked == istate->untracked &&
2105 (dir->untracked->dir_opened ||
2106 dir->untracked->gitignore_invalidated ||
2107 dir->untracked->dir_invalidated))
2108 - the_index.cache_changed |= UNTRACKED_CHANGED;
2109 - if (dir->untracked != the_index.untracked) {
2108 + istate->cache_changed |= UNTRACKED_CHANGED;
2109 + if (dir->untracked != istate->untracked) {
2110 free(dir->untracked);
2111 dir->untracked = NULL;
2112 }
dir.h
+3 -1
@@ -215,7 +215,9 @@ extern int report_path_error(const char *ps_matched, const struct pathspec *path
215 extern int within_depth(const char *name, int namelen, int depth, int max_depth);
216
217 extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec);
218 -extern int read_directory(struct dir_struct *, const char *path, int len, const struct pathspec *pathspec);
218 +extern int read_directory(struct dir_struct *, struct index_state *istate,
219 + const char *path, int len,
220 + const struct pathspec *pathspec);
221
222 extern int is_excluded_from_list(const char *pathname, int pathlen,
223 const char *basename, int *dtype,
unpack-trees.c
+1 -1
@@ -1592,7 +1592,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
1592 memset(&d, 0, sizeof(d));
1593 if (o->dir)
1594 d.exclude_per_dir = o->dir->exclude_per_dir;
1595 - i = read_directory(&d, pathbuf, namelen+1, NULL);
1595 + i = read_directory(&d, &the_index, pathbuf, namelen+1, NULL);
1596 if (i)
1597 return o->gently ? -1 :
1598 add_rejected_path(o, ERROR_NOT_UPTODATE_DIR, ce->name);