diff --git a/cache.h b/cache.h index ac5ab4ef9d..33fc8337c6 100644 --- a/cache.h +++ b/cache.h @@ -830,6 +830,15 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na */ int index_name_pos(struct index_state *, const char *name, int namelen); +/* + * Like index_name_pos, returns the position of an entry of the given name in + * the index if one exists, otherwise returns a negative value where the negated + * value minus 1 is the position where the index entry would be inserted. Unlike + * index_name_pos, however, a sparse index is not expanded to find an entry + * inside a sparse directory. + */ +int index_name_pos_sparse(struct index_state *, const char *name, int namelen); + /* * Determines whether an entry with the given name exists within the * given index. The return value is 1 if an exact match is found, otherwise diff --git a/read-cache.c b/read-cache.c index 76f372ff91..06e5b06e63 100644 --- a/read-cache.c +++ b/read-cache.c @@ -620,6 +620,11 @@ int index_name_pos(struct index_state *istate, const char *name, int namelen) return index_name_stage_pos(istate, name, namelen, 0, EXPAND_SPARSE); } +int index_name_pos_sparse(struct index_state *istate, const char *name, int namelen) +{ + return index_name_stage_pos(istate, name, namelen, 0, NO_EXPAND_SPARSE); +} + int index_entry_exists(struct index_state *istate, const char *name, int namelen) { return index_name_stage_pos(istate, name, namelen, 0, NO_EXPAND_SPARSE) >= 0;