From: Junio C Hamano <gitster@pobox.com>
To: Ben Peart <benpeart@microsoft.com>
Cc: git@vger.kernel.org, pclouds@gmail.com, blees@dcon.de
Subject: Re: [PATCH v1] Fix bugs preventing adding updated cache entries to the name hash
Date: Thu, 15 Mar 2018 10:58:00 -0700 [thread overview]
Message-ID: <xmqqfu515ihj.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180315152520.23264-1-benpeart@microsoft.com> (Ben Peart's message of "Thu, 15 Mar 2018 11:25:20 -0400")
Ben Peart <benpeart@microsoft.com> writes:
> 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()
OK.
> 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);
As we are removing "old" that is not "ce", an earlier call to
remove_name_hash() that clears the CE_HASHED bit from the cache
entry does not help us at all. We need to clear the bit from "ce"
ourselves before calling set_index_entry() on it, otherwise the call
would become a no-op wrt the name hash. Makes sense.
Makes me wonder why "ce" which is a replacement for what is in the
index already has the hashed bit, though. Is that the failure to
use copy_cache_entry() in the caller the other part of this patch
fixes? To me it looks like copy_cache_entry() is designed for
copying an entry's data to another one that has a different name,
but in the refresh codepath, we _know_ we are replacing an old entry
with an entry with the same name, so it somehow feels a bit strange
to use copy_cache_entry(), instead of doing memcpy() (and possibly
dropping the HASHED bit from the new copy--but wouldn't that become
unnecessary with the fix to replace_index_entry() we saw above?)
Is this fix something we can demonstrate in a new test, by the way?
Thanks.
next prev parent reply other threads:[~2018-03-15 17:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 15:25 [PATCH v1] Fix bugs preventing adding updated cache entries to the name hash Ben Peart
2018-03-15 17:58 ` Junio C Hamano [this message]
2018-03-15 18:44 ` Ben Peart
2018-03-15 18:58 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfu515ihj.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=benpeart@microsoft.com \
--cc=blees@dcon.de \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).