Skip to content

Commit 0e267b7

Browse files
benpeartgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38e79b1 commit 0e267b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

read-cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cache
6262
replace_index_entry_in_base(istate, old, ce);
6363
remove_name_hash(istate, old);
6464
free(old);
65+
ce->ce_flags &= ~CE_HASHED;
6566
set_index_entry(istate, nr, ce);
6667
ce->ce_flags |= CE_UPDATE_IN_BASE;
6768
mark_fsmonitor_invalid(istate, ce);
@@ -1325,7 +1326,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
13251326

13261327
size = ce_size(ce);
13271328
updated = xmalloc(size);
1328-
memcpy(updated, ce, size);
1329+
copy_cache_entry(updated, ce);
1330+
memcpy(updated->name, ce->name, ce->ce_namelen + 1);
13291331
fill_stat_cache_info(updated, &st);
13301332
/*
13311333
* If ignore_valid is not set, we should leave CE_VALID bit

0 commit comments

Comments
 (0)