dir: convert open_cached_dir 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 207a06cea39579586952a9a50bd25352e5c952f1
1 file changed +7 -5
dir.c
+7 -5
@@ -1664,6 +1664,7 @@ static void add_untracked(struct untracked_cache_dir *dir, const char *name)
1664
1665 static int valid_cached_dir(struct dir_struct *dir,
1666 struct untracked_cache_dir *untracked,
1667 + struct index_state *istate,
1668 struct strbuf *path,
1669 int check_only)
1670 {
@@ -1678,7 +1679,7 @@ static int valid_cached_dir(struct dir_struct *dir,
1679 return 0;
1680 }
1681 if (!untracked->valid ||
1681 - match_stat_data_racy(&the_index, &untracked->stat_data, &st)) {
1682 + match_stat_data_racy(istate, &untracked->stat_data, &st)) {
1683 if (untracked->valid)
1684 invalidate_directory(dir->untracked, untracked);
1685 fill_stat_data(&untracked->stat_data, &st);
@@ -1699,10 +1700,10 @@ static int valid_cached_dir(struct dir_struct *dir,
1700 */
1701 if (path->len && path->buf[path->len - 1] != '/') {
1702 strbuf_addch(path, '/');
1702 - prep_exclude(dir, &the_index, path->buf, path->len);
1703 + prep_exclude(dir, istate, path->buf, path->len);
1704 strbuf_setlen(path, path->len - 1);
1705 } else
1705 - prep_exclude(dir, &the_index, path->buf, path->len);
1706 + prep_exclude(dir, istate, path->buf, path->len);
1707
1708 /* hopefully prep_exclude() haven't invalidated this entry... */
1709 return untracked->valid;
@@ -1711,12 +1712,13 @@ static int valid_cached_dir(struct dir_struct *dir,
1712 static int open_cached_dir(struct cached_dir *cdir,
1713 struct dir_struct *dir,
1714 struct untracked_cache_dir *untracked,
1715 + struct index_state *istate,
1716 struct strbuf *path,
1717 int check_only)
1718 {
1719 memset(cdir, 0, sizeof(*cdir));
1720 cdir->untracked = untracked;
1719 - if (valid_cached_dir(dir, untracked, path, check_only))
1721 + if (valid_cached_dir(dir, untracked, istate, path, check_only))
1722 return 0;
1723 cdir->fdir = opendir(path->len ? path->buf : ".");
1724 if (dir->untracked)
@@ -1789,7 +1791,7 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
1791
1792 strbuf_add(&path, base, baselen);
1793
1792 - if (open_cached_dir(&cdir, dir, untracked, &path, check_only))
1794 + if (open_cached_dir(&cdir, dir, untracked, &the_index, &path, check_only))
1795 goto out;
1796
1797 if (untracked)