Skip to content

Commit 6f52b74

Browse files
bmwillgitster
authored andcommitted
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>
1 parent 12cd0bf commit 6f52b74

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

dir.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,8 @@ void add_exclude(const char *string, const char *base,
588588
x->el = el;
589589
}
590590

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,
592593
struct sha1_stat *sha1_stat)
593594
{
594595
int pos, len;
@@ -597,20 +598,20 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
597598
void *data;
598599

599600
len = strlen(path);
600-
pos = index_name_pos(&the_index, path, len);
601+
pos = index_name_pos(istate, path, len);
601602
if (pos < 0)
602603
return NULL;
603-
if (!ce_skip_worktree(the_index.cache[pos]))
604+
if (!ce_skip_worktree(istate->cache[pos]))
604605
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);
606607
if (!data || type != OBJ_BLOB) {
607608
free(data);
608609
return NULL;
609610
}
610611
*size = xsize_t(sz);
611612
if (sha1_stat) {
612613
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);
614615
}
615616
return data;
616617
}
@@ -751,7 +752,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
751752
if (0 <= fd)
752753
close(fd);
753754
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)
755756
return -1;
756757
if (size == 0) {
757758
free(buf);

0 commit comments

Comments
 (0)