From: Ben Peart Date: Thu, 15 Mar 2018 15:25:20 +0000 (-0400) Subject: Fix bugs preventing adding updated cache entries to the name hash X-Git-Tag: v2.17.0-rc1~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e267b7a240454538349407c0101cc17168cebcf;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- 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