🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4294

Re: [PATCH v2 2/7] commit-graph: simplify linking commit graph chains

#4294
From: Justin Tobler
Date: Wed, 02 Dec 2026 22:54
84 lines
13552 bytes
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 <ps@pks.im>
> ---
>  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
Technical Details
Message-ID: <axCe8Vt9CvYN-rpU@denethor>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76931-linux-kernel-git=dewy.ru
References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im> <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76931-linux-kernel-git=dewy.ru
From: jltobler@gmail.com (Justin Tobler)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v2 2/7] commit-graph: simplify linking commit graph chains
Date: Wed, 2 Dec 2026 16:54:59 -0600
Organization: Usenet Network
Message-ID: <axCe8Vt9CvYN-rpU@denethor>
References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im>
 <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2081034"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3IeNH9DOwyFKAOctw6dJ2aSvrTI= sha256:GmqHovjMQA/N7ZpyaG0p/HFVlJ+bK7B06Ye/pkNQck8=
	sha1:1hjHrefrpPyc8jCOjnC6c3FrfFo= sha256:7wdMfHF2bxP/mRQfhKBZChINn5+Ls+yhO90ftezwyXY=
Content-Disposition: inline
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1BFC411771C; Thu,  3 Dec 2026 01:55:20 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id w-HaJ9df9nkJ;
	Thu,  3 Dec 2026 01:55:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76931-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id CA263117304; Thu,  3 Dec 2026 01:55:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 0D9CC2918B; Wed,  2 Dec 2026 22:55:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796252104;
	b=afINNQf7BNH446A/7FQcMng8VPhfsrMFgOYnSM7tgc5kx6LFh0k5t9y2W7/kUIiAzIUI
	 tdCqZwRp2BFOovTIiQcLLtyjsaGUXpyEU+AWnbjrKrfIRUO04dIJimCCdmpbQ8n9aIW0S
	 xE3peGffnUWSEiAbyUrdcEHQ7cTqC4ry76tA78GWSPN4AsxE8bRbFJcvMrpIHPu1HCQh2
	 gCjFkAIwT65EoWPorTvEtP86uWwWL3UNGYzXANjYe866GpnpVLVbu2BnkKY9MbQNehPgf
	 OdgGyXtsxWIsOnhg8gLRiyjqPOmecn3GkMly7jbc6PhZCn0fWkVzOSqGjmvDUvpD1dA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796252104;
	h=X-Original-To:Received: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:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=gBZTxUnjSfbk6FOzCjJgpJKrP0bmUbO9jccFeI4YIgQ=;
	b=z9E3sKlJ28iU0/US8diWK5qrVtXJUjfqpKywpFHf28xXDJAhPsMiv8cLC2C5Y7nS+H4v
	 jNIMsM7Uu3bigP9MEcuLnVOcs60ykEgxA7kIj02Pqv3ufeaXGgqbzY5PGEk3JzVsAbe/V
	 WEkov+9NmLV8fx0ZNHJJt107AVvIEz5vSvTP+uPGHLaQskG9jLODZAjVrrjrlf2tM1HAB
	 vrl+4I6P4+JBX147pzWksZwAXrRN3Q3gz3irKnL/Bwl1I/f5uCXoFvoZIE/UBb7sUesdp
	 GZDW44ticbM/lJ4ERITaBd8lehnn07nmWLMWst4WhX/1h1gL/LPcaCzGcJw3B97iZdA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=nBPqndt2;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D9454606A334;
	Wed,  2 Dec 2026 22:55:04 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.46
X-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==
X-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==
X-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
X-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 <git@vger.kernel.org>; Wed,  2 Dec 2026 22:55:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E5D1606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-8253bc5a613so8706315a34.0
        for <git@vger.kernel.org>; Wed, 02 Dec 2026 14:55:03 -0800 (PST)
X-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)
X-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)
X-Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261120-pks-odb-pluggable-commit-graphs-v2-2-31f2341a9932@pks.im>