dir: convert read_skip_worktree_file_from_index 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 6f52b741a7e58dbabee196c22acd012107488ccb
1 file changed +7 -6
dir.c
+7 -6
@@ -588,7 +588,8 @@ void add_exclude(const char *string, const char *base,
588 x->el = el;
589 }
590
591 -static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
591 +static void *read_skip_worktree_file_from_index(const struct index_state *istate,
592 + const char *path, size_t *size,
593 struct sha1_stat *sha1_stat)
594 {
595 int pos, len;
@@ -597,12 +598,12 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
598 void *data;
599
600 len = strlen(path);
600 - pos = index_name_pos(&the_index, path, len);
601 + pos = index_name_pos(istate, path, len);
602 if (pos < 0)
603 return NULL;
603 - if (!ce_skip_worktree(the_index.cache[pos]))
604 + if (!ce_skip_worktree(istate->cache[pos]))
605 return NULL;
605 - data = read_sha1_file(the_index.cache[pos]->oid.hash, &type, &sz);
606 + data = read_sha1_file(istate->cache[pos]->oid.hash, &type, &sz);
607 if (!data || type != OBJ_BLOB) {
608 free(data);
609 return NULL;
@@ -610,7 +611,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
611 *size = xsize_t(sz);
612 if (sha1_stat) {
613 memset(&sha1_stat->stat, 0, sizeof(sha1_stat->stat));
613 - hashcpy(sha1_stat->sha1, the_index.cache[pos]->oid.hash);
614 + hashcpy(sha1_stat->sha1, istate->cache[pos]->oid.hash);
615 }
616 return data;
617 }
@@ -751,7 +752,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
752 if (0 <= fd)
753 close(fd);
754 if (!check_index ||
754 - (buf = read_skip_worktree_file_from_index(fname, &size, sha1_stat)) == NULL)
755 + (buf = read_skip_worktree_file_from_index(&the_index, fname, &size, sha1_stat)) == NULL)
756 return -1;
757 if (size == 0) {
758 free(buf);