Re: [PATCH v2 1/7] commit-graph: verify all trailer hashes against the chain file
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 3, 2026, 09:12 UTC
- Message-ID
- <axEymH5yfz3cysYz@pks.im>
- In-Reply-To
- <axEay2CYz6zboLz0@pks.im>
On Thu, Dec 03, 2026 at 08:31:26AM +0100, Patrick Steinhardt wrote:
Show 38 quoted lines
> On Wed, Dec 02, 2026 at 04:29:11PM -0600, Justin Tobler wrote: > > On 26/11/20 01:22PM, Patrick Steinhardt wrote: > > > @@ -341,6 +342,32 @@ test_expect_success 'warn on base graph chunk incorrect' ' > > > ) > > > ' > > > > > > +test_expect_success 'tip layer trailer must match chain file' ' > > > + git clone --no-hardlinks . tip-trailer && > > > + ( > > > + cd tip-trailer && > > > + test_line_count = 2 $graphdir/commit-graph-chain && > > > + tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph && > > > + corrupt_trailer "$tip_file" && > > > + git -c core.commitGraph=false log >expect && > > > + git -c core.commitGraph=true log >actual 2>err && > > > + test_cmp expect actual && > > > + test_grep "commit-graph chain does not match" err > > > + ) > > > +' > > > > With this test we corrupt the trailer of the tip layer and check that is > > was indeed validated. Previously it would have been ignored. The base > > layer should still be loaded and used though, but we don't really check > > explicitly which layers were kept. Not sure it there is a good way to do > > that anyway though. > > Not that I'd know of, at least. `test-tool read-graph` gives us some > info, but it doesn't give us the ability to figure out which layers have > been loaded. Now we could of course extend it to give us that info, but > I'm not sure that's worth it for a single test. > > Hmm. That being said, the test-tool works somewhat funny in that it > seems to only give information about the uppermost layer. So we can > assert that initially it covers less commits, and then when we corrupt > the uppermost layer it covers more commits because it uses the base > layer now. > > I'll adapt the test a bit.
Oh, well, I couldn't resist, so I've now gone the full route and have extended the test-tool. Funny enough, extending the infra actually lets me deduplicate some test logic, and so overall we actually remove more code than we add even though we now have more capabilities:
t/helper/test-read-graph.c | 9 +++++++++ t/lib-commit-graph.sh | 62 ++++++++++++++++++++++++++++++++++++++------------------ t/t4216-log-bloom.sh | 15 ++------------ t/t5318-commit-graph.sh | 34 +++++++++++++++---------------- t/t5324-split-commit-graph.sh | 69 ++++++++++----------------------------------------------------- t/t5328-commit-graph-64bit-time.sh | 10 ++++----- 6 files changed, 87 insertions(+), 112 deletions(-)
So it's a win-win, except that it's going to be two more patches to review. But that's your problem :P
Patrick