🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #1235

[PATCH v2 01/13] loose: allow looking up in object map with source

#1235
From: Christian Couder
Date: Fri, 23 Oct 2026 07:25
93 lines
13626 bytes
From: "brian m. carlson" <sandals@crustytoothpaste.net>

In preparation for wiring up object mapping into the ODB abstraction,
add a function which can map object IDs based on a struct
odb_source_loose and use it in the existing function.  This preserves
the same behavior, but allows us to make use of it elsewhere in the
future.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Christian Couder <christian.couder@gmail.com>
---
 loose.c | 41 +++++++++++++++++++++++++++++------------
 loose.h |  5 +++++
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/loose.c b/loose.c
index d6a2bb5ba3..fe8f540979 100644
--- a/loose.c
+++ b/loose.c
@@ -225,27 +225,44 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,
 	return 0;
 }
 
+int source_loose_object_map_oid(struct odb_source_loose *loose,
+				const struct object_id *src,
+				const struct git_hash_algo *to,
+				struct object_id *dest)
+{
+	kh_oid_map_t *map;
+	khiter_t pos;
+	struct loose_object_map *loose_map = loose->map;
+	struct repository *repo = loose->base.odb->repo;
+
+	if (!loose_map)
+		return -1;
+	map = (to == repo->compat_hash_algo) ?
+		loose_map->to_compat :
+		loose_map->to_storage;
+	pos = kh_get_oid_map(map, *src);
+	if (pos < kh_end(map)) {
+		oidcpy(dest, kh_value(map, pos));
+		return 0;
+	}
+	return -1;
+}
+
 int repo_loose_object_map_oid(struct repository *repo,
 			      const struct object_id *src,
 			      const struct git_hash_algo *to,
 			      struct object_id *dest)
 {
 	struct odb_source_files *files = odb_source_files_downcast(repo->objects->source);
-	kh_oid_map_t *map;
-	khiter_t pos;
 
 	for (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) {
-		struct loose_object_map *loose_map = dir->loose->map;
-		if (!loose_map)
+		int ret;
+
+		if (!dir->loose)
 			continue;
-		map = (to == repo->compat_hash_algo) ?
-			loose_map->to_compat :
-			loose_map->to_storage;
-		pos = kh_get_oid_map(map, *src);
-		if (pos < kh_end(map)) {
-			oidcpy(dest, kh_value(map, pos));
-			return 0;
-		}
+		ret = source_loose_object_map_oid(dir->loose, src, to, dest);
+		if (ret != -1)
+			return ret;
 	}
 	return -1;
 }
