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 <gitster@pobox.com>
Junio C Hamano committed
Aug 15, 2013 at 12:08 UTC
712610274211dc6cd7c83c5ccf88db5a75af8c25
1 file changed
+5
-6
dir.c
+5
-6
@@ -472,15 +472,14 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
472
unsigned long sz;
473
enum object_type type;
474
void *data;
475
- struct index_state *istate = &the_index;
475
476
len = strlen(path);
478
- pos = index_name_pos(istate, path, len);
477
+ pos = cache_name_pos(path, len);
478
if (pos < 0)
479
return NULL;
481
- if (!ce_skip_worktree(istate->cache[pos]))
480
+ if (!ce_skip_worktree(active_cache[pos]))
481
return NULL;
483
- data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
482
+ data = read_sha1_file(active_cache[pos]->sha1, &type, &sz);
483
if (!data || type != OBJ_BLOB) {
484
free(data);
485
return NULL;
@@ -924,13 +923,13 @@ enum exist_status {
923
};
924
925
/*
927
- * Do not use the alphabetically stored index to look up
926
+ * Do not use the alphabetically sorted index to look up
927
* the directory name; instead, use the case insensitive
928
* name hash.
929
*/
930
static enum exist_status directory_exists_in_index_icase(const char *dirname, int len)
931
{
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);
933
unsigned char endchar;
934
935
if (!ce)