dir: convert dir_add* to take an index
authorBrandon Williams <bmwill@google.com>
Fri, 5 May 2017 19:53:25 +0000 (12:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 May 2017 10:15:39 +0000 (19:15 +0900)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
dir.c
dir.h
index 9f53f020d0fc7184ac803a4346bdf426a814ed72..bf5e676e4666d55ea0d5340cc5186f184424f2f1 100644 (file)
@@ -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 4515f008362fe92b5aa686e1af05f39ace7138df..a508e8076ddc3ff3aef262512b1b9b77a4357d2c 100644 (file)
--- 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 bf23a470af57775c8f0099597f7a403995bf3a89..a9f80998339ebc1f510c041809f7beaddaec01ff 100644 (file)
--- 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