diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2021-04-12 21:08:17 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-04-14 13:48:01 -0700 |
commit | 4589bca829a2ace58bc98876cccd7dbd2e89f732 (patch) | |
tree | de51de02e3730e05b8689e64519db60b5374806b /name-hash.c | |
parent | 71f82d032f34f7aa3708b4cdaeb12db617449606 (diff) | |
download | git-4589bca829a2ace58bc98876cccd7dbd2e89f732.tar.gz |
name-hash: use expand_to_path()
A sparse-index loads the name-hash data for its entries, including the
sparse-directory entries. If a caller asks for a path that is contained
within a sparse-directory entry, we need to expand to a full index and
recalculate the name hash table before returning the result. Insert
calls to expand_to_path() to protect against this case.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'name-hash.c')
-rw-r--r-- | name-hash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/name-hash.c b/name-hash.c index d08deaa2c9..383cf58996 100644 --- a/name-hash.c +++ b/name-hash.c @@ -8,6 +8,7 @@ #include "cache.h" #include "thread-utils.h" #include "trace2.h" +#include "sparse-index.h" struct dir_entry { struct hashmap_entry ent; @@ -683,6 +684,7 @@ int index_dir_exists(struct index_state *istate, const char *name, int namelen) struct dir_entry *dir; lazy_init_name_hash(istate); + expand_to_path(istate, name, namelen, 0); dir = find_dir_entry(istate, name, namelen); return dir && dir->nr; } @@ -693,6 +695,7 @@ void adjust_dirname_case(struct index_state *istate, char *name) const char *ptr = startPtr; lazy_init_name_hash(istate); + expand_to_path(istate, name, strlen(name), 0); while (*ptr) { while (*ptr && *ptr != '/') ptr++; @@ -716,6 +719,7 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na unsigned int hash = memihash(name, namelen); lazy_init_name_hash(istate); + expand_to_path(istate, name, namelen, icase); ce = hashmap_get_entry_from_hash(&istate->name_hash, hash, NULL, struct cache_entry, ent); |