🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2835

Re: [PATCH 3/6] object-file: move iteration over loose files into backend

#2835
From: Kaartic Sivaraam
Date: Tue, 10 Nov 2026 13:57
97 lines
14189 bytes
On 11/2/26 16:50, Patrick Steinhardt wrote:
> The logic to iterate over files part of the "loose" backend is contained
> in "object-file.c" even though it's an implementation detail of the
> backend itself. Move the logic into the backend accordingly.
> 
> Note that the function is a bit on the weird side: it accepts a generic
> `struct odb_source` as input and doesn't cast it down to its backend at
> all. This is because all it requires access to is the `path` member of
> the source, and from thereon it knows how to iterate the subdirectories
> of the "loose" backend.
> 
> We should adapt this function to accept `struct odb_source_loose` to
> properly reflect that it expects a path to a loose object database. But
> that would require changes to a bunch of callers without much benefit.
> So for now, the function signature is left as-is. But eventually we may
> want to change it once we have reworked a couple of its callers.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>   builtin/count-objects.c |  1 +
>   builtin/gc.c            |  1 +
>   builtin/prune.c         |  1 +
>   object-file.c           | 92 -------------------------------------------------
>   object-file.h           | 44 -----------------------
>   odb/source-loose.c      | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
>   odb/source-loose.h      | 33 ++++++++++++++++++
>   prune-packed.c          |  1 +
>   8 files changed, 129 insertions(+), 136 deletions(-)
> 
> diff --git a/builtin/count-objects.c b/builtin/count-objects.c
> index 3f7b20fde53..aae040567e3 100644
> --- a/builtin/count-objects.c
> +++ b/builtin/count-objects.c
> @@ -14,6 +14,7 @@
>   #include "quote.h"
>   #include "packfile.h"
>   #include "object-file.h"
> +#include "odb/source-loose.h"
>   

It seems like we can remove the include of object-file.h while at it.
>   static unsigned long garbage;
>   static off_t size_garbage;
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 81cecf6b6c3..d3ba6f0c9e9 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -31,6 +31,7 @@
>   #include "packfile.h"
>   #include "object-file.h"
>   #include "odb.h"
> +#include "odb/source-loose.h"
>   #include "path.h"
>   #include "reflog.h"
>   #include "rerere.h"
> diff --git a/builtin/prune.c b/builtin/prune.c
> index 97f4c1418bc..af2a547d931 100644
> --- a/builtin/prune.c
> +++ b/builtin/prune.c
> @@ -17,6 +17,7 @@
>   #include "object-file.h"
>   #include "object-name.h"
>   #include "odb.h"
> +#include "odb/source-loose.h"
>   #include "shallow.h"
>   

Ditto for the above two.

>   
> +static int for_each_file_in_obj_subdir(unsigned int subdir_nr,
> +				       struct strbuf *path,
> +				       const struct git_hash_algo *algop,
> +				       each_loose_object_fn obj_cb,
> +				       each_loose_cruft_fn cruft_cb,
> +				       each_loose_subdir_fn subdir_cb,
> +				       void *data)

This was made 'static' during the move but that seems to make sense to me.

> diff --git a/prune-packed.c b/prune-packed.c
> index b6749b8d132..d0a8a062b97 100644
> --- a/prune-packed.c
> +++ b/prune-packed.c
> @@ -3,6 +3,7 @@
>   #include "git-compat-util.h"
>   #include "gettext.h"
>   #include "object-file.h"
> +#include "odb/source-loose.h"

This could also benefit from losing the include of object-file.h

Rest of the patch looks good to me.

-- 
Sivaraam
Technical Details
Message-ID: <79a2222b-2087-460f-b4c8-c24c3b7c087c@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75073-linux-kernel-git=dewy.ru
References: <20261102-pks-odb-loose-cleanups-v1-0-fbbc86c29693@pks.im> <20261102-pks-odb-loose-cleanups-v1-3-fbbc86c29693@pks.im>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75073-linux-kernel-git=dewy.ru
From: kaartic.sivaraam@gmail.com (Kaartic Sivaraam)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 3/6] object-file: move iteration over loose files into
 backend
Date: Tue, 10 Nov 2026 19:27:58 +0530
Organization: Usenet Network
Message-ID: <79a2222b-2087-460f-b4c8-c24c3b7c087c@gmail.com>
References: <20261102-pks-odb-loose-cleanups-v1-0-fbbc86c29693@pks.im>
 <20261102-pks-odb-loose-cleanups-v1-3-fbbc86c29693@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="623939"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:zEjNsdD6yPJm1KsVsQuEoMUpDe8= sha256:MB7DN124V3K7cdA+FCKZAXJWZG7aI6Pn6zgwIXq8R0w=
	sha1:9YdNfDjDf/gI6syocu2syFzVNHI= sha256:Wf7rC53IdXjx+wc8x1LOqxZO1FmwZGGWodTlwfDdPLI=
