Skip to content

Commit 7126102

Browse files
committed
dir.c: use the cache_* macro to access the current index
These codepaths always start from the_index and use index_* functions, but there is no reason to do so. Use the compatibility cache_* macro to access the current in-core index like everybody else. While at it, fix typo in the comment for a function to check if a path within a directory appears in the index. Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit 7126102

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

dir.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,14 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
472472
unsigned long sz;
473473
enum object_type type;
474474
void *data;
475-
struct index_state *istate = &the_index;
476475

477476
len = strlen(path);
478-
pos = index_name_pos(istate, path, len);
477+
pos = cache_name_pos(path, len);
479478
if (pos < 0)
480479
return NULL;
481-
if (!ce_skip_worktree(istate->cache[pos]))
480+
if (!ce_skip_worktree(active_cache[pos]))
482481
return NULL;
483-
data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
482+
data = read_sha1_file(active_cache[pos]->sha1, &type, &sz);
484483
if (!data || type != OBJ_BLOB) {
485484
free(data);
486485
return NULL;
@@ -924,13 +923,13 @@ enum exist_status {
924923
};
925924

926925
/*
927-
* Do not use the alphabetically stored index to look up
926+
* Do not use the alphabetically sorted index to look up
928927
* the directory name; instead, use the case insensitive
929928
* name hash.
930929
*/
931930
static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
932931
{
933-
struct cache_entry *ce = index_name_exists(&the_index, dirname, len + 1, ignore_case);
932+
struct cache_entry *ce = cache_name_exists(dirname, len + 1, ignore_case);
934933
unsigned char endchar;
935934

936935
if (!ce)

0 commit comments

Comments
 (0)