From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796252104; b=5KAPwKQRkAdd+vh7C1ICH0nseSyLvL0kKeN9QnrFqv28Fd0GqTHUNfsyruJff/AypSPF D3v1mYHQ108/0i1U3fF1U+QXJjS4fAnoKIFd9t7xpYwFg8lVFH+yNzjlSOE8qWZMwMcGs 9NqtSQBu5YuUwvOveQywCh/ZT7bPxzn3LNHWXvpVarFBtHai6//Km7H+vVDiw28fhe09K kwiqgS7LfCKTDsjbHgDjg4Fm+GtCSM6yn9ff4MySBOi/rfkpzgvXBsyQWupMkQBUtg9b1 78uM+p6Gzs7ksgE85VQtodmwPFAoXQzulkN2sdThWNBBoXjMwgdBmOiH2XcHDbqparQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796252104; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=gBZTxUnjSfbk6FOzCjJgpJKrP0bmUbO9jccFeI4YIgQ=; b=GG1ng+bUxD2Qx4sNejSqiR5PrUm/kcfFs8UV9I85TT4/qM/v11Rg4sHcm+3a/0YeNhhS XmA2HkODGBupXwNTMCPYH+sXBu/SW3GFNJIdMcQ/KGNFs1TgF0OocCmD+2sMk17DhymPg eEu1p1KOOk9n9zaRj7uGcUO0jFwijJ7v2K4V4lc9yIhzuAVKmZNRmjSpeIqpNAH6dlSXC k2avcisSr+pvIZ2QbotRx0s54M0nxEJz7/pxXmdmqMJ943h7HdGnUHabVwZ2DuVPJ3f1G oj4z6yoezNzvqzuytF43PSNzFaHvIhLMI46YVlu1BTNmCAGor5WfQYa5V7rdQXbuJgw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=nBPqndt2; arc=none smtp.remote-ip=209.85.210.46 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E5D1606A322 for ; Wed, 2 Dec 2026 22:55:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E5D1606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=nBPqndt2 Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-8253bc5a613so8706315a34.0 for ; Wed, 02 Dec 2026 14:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796252102; x=1796856902; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=gBZTxUnjSfbk6FOzCjJgpJKrP0bmUbO9jccFeI4YIgQ=; b=nBPqndt2yUkQOGCkFAd4Ha47EZWR3+bnnD7ChlL3Q1MyNRi+BZpQItCXz4HzUWjlEn 8t1jwi7bkGB7nz4wxPmp+OPBCVDVMYCa3pxvLFJT9Dv/gKoQy/Yr9+RYAKdQJApmSHux /1DpmesfOz+E2cgmEmEUZ3q37d6+lq4JjioHl+C21bUuAyq1SQ4kMD8Ss77NWrnb/KBc gh9p2/DNe3pMWrfw0cs70DsK9AXVpIQilWwENItjEtVxKA0rgaH768mkDszHzrP0rnj2 Sf/QFx1vCi5i7dAQnIB5GB3lUf6kE6VrdZSp41djXgQkxKeZWC8fpeIWJoE0Xtk19Xsx CWtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796252102; x=1796856902; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gBZTxUnjSfbk6FOzCjJgpJKrP0bmUbO9jccFeI4YIgQ=; b=rFCNmhOgFuuJUlFAZY3EtTUGI39Lk+F6sW9UbB8cALPDMrgIdA43mt5VJGb7GwfIjC 7R15obCs4ZN4UiJZTh6cVls4SZbnMNN/JM9pMXmioYE2BDqPhlSKlOGYEu3wVCkurSVm /DH0WI9cdcqVx1AyLpacpRpGapZqib2aU0Yfv8L0VjQpiKbcj/gFdMfKuhFJ2UIQ/bFv ACH35HPmHwGI4Ms4aeAbl95qhJcAABjQna9PMscVOjObQVh9ebGZg0LmnMBAhGvjhNZv c6cL5WjvfQhDzZZy/xOfGcIOAGjmBm26wvl+sGY5mjTnpK5kJq2NcJzzNOn+aypf0bzU N7fw== X-Gm-Message-State: APuU4Z+3OKIt8jIUsa1gou0TBxjfNpAihgt1NSdJlxpowUtiy0K46cFT QpYtlVJLQVD9ixBzUvnHiur8zw4S+sCE+YqRjEAZHfr00RHe5ZGAMTUn X-Gm-Gg: AZFdTZcsgK9nbuInvIGOWR5Azyhqr3NtoyzaAcsPPDmOk7d5vxN4Qftg7gYmT5HScR3 5bTDhroEi3BIUdkvMOlPXT372zudKqsjua90slo6Cn22KndLYfzlrF0qWG1zWt0pB7C3ytlzBFt EhQskkZ62SZ9zfxfZoMm3QK45G5PuktMM1An+dReq3/bzwf8gWTLUQA1B6XnTfbiTgeoaITpezl ilAbujBlcZdM8zRbG0pAPz6dbunyG2IDDJULyd8CBy6zTDzZot7F5E2iPRRYDbs805eTS1KYITQ 0NlfblCWTEhFVHJafUBc19zRVG6ENBghpJgTtFH4QET9lDHIdpz0k5na3kmfAejax9nd8A7uQqe cK5ChnQB/I2wVEZJFH3+tA/rf/iQjQl6NfCJbcDFEooI9CxCNjMJ/H3T+aP1Fg0GOsBGvk1GFZk Tcvxke3Vp/OYRNkJELESmYy6RlZnCxQlQqQbaFwSalXS4JXKGuqRulzK6tXXq39aPXbJSWHk+nR TKSJAlZ5upVJLL5M+nBKdMZS4waye+N8POkfrJxzKx91q19pcwzsUUvOqJ3GdBbiTFM2Kw45ZIB An9gWS9jvSZ88g5Fm3UqybNTfPVnT9e3T0QrpBpZER9UhdR5KIrD X-Received: by 2002:a05:6820:162c:b0:71a:facc:5a3b with SMTP id 006d021491bc7-71b395992edmr38392112eaf.83.1796252102535; Wed, 02 Dec 2026 14:55:02 -0800 (PST) Received: from localhost ([136.51.44.64]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-86316822ad4sm29088725a34.3.2026.12.02.14.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 14:55:02 -0800 (PST) Date: Wed, 2 Dec 2026 16:54:59 -0600 From: Justin Tobler To: Patrick Steinhardt Cc: git@vger.kernel.org, Junio C Hamano Subject: Re: [PATCH v2 2/7] commit-graph: simplify linking commit graph chains Message-ID: References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im> <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im> On 26/11/20 01:22PM, 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. Makes sense. The base layer already knows about all the other dependent layers. There isn't really a reason to pass this information again. > 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. Ok. > 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(-) > > diff --git a/commit-graph.c b/commit-graph.c > index 0c75939910d..9e5656992eb 100644 > --- a/commit-graph.c > +++ b/commit-graph.c > @@ -575,44 +575,48 @@ static void validate_mixed_bloom_settings(struct commit_graph *g) > } > } > > -static int add_graph_to_chain(struct commit_graph *g, > - struct commit_graph *chain, > - struct object_id *oids, > - int n) > +int commit_graph_link_base(struct commit_graph *g, > + struct commit_graph *base) > { > + struct commit_graph *layer; > + size_t n = 0; > + > + for (layer = base; layer; layer = layer->base_graph) > + n++; Here we figure out the number of base layers there are. > + > if (n && !g->chunk_base_graphs) { > warning(_("commit-graph has no base graphs chunk")); > - return 0; > + return -1; > } > > if (g->chunk_base_graphs_size / g->hash_algo->rawsz < n) { > warning(_("commit-graph base graphs chunk is too small")); > - return 0; > + return -1; > } > > - while (n) { > + for (layer = base; layer; layer = layer->base_graph) { > n--; > - > - if (!hasheq(oids[n].hash, g->chunk_base_graphs + st_mult(g->hash_algo->rawsz, n), > + if (!hasheq(layer->oid.hash, > + g->chunk_base_graphs + st_mult(g->hash_algo->rawsz, n), > g->hash_algo)) { We compare each of the base layers with the chunk base layers of the new layer. Looks good. The rest of this patch also looks good. -Justin