diff options
author | Ben Peart <benpeart@microsoft.com> | 2018-03-15 18:25:20 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-15 20:58:30 +0300 |
commit | 0e267b7a240454538349407c0101cc17168cebcf (patch) | |
tree | 5e46d2d9bfb91b4a52510ca20992c4787dfe16a5 | |
parent | 38e79b1fdab9244e1727d0698afcf3bb8956c0a4 (diff) |
Fix bugs preventing adding updated cache entries to the name hash
Update replace_index_entry() to clear the CE_HASHED flag from the new cache
entry so that it can add it to the name hash in set_index_entry()
Fix refresh_cache_ent() to use the copy_cache_entry() macro instead of memcpy()
so that it doesn't incorrectly copy the hash state from the old entry.
Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | read-cache.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c index 2eb81a66b9..96fa833111 100644 --- a/read-cache.c +++ b/read-cache.c @@ -62,6 +62,7 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cache replace_index_entry_in_base(istate, old, ce); remove_name_hash(istate, old); free(old); + ce->ce_flags &= ~CE_HASHED; set_index_entry(istate, nr, ce); ce->ce_flags |= CE_UPDATE_IN_BASE; mark_fsmonitor_invalid(istate, ce); @@ -1325,7 +1326,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate, size = ce_size(ce); updated = xmalloc(size); - memcpy(updated, ce, size); + copy_cache_entry(updated, ce); + memcpy(updated->name, ce->name, ce->ce_namelen + 1); fill_stat_cache_info(updated, &st); /* * If ignore_valid is not set, we should leave CE_VALID bit |