Skip to content

Commit 2c1eb10

Browse files
bmwillgitster
authored andcommitted
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>
1 parent 0ef8e16 commit 2c1eb10

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

dir.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
190190
prefix = prefix_len ? pathspec->items[0].match : "";
191191

192192
/* Read the directory and prune it */
193-
read_directory(dir, prefix, prefix_len, pathspec);
193+
read_directory(dir, &the_index, prefix, prefix_len, pathspec);
194194

195195
return prefix_len;
196196
}
@@ -2071,8 +2071,8 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
20712071
return root;
20722072
}
20732073

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)
20762076
{
20772077
struct untracked_cache_dir *untracked;
20782078

@@ -2086,8 +2086,8 @@ int read_directory(struct dir_struct *dir, const char *path,
20862086
* e.g. prep_exclude()
20872087
*/
20882088
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);
20912091
QSORT(dir->entries, dir->nr, cmp_name);
20922092
QSORT(dir->ignored, dir->ignored_nr, cmp_name);
20932093
if (dir->untracked) {
@@ -2101,12 +2101,12 @@ int read_directory(struct dir_struct *dir, const char *path,
21012101
dir->untracked->gitignore_invalidated,
21022102
dir->untracked->dir_invalidated,
21032103
dir->untracked->dir_opened);
2104-
if (dir->untracked == the_index.untracked &&
2104+
if (dir->untracked == istate->untracked &&
21052105
(dir->untracked->dir_opened ||
21062106
dir->untracked->gitignore_invalidated ||
21072107
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) {
21102110
free(dir->untracked);
21112111
dir->untracked = NULL;
21122112
}

dir.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ extern int report_path_error(const char *ps_matched, const struct pathspec *path
215215
extern int within_depth(const char *name, int namelen, int depth, int max_depth);
216216

217217
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);
219221

220222
extern int is_excluded_from_list(const char *pathname, int pathlen,
221223
const char *basename, int *dtype,

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
15921592
memset(&d, 0, sizeof(d));
15931593
if (o->dir)
15941594
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);
15961596
if (i)
15971597
return o->gently ? -1 :
15981598
add_rejected_path(o, ERROR_NOT_UPTODATE_DIR, ce->name);

0 commit comments

Comments
 (0)