Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- builtin/add.c | 3 ++- dir.c | 18 +++++++++++------- dir.h | 4 +++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 9f53f020d..bf5e676e4 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -437,7 +437,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) if (ignore_missing) { int dtype = DT_UNKNOWN; if (is_excluded(&dir, path, &dtype)) - dir_add_ignored(&dir, path, pathspec.items[i].len); + dir_add_ignored(&dir, &the_index, + path, pathspec.items[i].len); } else die(_("pathspec '%s' did not match any files"), pathspec.items[i].original); diff --git a/dir.c b/dir.c index 4515f0083..a508e8076 100644 --- a/dir.c +++ b/dir.c @@ -1236,18 +1236,22 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len) return ent; } -static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len) +static struct dir_entry *dir_add_name(struct dir_struct *dir, + struct index_state *istate, + const char *pathname, int len) { - if (index_file_exists(&the_index, pathname, len, ignore_case)) + if (index_file_exists(istate, pathname, len, ignore_case)) return NULL; ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc); return dir->entries[dir->nr++] = dir_entry_new(pathname, len); } -struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len) +struct dir_entry *dir_add_ignored(struct dir_struct *dir, + struct index_state *istate, + const char *pathname, int len) { - if (!index_name_is_other(&the_index, pathname, len)) + if (!index_name_is_other(istate, pathname, len)) return NULL; ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc); @@ -1819,18 +1823,18 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir, switch (state) { case path_excluded: if (dir->flags & DIR_SHOW_IGNORED) - dir_add_name(dir, path.buf, path.len); + dir_add_name(dir, &the_index, path.buf, path.len); else if ((dir->flags & DIR_SHOW_IGNORED_TOO) || ((dir->flags & DIR_COLLECT_IGNORED) && exclude_matches_pathspec(path.buf, path.len, pathspec))) - dir_add_ignored(dir, path.buf, path.len); + dir_add_ignored(dir, &the_index, path.buf, path.len); break; case path_untracked: if (dir->flags & DIR_SHOW_IGNORED) break; - dir_add_name(dir, path.buf, path.len); + dir_add_name(dir, &the_index, path.buf, path.len); if (cdir.fdir) add_untracked(untracked, path.buf + baselen); break; diff --git a/dir.h b/dir.h index bf23a470a..a9f809983 100644 --- a/dir.h +++ b/dir.h @@ -219,7 +219,9 @@ extern int read_directory(struct dir_struct *, const char *path, int len, const extern int is_excluded_from_list(const char *pathname, int pathlen, const char *basename, int *dtype, struct exclude_list *el); -struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len); +struct dir_entry *dir_add_ignored(struct dir_struct *dir, + struct index_state *istate, + const char *pathname, int len); /* * these implement the matching logic for dir.c:excluded_from_list and -- 2.13.0.rc1.294.g07d810a77f-goog