From: Kaartic Sivaraam Date: Thu, 03 Dec 2026 10:03:09 GMT Subject: Re: [PATCH v2 2/7] commit-graph: simplify linking commit graph chains Message-ID: In-Reply-To: <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im> On 11/20/26 17:52, Patrick Steinhardt wrote: > When we load a commit graph chain we verify for every layer that the > hash of the base commit graph matches what the current tip has in its > base graphs chunk. To do so we pass both the chain itself as well as the > array of object IDs that we have read from the commit-graph chain file > to `add_graph_to_chain()`. > > But the array of object IDs is redundant information: we have already > loaded and linked the base layers, and as part of that we have stored > their respective hashes in the structure itself. Consequently, we can > already derive the hashes by walking the chain of base layers. > The hashes stored in the structure are the layers' trailers, not the hashes from the chain file. They only agree because the previous patch now compares each layer's trailer with the chain file right after loading it. Since this function becomes public so that the backend can call it, could the comment in the header say that it validates `g` against the trailers of `base`, and that callers are expected to have verified those against the chain file themselves? > Refactor the function to only take the new tip and base layers as input > and derive all the other information ad-hoc and make the function > public. This prepares for a subsequent commit, where we are about to > move the logic that creates commit graph chains into the object database > backend. > > While at it, align on error semantics so that we return 0 on success, or > a negative error code otherwise. > > Signed-off-by: Patrick Steinhardt > --- > commit-graph.c | 50 ++++++++++++++++++++++++++------------------------ > commit-graph.h | 8 ++++++++ > 2 files changed, 34 insertions(+), 24 deletions(-) > Otherwise, the change itself looks fine to me given the changes in 1/7. -- Sivaraam