Content-Language: en-US
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 9C6C5113BC3; Tue, 10 Nov 2026 17:13:51 +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 QpgcxCh6ssol;
	Tue, 10 Nov 2026 17:13:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-75073-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 DEE02113B79; Tue, 10 Nov 2026 17:13:39 +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 4C911126DFE; Tue, 10 Nov 2026 13:58:09 +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=1794319085;
	b=kaJpvTTDF+ldrNCTvyWb9IpcGfPG7QGXBzwtgZVoo6+Tun5JfS1ZhaeHVW96bkuru2sm
	 UqpvXN+KosyWZZIYp98t9E6Ea6VnaW9ajEP8pTzQmvv90b6rE0ipr8bM0n4Dy7GZF+1to
	 f/TFXTn+kqV2bi//rJN7Dj+d6yWz9eVCnZovPrv24A5yfj6E2WLktUT4XwFxxPVcBo3FF
	 l1/Qqe8OYqPic1P2D6EznFam4zJEpl7zNXs/+K9srRbHU2AVt9fdT7G5oPj2zs7jY3GdR
	 Wdp+Ism/6Pyszw7wqnttZA2q0xq40+8qxU0T26eCTvtSoMZgnlfI29dtECNuh9YTeUQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794319085;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 User-Agent:Subject:To:References:Content-Language:Cc:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=tQBPKAYUA7wYHXTtFxuOAWqmB7lHQ3Y/QebKzjtCgMs=;
	b=WHv+G8bmitm7n0BaA+Ms17GbPviwjEiRrUjx7lf3Pbv2vVqnce7h5M+rt26X6iGc7KtV
	 HadJv1OiX+xENkHYqMjGhqZqu8o5/j6qHjPtBfTWMp9HdzPh060NMeLe7knXl4BK7+VPG
	 XusCEahGJXbNEnLZTjKM7Jc/yfEvYw88DagWfC5Sn1UpB3uq6zdINTfeIEpNWfLsRTI5x
	 aahayrrTkBq+ppIUU/P9N9baa0TRbVGtvaHCX5MbdYu6GMNq8TCagfoBKFWG/FjqIRi5G
	 WY928ilgU7KQ0L+RIyJr8bOJPdmr33OWOEa/WNDyYDUAXvNx9Z6FA3meSdD9ly7OYEw==
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=JTmiYDgL;
	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 DFF4C606A32E;
	Tue, 10 Nov 2026 13:58: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=JTmiYDgL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794319084;
	b=fuBdrQ/GKHJvE6EBUDCjuyzrnxgSF+fiJQGeFFtU5yPd7x25CG+a6scwmW+meGX1atR3
	 cDhbaDO8TgTQPJs6b4Uod7EjSj8KhUqa187SFG8jiX61PDJSh3c3v/9A881bRJ4Or/KZF
	 W06LD96YbkHs3hvOoq97hIz3T3cmw87v95ESqjcKdIR0AgMDp80UxGIhtItSyEkSJ0fNF
	 tEcS1wMKrNrq0oK9MTZezEEyJhpSoN9YqVP5dNoLLwKyYR1EDi7TqfYY5AuP5znFb6MBK
	 WBBrewyc5hZYKYxmrKrczKT28q58k8CK0KyUi/1uhPdCQqtR8ebpuCv4QKFdoxR0NeA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794319084;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
	 MIME-Version:User-Agent:Subject:To:References:Content-Language:Cc:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=tQBPKAYUA7wYHXTtFxuOAWqmB7lHQ3Y/QebKzjtCgMs=;
	b=tVeioKE7ejugp5nGShmCZf5mutnBDmudwEiquAAcdU2h/f02o16iq/KrLwnmEbem3hG2
	 pwUEvzsX1s1MZ0O4H2wlY20UiCByt4dFunWdbyWhQTDbX15S+F0lHfCOfh3dLC9ELv/wr
	 zfN4d3wTjB4l9pl5TkOFZm2cGCtsM9MrwCdtkL90tO9vnJzU9sy/xPnq74Kl4lxYvM3mj
	 yXgNOa2mQf7gQFJzSA++5ME5t9wNLjCM5aU+Mpy7ecgu4q0mSDumgWGgbP3M0VDGo11+f
	 TfOy0gcYa892HDh93CXD2cZYUPyKyIsg0sGrkH564T0v8mZTKEwG/eCanLrJ+MF8MXw==
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=JTmiYDgL;
	arc=none smtp.remote-ip=74.125.82.179
