git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1] Fix bugs preventing adding updated cache entries to the name hash

From
Ben Peart <benpeart@microsoft.com>
Date
Mar 15, 2018, 15:25 UTC
Message-ID
<20180315152520.23264-1-benpeart@microsoft.com>

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>
---
Notes:
    Base Ref: master
    Web-Diff: https://github.com/benpeart/git/commit/079be4ac07
    Checkout: git fetch https://github.com/benpeart/git ce_hashed-v1 && git checkout 079be4ac07
 read-cache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c
index 977921d90c..bdfa552861 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);
@@ -1324,7 +1325,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

base-commit: d0db9edba0050ada6f6eac68061599690d2a4333
-- 
2.16.2.windows.1
Next: Junio C Hamano
Message 1 of 4 in “Fix bugs preventing adding updated cache entries to the name hash”
  1. Fix bugs preventing adding updated cache entries to the name hashBen Peart, Mar 15, 2018
  2. Junio C HamanoMar 15, 2018
  3. Ben PeartMar 15, 2018
  4. Junio C HamanoMar 15, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.