🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4170

[PATCH 1/5] builtin/multi-pack-index: resolve default object directory lazily

#4170
From: Justin Tobler
Date: Mon, 30 Nov 2026 21:54
66 lines
13060 bytes
The object directory used by git-multi-pack-index(1) defaults to the
path of the primary object database source. This default is set eagerly
in `cmd_multi_pack_index()` before any options are parsed, and again
when "--no-object-dir" is given. Both cases access `the_repository` to
do so, and the eager initialization additionally has to guard against
the repository not being set up.

In a subsequent commit, the remaining references to `the_repository` in
"builtin/multi-pack-index.c" are removed. In preparation for this
change, leave the object directory unset in both cases and lazily fall
back to the path of the primary source in `handle_object_dir_option()`,
where the repository is passed in explicitly. This also removes the
need for the defensive `NULL` checks guarding the eager initialization.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 builtin/multi-pack-index.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index c48212290cf8..1a27d523c7ab 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -80,7 +80,7 @@ static int parse_object_dir(const struct option *opt, const char *arg,
 	char **value = opt->value;
 	free(*value);
 	if (unset)
-		*value = xstrdup(the_repository->objects->source->path);
+		*value = NULL;
 	else
 		*value = real_pathdup(arg, 1);
 	return 0;
@@ -88,10 +88,16 @@ static int parse_object_dir(const struct option *opt, const char *arg,
 
 static struct odb_source_packed *handle_object_dir_option(struct repository *repo)
 {
-	struct odb_files_dir *dir = odb_source_files_find_dir(repo->objects, opts.object_dir);
+	const char *object_dir = opts.object_dir;
+	struct odb_files_dir *dir;
+
+	if (!object_dir)
+		object_dir = repo->objects->source->path;
+
+	dir = odb_source_files_find_dir(repo->objects, object_dir);
 	if (!dir)
 		die(_("object directory is not an alternate of the current repository: '%s'"),
-		    opts.object_dir);
+		    object_dir);
 	return dir->packed;
 }
 
@@ -424,11 +430,6 @@ int cmd_multi_pack_index(int argc,
 
 	repo_config(the_repository, git_default_config, NULL);
 
-	if (the_repository &&
-	    the_repository->objects &&
-	    the_repository->objects->source)
-		opts.object_dir = xstrdup(the_repository->objects->source->path);
-
 	argc = parse_options(argc, argv, prefix, options,
 			     builtin_multi_pack_index_usage, 0);
 	FREE_AND_NULL(options);
-- 
2.56.0
Technical Details
Message-ID: <c381afb0da593080ae8fc96a6187b579da829658.1796075503.git.jltobler@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76734-linux-kernel-git=dewy.ru
References: <cover.1796075503.git.jltobler@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76734-linux-kernel-git=dewy.ru
From: jltobler@gmail.com (Justin Tobler)
Newsgroups: linux.kernel.git
Subject: [PATCH 1/5] builtin/multi-pack-index: resolve default object directory lazily
Date: Mon, 30 Nov 2026 15:54:57 -0600
Organization: Usenet Network
Message-ID: <c381afb0da593080ae8fc96a6187b579da829658.1796075503.git.jltobler@gmail.com>
References: <cover.1796075503.git.jltobler@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1548991"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WXSrp986bXAwTsqv/BcXKiYdtvs= sha256:ZHBIKaiKtLbBVUYgTkVGvEv95SdMB7CBE2I+J8jdLWc=
	sha1:uB/ljt8uPHN095Yee8P6Ztip4lo= sha256:5S1NnVwWV6CtY/eL+H2RtYLKaLFOl6+jziTSDEByxHo=
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 3390A12600E; Tue,  1 Dec 2026 00:58:59 +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 o55ZsfHvNQY3;
	Tue,  1 Dec 2026 00:58:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76734-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 0D29D126010; Tue,  1 Dec 2026 00:58:47 +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 D0AB82BF29; Mon, 30 Nov 2026 21:58:45 +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=1796075925;
	b=gmjck/43ct3CflxkGbVXGhSvB7vnCanNLB5IVumxw1ioNdHqrIOcG/ExkdB8kWZIBLdy
	 QQCF93VcEkVEJemXXiTYpxIfbNpVj9qaH5pOd0k9sgjKNz97SI5A7cXCjGs8FqXFA0wHv
	 6vyNWm+dNAkZrepAzG9HDgyuk7Z9JhVk6TuRHLY6KTD6lHUvjqzMqW1IXR6xez1im57FA
	 4Zh26wnGjX0facYL/5NPiCDhxCEX8bvBg3eokjvZuG4WGxMQRNUDjg5a36J2blOdPZDJp
	 fGwK1wPFp/9GhnnAWkRbkPzzX96O9QwxHvlVTrAhe72yq+cxtTzAtg+WvAQx0HFZwdg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796075925;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=HnbdqPiST8tUEQpR3ogoXMX0GN2hxJLaqKblT+/U9+k=;
	b=wjecD1mh2XrBLUSp8zNTWfTxXzktQ/mmDOnobXN0nF1a8ODep1RWjp2ybNysvYOf6fUH
	 mpvAFIBqrkfSUn4o3ReFnSxvfiZ8kh42u03KGuazCtNevd1cUL5TpEEVNJW0kj7zSVUfb
	 6g4cTFkhH3I8Tvv01HyDQQbibxmYIzsQvT1jx3JfhMywbNknhEd0C02hH1vTYP+EaO41g
	 mV1MdMd8Bvc400YqtXj+MYflZVLoutuHNx6+COOAbe7+3Buq1/B3gMtKa7qfs5o5n2vBd
	 ODxF9khE15Oq+94u8cR/lm5cMuiIsahrSr/tQVStKI9k9IroI2nMsoVPjEE6vEwI9Ew==
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=0x4OSfrt;
	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 2A431606A338;
	Mon, 30 Nov 2026 21:58:45 +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=0x4OSfrt
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.53
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796075924;
	b=feFk4EfAfnhWgf2voR8neU8gP49oWmQtXQe/dDFyYQUwhuQQ9iBqQZsQHvaHoAiZQs6C
	 kxwSSIZ8Pp6ZzutqsW8LNcZKLTK/XA0AX1/LiLdvbjOXz2VxbshLTOPSTTmZ15uNBYyr0
	 /PHE2DtgZiZt4ntXrmwWsHKuEbgxKSg0FW1r8fX1S0n118hDmpgxR+RzoyKbcYuQ9kmqv
	 MFB9rk+AOEfLZn7+07Kjs+YsG1j1+4BI9zFi+X4QFjusMlnF/GTVnlIV90BD2dxN/s8kt
	 TbFAsnqx//KAoN4Hja7yEpP0T4fU8sTu7wllYPy/+IuA+5EuYUam66cu1FbYeceBCtg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796075924;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=HnbdqPiST8tUEQpR3ogoXMX0GN2hxJLaqKblT+/U9+k=;
	b=OihsVFeLH/7GRqbotQwJiw8IU30WVSB5q8d9uPg4myk5B8sg32olAQJZduAKoG+L3QEy
	 ev2aq2Am3kMO7xAhWGFUSi+QJpXepcnp/yLxXWuFn4o8HYOWqOE6n9kNlMM8LAW83M80o
	 LeK61xRHvh/rh7C3CotIJMDsyZNYt6qSNfJHjpQx/W4xDGCJIXr/zJwURj6HHs2nqTDKU
	 T4yC+62kVBPe/rBRISpsc+5HvlYo99Wt42hV3sROXeMYWCE67AKgx/k20FnfIqR5YzOEB
	 xXZTLVFHSZYPi4FM7CvdnBzipIpH47ZXTJbnoonYUzO8nkV6LIWHKapv6K8hf2diuvg==
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=0x4OSfrt;
	arc=none smtp.remote-ip=209.85.161.53
X-Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53])
	(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 F190C606A325
	for <git@vger.kernel.org>; Mon, 30 Nov 2026 21:58:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F190C606A325
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-oo1-f53.google.com with SMTP id 006d021491bc7-71ab5e64742so6682367eaf.3
        for <git@vger.kernel.org>; Mon, 30 Nov 2026 13:58:43 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796075923; x=1796680723; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=HnbdqPiST8tUEQpR3ogoXMX0GN2hxJLaqKblT+/U9+k=;
        b=0x4OSfrt3ltBNG/odLVbo26+rrkwVOIqNzo7eecRbH5JhsfZD3kS7wsXQOGu3DGzfv
         H4i/lAmhD0Yac4xd6urcaYzUOu3Y4T+5W2P+kMCmM+TL3NQvk4Mhxj/CZ2yZcxRrPYxq
         Q7ZWUo3L+LOa2t7hDx1V5t/azca1xbdpnpbfZxnlnIzUWV2Az+ZJzkYbXMMmC0Kju509
         H4ThQbpDdzPR6/LzOIwRskhVobjyXc8gmKUFz5KoqooFKyJBuSNoAJWkkDxF30LtR+G7
         c4TmAU0lS1r0Jgt5J81CRONZ9E1bUDhVWaCQ18kXLhiKdO1yztGFZKDdRm6zwS05rI24
         W39g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796075923; x=1796680723;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=HnbdqPiST8tUEQpR3ogoXMX0GN2hxJLaqKblT+/U9+k=;
        b=oOFOoRatMJ2dRzx2x2jx9xxF5BKJnh3EytLV8Grgs0EuI3yAHnEpOqUlzkNowKVMit
         oOg10vRwt27GnBWvBTKQbT/FXO4nETkSDQtyCqQnViAwW/rH7Dt/p/j2nb7D56ZXbrcL
         EdoAVP8mwvqXmNNZa8B05h2h1rXxnrWVZ0c0PHOujrmEfy1S3JMGj9FQ6GQt6qgNlRQG
         6PGQho70gFa7Xf+2BDEyJxcnrEk+RqvA/whAi8hoXJ4EIHbuqgUC7uDz7qSpal4yE4mi
         Mmheza8SP6uaAazBbTo+ukpSZdGfIoxuc+4omgaOxsvOP6W/JvXjkB3Mk41E0gQQO6N9
         pRrA==
X-Gm-Message-State: APuU4Z8t2BHlM1cXjDPb2nOIVEoWXDU8MRZClaGjxIDUKX4M36vJmMjC
	pKKIc04uBS0azjjs+a9psvC5yYotdPg2NKceWjq08TQdw11V00/zw02ghwmHXg==
X-Gm-Gg: AZFdTZeT2Ut1SAedXYrlC9xFsbmECbV9RAkqOoYYkLVuhPdqWst1SC2Yo2tKLpPhew4
	CSIcqtcTXJ8T63WtQC5Kr4Wt4bnnzI12b++NcAYoVtoSiFrKtmn4dJ/cz1DcRJRjwLOvwh0L/b4
	J3Kdj+KtoEbZwa5clxULbHznMYeEoR7BGVDsoLMq9hSZ7VLQnpSc+LbH6WTf6kvrtbVWnjEsAEz
	5wWTv4KSW9KfgyZvZ/ft9MgGgkWY+n6X4xwburzmJJ9xRxJEV6SYGbVg3CHHncyxIGSqkopvL9d
	zD2fY16M8cL1zyzZ4/oOUdwXnASQpE6iDgkklozEO1juNDv9zCqsT5nLxg2EcS9UIycJGdIpYfh
	MUJ9T697ZZbCHg+bLPDS9ny5Dykn7/fwjFmSMSXZ7fv7VJs0o54Q1C96o3sOoH/QS6hi1y0XfON
	bs7DbzGu2IPxsiYN5OWjX9IMaABBImYT6YbOKYkd0TttKDsU0VMTCrUf+/3W60NLhWkXX+Cdld6
	KsiqqZ4UD+D4AAxyzKy8HpbzKAX8ac9JlpXhrX2p4Uka7/d23qtWeLq98bnKAKBgc6r9l0CmHqr
	aMa21wU4kbXpo/zErXliOwDmuM4LEV1D7HD5URV5oLY9i40gY26vizlZEQW6dvSyI0AzgPS2yTi
	V/YuhxoBWpaLi
X-Received: by 2002:a05:6820:162b:b0:71b:911f:ae01 with SMTP id 006d021491bc7-71b911fae90mr12653870eaf.55.1796075922896;
        Mon, 30 Nov 2026 13:58:42 -0800 (PST)
X-Received: from jtobler--20250820-SHC54.localdomain ([136.51.44.64])
        by smtp.gmail.com with ESMTPSA id 006d021491bc7-71b37c52ae6sm23479986eaf.0.2026.11.30.13.58.42
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 30 Nov 2026 13:58:42 -0800 (PST)
X-Cc: Justin Tobler <jltobler@gmail.com>
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <cover.1796075503.git.jltobler@gmail.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