Re: [PATCH v2] read-cache: hash the shared index even with index.skipHash
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 28, 2026, 21:41 UTC
- Message-ID
- <xmqq7bhwvdle.fsf@gitster.g>
- In-Reply-To
- <pull.2337.v2.git.1795858039529.gitgitgadget@gmail.com>
"blanet via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 19 quoted lines
> From: Xing Xin <xingxin.xx@bytedance.com> > > The shared index of a split index is named after its trailing hash, > which the split index records in its "link" extension to find it. > Since ee1f0c242e (read-cache: add index.skipHash config option, > 2023-01-06), do_write_index() skips that hash for the shared index > too, so with index.skipHash and core.splitIndex both set, the shared > index is written as "sharedindex.<null OID>" and the split index > records a null OID as its base. Reading the index back, a null base > ... > This gives up index.skipHash on the file where skipping the hash would > save the most per write, as the shared index holds nearly all the > entries. But what index.skipHash saves is the hashing done on each > write, and the split index is designed to make writing a shared index > rare: once there is one, a new one is written only when more than > splitIndex.maxPercentChange of the entries (20% by default) are not > in it. The frequent writes are of the split index, which holds the > entries added or changed since the shared index was written, as well > as all the extensions, and still skips the hash.
The updated commit message explains both the failure mode and the trade-off clearly, without overstating the savings on split-index writes.
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?
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.