diff options
author | Brandon Williams <bmwill@google.com> | 2017-05-05 12:53:25 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-06 19:15:39 +0900 |
commit | 9e58becab9d2512bad0fdf150fedbea84d6b9b03 (patch) | |
tree | 55a7634aad58ab7a1f14869abcbce6e5c8f737be | |
parent | dir: convert get_dtype to take index (diff) | |
download | tgif-9e58becab9d2512bad0fdf150fedbea84d6b9b03.tar.xz |
dir: convert dir_add* to take an index
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/add.c | 3 | ||||
-rw-r--r-- | dir.c | 18 | ||||
-rw-r--r-- | dir.h | 4 |
3 files changed, 16 insertions, 9 deletions
diff --git a/builtin/add.c b/builtin/add.c index 9f53f020d0..bf5e676e46 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); @@ -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; @@ -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 |