]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Fix bugs preventing adding updated cache entries to the name hash
authorBen Peart <benpeart@microsoft.com>
Thu, 15 Mar 2018 15:25:20 +0000 (11:25 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Mar 2018 17:58:30 +0000 (10:58 -0700)
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>
read-cache.c

index 2eb81a66b941325dc339d61a0ab804a60cbb8be2..96fa833111893544cc31504b1b17791417518e12 100644 (file)
@@ -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