X-Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179])
	(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 AFCF4606A336
	for <git@vger.kernel.org>; Tue, 10 Nov 2026 13:58:03 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AFCF4606A336
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-dy1-f179.google.com with SMTP id 5a478bee46e88-37628596783so233975eec.1
        for <git@vger.kernel.org>; Tue, 10 Nov 2026 05:58:03 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794319083; x=1794923883; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from:cc
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=tQBPKAYUA7wYHXTtFxuOAWqmB7lHQ3Y/QebKzjtCgMs=;
        b=JTmiYDgLqqN4+yM+81lE+qpwzFUqDvpFuHT+Y/n8O8Vzjvj7Z+238tc7eER2euFtCV
         JX99ol3WriyCsy0cX/TB+ztpBewe9rMknYDVPhisnZ8LImUG+yEmb3tl4z902xabnZWU
         +aDMeqoDsngo7fel93WgL3EI++mH21K5g6VcT683qpHNkrfKWNhM4r42J75CEPIQwN8a
         CYXs4m5760MVOWkeG7TncItTvFBl9oaOo063rg2MYuda2pTPyY64fD/P+xTYpGPiMwgH
         RfgtJdSkP4jizJH5n9l41HGycfasHhCpgFvgoqIM+6rbBtXe8cRy5QOa02rQsyhzOPVz
         lb0Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794319083; x=1794923883;
        h=content-transfer-encoding:content-type:in-reply-to:from:cc
         :content-language:references:to:subject:user-agent:mime-version:date
         :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=tQBPKAYUA7wYHXTtFxuOAWqmB7lHQ3Y/QebKzjtCgMs=;
        b=d4OncnKj93a8COaVKzY+HANifRBTWl6iAt+zu5YVpiv3Y6cX944K2gpb1Q9EQwra53
         1H+8Sq7vgBC2Qs/izSxkRhJh28/IKG5iWH4dqmAGq77lJEbVsfK5fzwedIsT14izE7bv
         3KvocJpUf/OuNyqdPduGJ5PeTdsfX2X5ruAPUbyUK40hq+M6E7BnlLRaVCA1HMsPt+zF
         foWDh5qX/B4Xg7dRr32RqJWIvMoNOVWwLzwimewBmp0eURaZhXHYtD+3PDZFtZW+wlEc
         jJDYiLgJuEUEIGQFKuxWOxWzywjm7MzELerEWBVKP1BanYnZDQfAXjtRRsWnKzeVFFaT
         yxfQ==
X-Gm-Message-State: APuU4Z/9B7Kl2Aj0/9fle5Db5BeSv0g1NvB49kwDVLqNjVPHSzAlF5zk
	F6lWpiqM8YmAxeGJFWnNLelSHX4HDbUx3PkcbmWrq/4LuqKJZnsbCZF+rumZg7wH
X-Gm-Gg: AYBFou3iJdASpxtp4xL8o1UeAWKqaajTGAILNk9DbWwiZ88PckTCfI6MjBuVEduoSzf
	4y9Txbr+AL4Jtz+2PZhOhlc1xFna64efy97k0gMBXZKAhrdx+KQJFSWHst7kPbidQQld2r+2I2R
	61MJwyqw532x+VY65wHL5duzi5y8jv8CsTMIuUk/eXWR00dRWb0R1Q8hDJR+sB16Qw6y3pn6JU0
	/dhWBg2KEvhWd1Vi9S929p5pd577X4FQLcMKWFFQ5guv4HIhfw15wKIsckr4tY9JMZiQV03weYF
	xEX0pNRSo5lnM565fc156VVV9SZ6Snw9Pxil0TIqMnM5z7eFTHEdijozzmSHMwGDvOoc8Yz5PWe
	FDGZjcPO27fHFBMcdhxo29/K+Cb7BaMlm6qMXylEGIIHSy3GGmgZPf5AUWSGCj1kp+pDsgZRTVJ
	wUnYCpq5kUSVIdQHwz1NXcD4gmiqRZTeL/7CyNd6PennZmICGKMdoFQABUCCKO/y+nXWQQje0gR
	I7Zw/b6i4ivJPy9ApXT/tvS/ghmEFsGxoxnEbdkoIUzS6+Kwf7XEir7BqoimaHF4WrNWvOsJUMH
	RlMt4Y3RFXxf08GI22xt3XJ0tAf5Ik0P4dtzIVBmXLpJ
X-Received: by 2002:a05:7022:2208:b0:184:992:c9ec with SMTP id a92af1059eb24-1b3b6195445mr5013167c88.38.1794319081612;
        Tue, 10 Nov 2026 05:58:01 -0800 (PST)
X-Received: from [192.168.25.219] ([115.108.41.154])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b3b5b2fc09sm16073358c88.10.2026.11.10.05.58.00
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 10 Nov 2026 05:58:01 -0800 (PST)
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-User-Agent: Mozilla Thunderbird
X-Cc: git@vger.kernel.org
X-In-Reply-To: <20261102-pks-odb-loose-cleanups-v1-3-fbbc86c29693@pks.im>