diff --git a/loose.h b/loose.h
index ed663ac550..f3b1e47363 100644
--- a/loose.h
+++ b/loose.h
@@ -24,4 +24,9 @@ int repo_add_loose_object_map(struct odb_source_loose *loose,
 int repo_read_loose_object_map(struct repository *repo);
 int repo_write_loose_object_map(struct repository *repo);
 
+int source_loose_object_map_oid(struct odb_source_loose *loose,
+				const struct object_id *src,
+				const struct git_hash_algo *to,
+				struct object_id *dest);
+
 #endif
-- 
2.56.0.215.g47fdf2208c
Technical Details
Message-ID: <20261023072559.3204273-2-christian.couder@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72946-linux-kernel-git=dewy.ru
References: <20261023072559.3204273-1-christian.couder@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72946-linux-kernel-git=dewy.ru
From: christian.couder@gmail.com (Christian Couder)
Newsgroups: linux.kernel.git
Subject: [PATCH v2 01/13] loose: allow looking up in object map with source
Date: Fri, 23 Oct 2026 09:25:46 +0200
Organization: Usenet Network
Message-ID: <20261023072559.3204273-2-christian.couder@gmail.com>
References: <20261023072559.3204273-1-christian.couder@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="438002"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Zm21y9WRzfKC7KQYeVX5cKssE9A= sha256:73N6HMLCcxBgUo48h9nphugmBWZMtjSb4xD7QBPs2RE=
	sha1:ImCi+DbqqDEm4yxoA9M5LQg/Eok= sha256:AFrdAMjsLUv3vEsRGH0YGn/tEnyPc4weKhsofQWkHFY=
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 EFC8311141A; Fri, 23 Oct 2026 10:30:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 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.25,
	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 GLf3V1vLGv9r;
	Fri, 23 Oct 2026 10:30:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-72946-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 12E4711140E; Fri, 23 Oct 2026 10:30:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C795731428; Fri, 23 Oct 2026 07:26:21 +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=1792740379;
	b=lfeTvqnc4Vg0L6fg25yr0QbxjlpOhV3QxYiILWDLZPWJNx/kMkWDFxHmYXfodUnpeUJ3
	 +0NmInbNLeZgq9tgIEsbCEuUuVyCC+uMZKJP5a0q7B6gU18JQpfs1vc6J13q1Ldt2wdmm
	 THxL7o0dcrOZBNnYIbh46s+5/AO2x/VasAN2kC+3wWbJJXclDQWViVcPORll/o0ypqwfe
	 hQKopCFwTsVlHVVuerV376qQeN9uqJmpS5tKwOl9Pl6Pa2PsETE0g5V6W14Z/URdugT/O
	 rIcbevsuRnEG+IxIWYyY+adyKLMTpQGyMrQ/U9ulTTsA8Y11OUEhFTn4BoSe+s2zJwQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792740379;
	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=WRyHIc9hqkS84sZmub+2A+XBGc1Z506ni/G6R1OBz8c=;
	b=2NoKs6SvYk3PYzQvGFH6sTRPtz+xSuoLPVmuheo6IpEL/nXXw7HC8bx8cb+ffQjCCzdj
	 k0uL++LkTnULxBJtm+O+vtdEBzr/qbXvCPgYEyzVZRX49HS8wnErddkN88mcUadm2XWaA
	 Ri+X8z0pMr/VqVdgNIXbWeBAi8TCLIOM6rZA2WjBYVvzGXFizZyNdooJlqOH8wj0wkQvs
	 wNDqAUFZxhTf2IJI3EdeatsSS5giaQswulryvBkeIkSpmZB8umeKG6xtDh014UC9I3H0W
	 vZ0z93Os5WF81vsKxSnn1MB7E3aUi4eu2c8HbC6BrEn07gXapn+7h2Q6ZxYjHDZuABg==
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=20251104 header.b=psmmEd1e;
	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 BE986606A329;
	Fri, 23 Oct 2026 07:26:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=psmmEd1e
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792740378;
	b=gGxY74C5zBJTRp+un5y1ZxYS4stfkEOyaYuZCm6XnjYUzvmG3ez9J3GVwKB7CWsF47e/
	 /bJ6EDWq1QRxVDkzAtIchO45SeXf2CSxIo6iXqtIIFMx0s50ZLmRm0ZUc9wONY5Ny7yjd
	 L+rOhNcKKQxZkTE2FwD8LZ/tuyXQFgJMow1gYO9osJz8IoNFbomA6Jv4VbnEy1qFzJhsI
	 fX5j/j9d8PZ7oVvsdFCW0TNX7Uz7UkLnQWbE+uq181iuW4DkPWqkVgLgQuUwJNyUb762i
	 JDngoFRnkoaSqxSnIPswZNKgi3M8spLWvZvgLktO5MeLnuwc4uvyeAfbeVuzbq/FzDA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792740378;
	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=WRyHIc9hqkS84sZmub+2A+XBGc1Z506ni/G6R1OBz8c=;
	b=uTtMcXwjZiT9PVYBd/t4XXUX5Df9Yz/3zE79f0UGaihPJgVZTzSzUvw8SNuxLUdIezWm
	 jB1d2Y+TUcsZHOcOG7LAPdFNJldZ6xgQio4uW1QyC80OYMM6SAVdRhg8nOILmt3gHbic7
	 AneovPoEWYGdPR5kIO/weJCYCrKQ2PSBSi3QQJDLRVQOZFG9+uGdqlNmCuo3IZZntqSmL
	 Sik2aNPDqFQ9bTZrc6BaorI+54ydEN4DH+j3tvZBWL04VAlYnVIdkYEv4UJuFOuFWFbK1
	 G61qboipl3sgKYSebwcvV+7gm4iG0tub5Z4X3Vw3l0hI8UofGZK4S/Zvma8SyKOzVwg==
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=20251104 header.b=psmmEd1e;
	arc=none smtp.remote-ip=209.85.221.41
X-Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41])
	(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 8DAEB606A31B
	for <git@vger.kernel.org>; Fri, 23 Oct 2026 07:26:18 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8DAEB606A31B
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-wr1-f41.google.com with SMTP id ffacd0b85a97d-48e00eee27dso310929f8f.0
        for <git@vger.kernel.org>; Fri, 23 Oct 2026 00:26:18 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792740377; x=1793345177; 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=WRyHIc9hqkS84sZmub+2A+XBGc1Z506ni/G6R1OBz8c=;
        b=psmmEd1ePcxMVjwGEtvwpwD+psrbriKWPN6aeGCqwv8B5Y6qk7irsDBlGKAVU9d6wJ
         kkQBgVYUggffL73UeBjNfI8GO2ywUnY6UQkfg06j7nL3OHuz/NSJ4CIH5UWVogna2sN9
         PYBBTGl6nP6/TcfSesh6u8+OZYKwJvsqKgKFBV9XrEMbrCPrnm3REeMgrRefT34NJMBf
         fvx4lzoVDeFcKjNPApVRg7HLSU46kAxET7kR1jdwaLXS3F24te0sJVzE2abrJpqnO52O
         ofr0FTxzmiXGLTCMirkAsjcELboK9GpZsNB7/Vx3hIsTUr2tKLKd45YfNEorsNtbqpps
         tcnA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792740377; x=1793345177;
        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=WRyHIc9hqkS84sZmub+2A+XBGc1Z506ni/G6R1OBz8c=;
        b=Wgnzsu8Uk8PJQfgdQzmyrhWa2QBlwOayl7Ip3FyGgNwkM2a+j2nSLf2gFki2bZB7RJ
         U/BjsLH1g4LtCdTkbh96xp0Ujl15KZt77OliRySjX/DEeLl5wLy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ra30bBsDjH24//I2N7TkPA3wwUZxRKTSN94OAuHOkWNxxOqPQaIgg==
X-Received: by 2002:a05:6000:46dc:b0:48d:f7ef:721f with SMTP id ffacd0b85a97d-48e3859dd7amr1126825f8f.11.1792740376788;
        Fri, 23 Oct 2026 00:26:16 -0700 (PDT)
X-Received: from christian--20230123--2G7D3 ([62.35.114.108])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e38055da4sm3228024f8f.43.2026.10.23.00.26.15
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 23 Oct 2026 00:26:16 -0700 (PDT)
X-Cc: Junio C Hamano <gitster@pobox.com>,
	"brian m . carlson" <sandals@crustytoothpaste.net>,
	Patrick Steinhardt <ps@pks.im>,
	Elijah Newren <newren@gmail.com>,
	Jeff King <peff@peff.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Christian Couder <christian.couder@gmail.com>
X-Mailer: git-send-email 2.56.0.215.g47fdf2208c
X-In-Reply-To: <20261023072559.3204273-1-christian.couder@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