diff options
author | Victoria Dye <vdye@github.com> | 2022-08-08 21:07:51 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-08 22:21:50 +0200 |
commit | 9553aa0f6c844085b3fbf05da5440dd7096dd764 (patch) | |
tree | d1415dd910ce3263f8337570f39ef49a7465d752 /read-cache.c | |
parent | oneway_diff: handle removed sparse directories (diff) | |
download | git-9553aa0f6c844085b3fbf05da5440dd7096dd764.tar.xz git-9553aa0f6c844085b3fbf05da5440dd7096dd764.zip |
cache.h: create 'index_name_pos_sparse()'
Add 'index_name_pos_sparse()', which behaves the same as 'index_name_pos()',
except that it does not expand a sparse index to search for an entry inside
a sparse directory.
'index_entry_exists()' was originally implemented in 20ec2d034c (reset: make
sparse-aware (except --mixed), 2021-11-29) as an alternative to
'index_name_pos()' to allow callers to search for an index entry without
expanding a sparse index. However, that particular use case only required
knowing whether the requested entry existed, so 'index_entry_exists()' does
not return the index positioning information provided by 'index_name_pos()'.
This patch implements 'index_name_pos_sparse()' to accommodate callers that
need the positioning information of 'index_name_pos()', but do not want to
expand the index.
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |