From: "Xing Xin" <bupt_xingxin@163.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "blanet via GitGitGadget" <gitgitgadget@gmail.com>,
git@vger.kernel.org, "Xing Xin" <xingxin.xx@bytedance.com>
Subject: Re:Re: [PATCH v2] read-cache: hash the shared index even with index.skipHash
Date: Mon, 30 Nov 2026 15:47:53 +0800 (CST) [thread overview]
Message-ID: <47be148e.6b3d.1a22b6cb367.Coremail.bupt_xingxin@163.com> (raw)
In-Reply-To: <xmqq7bhwvdle.fsf@gitster.g>
At 2026-11-29 05:41:01, "Junio C Hamano" <gitster@pobox.com> wrote:
> The updated commit message explains both the failure mode and the
> trade-off clearly, without overstating the savings on split-index
> writes.
Thanks.
> It is also worth checking how concurrent-update detection behaves when
> both features are active. Suppose a repository has both core.splitIndex
> and index.skipHash enabled, and "git status" reads the split index and
> later calls repo_verify_index() before writing back.
>
> Because do_write_locked_index() still writes the split index with
> skip_hash enabled, the split index has a null trailing hash on disk, and
> merge_base_index() does not overwrite '.oid' or '.file_stat' on the main
> index_state. Thus verify_index_from() still sees a null '.oid' and
> falls back to index_file_unchanged() on .git/index, so concurrent
> updates are still detected correctly?
Yes. read_index_from() reads .git/index into the index_state itself,
where do_read_index() records its null trailer in istate->oid and its
stat data in istate->file_stat, and reads the shared index into the
separate istate->split_index->base. Nothing touches these two fields
of the main index_state after that: merge_base_index() only copies
cache entries out of istate->split_index->base, and do_write_index()
sets them only on the index_state that it writes, which is
istate->split_index->base for the shared index. So verify_index_from()
always checks .git/index, and since every index update, with or
without a new shared index, ends by renaming a new .git/index into
place, index_file_unchanged() notices it.
The two index.skipHash=true tests in t7508, "status keeps an index
update made after it read the index" and "status refresh does not
overwrite an index update made while collecting", check exactly this.
This patch drops the workaround that made them unset
GIT_TEST_SPLIT_INDEX, so they now also run with a split index in the
linux-feature-testbed CI job, which sets it. With
GIT_TEST_SPLIT_INDEX=1 they pass, and they fail when
verify_index_from() skips the stat check. I also ran the first one
with core.splitIndex=true instead, with the same results.
> Likewise, "git fsck" runs read_index_from() with verify_index_checksum
> set, so verify_hdr() accepts the null trailer on .git/index while
> verifying the real hash on the shared index file.
Right. do_read_index() calls verify_hdr() for both files, and with
this patch the shared index always has a real trailer, so "git fsck"
verifies it: flipping a byte in an entry of the shared index makes it
fail with "bad index file sha1 signature". The split index, like any
index written with index.skipHash, has no checksum to verify.
prev parent reply other threads:[~2026-11-30 7:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 13:57 [PATCH] read-cache: hash the shared index even with index.skipHash blanet via GitGitGadget
2026-11-26 19:21 ` Junio C Hamano
2026-11-27 12:59 ` Xing Xin
2026-11-27 18:44 ` Junio C Hamano
2026-11-28 9:27 ` [PATCH v2] " blanet via GitGitGadget
2026-11-28 21:41 ` Junio C Hamano
2026-11-30 7:47 ` Xing Xin [this message]
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=47be148e.6b3d.1a22b6cb367.Coremail.bupt_xingxin@163.com \
--to=bupt_xingxin@163.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=xingxin.xx@bytedance.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