From: Taylor Blau <me@ttaylorr.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>,
Justin Tobler <jltobler@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 10/14] treewide: drop uses of `for_each_{loose,packed}_object()`
Date: Thu, 22 Jan 2026 19:46:04 -0500 [thread overview]
Message-ID: <aXLEzAnNRTf5A6bt@nand.local> (raw)
In-Reply-To: <20260121-pks-odb-for-each-object-v3-10-12c4dfd24227@pks.im>
On Wed, Jan 21, 2026 at 01:50:26PM +0100, Patrick Steinhardt wrote:
> We're using `for_each_loose_object()` and `for_each_packed_object()` at
> a couple of callsites to enumerate all loose and packed objects,
> respectively. These functions will be removed in a subsequent commit in
> favor of the newly introduced `odb_source_loose_for_each_object()` and
> `packfile_store_for_each_object()` replacements.
>
> Prepare for this by refactoring the sites accordingly.
>
> Note that ideally, we'd convert all callsites to use the generic
> `odb_for_each_object()` function already. But for some callers this is
> not possible (yet), and it would require some significant refactorings
> to make this work. Converting these site will thus be deferred to a
> later patch series.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> builtin/cat-file.c | 28 ++++++++++++++++++++++------
> commit-graph.c | 44 +++++++++++++++++++++++++++++++-------------
> 2 files changed, 53 insertions(+), 19 deletions(-)
>
> diff --git a/builtin/cat-file.c b/builtin/cat-file.c
> index 6964a5a52c..7d16fbc1b8 100644
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -806,11 +806,14 @@ struct for_each_object_payload {
> void *payload;
> };
>
> -static int batch_one_object_loose(const struct object_id *oid,
> - const char *path UNUSED,
> - void *_payload)
> +static int batch_one_object_oi(const struct object_id *oid,
> + struct object_info *oi,
> + void *_payload)
> {
> struct for_each_object_payload *payload = _payload;
> + if (oi && oi->whence == OI_PACKED)
> + return payload->callback(oid, oi->u.packed.pack, oi->u.packed.offset,
Ah, here's a good argument for having the API provide the caller with
the object_info response it requested. Obviously the packfile_store
knows which packfile it's looking at, so asking the caller to
re-discover the same information is wasteful.
That said, I'm still a little leery of the way we're passing that
information around for the same reasons as I shared earlier in the
thread, but I definitely can see the motivation.
> @@ -846,8 +849,15 @@ static void batch_each_object(struct batch_options *opt,
> .payload = _payload,
> };
> struct bitmap_index *bitmap = prepare_bitmap_git(the_repository);
> + struct odb_source *source;
>
> - for_each_loose_object(the_repository->objects, batch_one_object_loose, &payload, 0);
> + odb_prepare_alternates(the_repository->objects);
> + for (source = the_repository->objects->sources; source; source = source->next) {
> + int ret = odb_source_loose_for_each_object(source, NULL, batch_one_object_oi,
> + &payload, flags);
> + if (ret)
> + break;
> + }
OK, I'm guessing that this is one such case where we can't yet use
odb_for_each_object() function directly because of the refactoring which
you alluded to in the commit message. That seems reasonable, though I
wonder if it's worth adding a /* TODO */ comment here to that effect.
Just out of curiosity, what does that refactoring entail? I'm curious
because I wonder whether the caller is just written in such a way that
it makes it hard to immediately plug into the new API, or whether there
are more fundamental issues at play that make the refactoring less than
straightforward. If the latter, those could potentially help inform the
direction here.
(To be clear, I figure that this is likely work that you have already
done, I'm just curious to see if the details would yield any benefit to
the immediate patch series under discussion.)
> diff --git a/commit-graph.c b/commit-graph.c
> index 7f1145a082..a3087d7883 100644
> --- a/commit-graph.c
> +++ b/commit-graph.c
The conversion here all looks great to me.
Thanks,
Taylor
next prev parent reply other threads:[~2026-01-23 0:46 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:04 [PATCH 00/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-15 18:00 ` Justin Tobler
2026-01-15 11:04 ` [PATCH 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-15 18:31 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-20 9:09 ` Karthik Nayak
2026-01-15 11:04 ` [PATCH 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-15 20:54 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-20 9:16 ` Karthik Nayak
2026-01-15 11:04 ` [PATCH 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-15 21:17 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 17:46 ` Justin Tobler
2026-01-19 7:10 ` Patrick Steinhardt
2026-01-20 9:20 ` Karthik Nayak
2026-01-21 7:39 ` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-15 21:24 ` Justin Tobler
2026-01-15 11:04 ` [PATCH 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-15 21:44 ` Justin Tobler
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 17:47 ` Justin Tobler
2026-01-19 7:10 ` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-15 11:04 ` [PATCH 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-15 13:50 ` [PATCH 00/14] odb: introduce `odb_for_each_object()` Junio C Hamano
2026-01-16 7:03 ` Patrick Steinhardt
2026-01-16 16:49 ` Junio C Hamano
2026-01-20 15:25 ` [PATCH v2 " Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-20 15:25 ` [PATCH v2 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-20 15:26 ` [PATCH v2 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 00/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-21 21:11 ` Jeff King
2026-01-22 0:00 ` Taylor Blau
2026-01-22 15:41 ` Junio C Hamano
2026-01-22 19:23 ` Jeff King
2026-01-23 10:57 ` Patrick Steinhardt
2026-01-26 22:32 ` Junio C Hamano
2026-01-22 6:50 ` Patrick Steinhardt
2026-01-22 23:44 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-22 0:04 ` Taylor Blau
2026-01-22 6:51 ` Patrick Steinhardt
2026-01-22 23:47 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-22 0:15 ` Taylor Blau
2026-01-22 6:52 ` Patrick Steinhardt
2026-01-23 0:01 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-22 1:37 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-23 0:06 ` Taylor Blau
2026-01-23 9:42 ` Patrick Steinhardt
2026-01-23 9:52 ` Chris Torek
2026-01-23 16:22 ` Junio C Hamano
2026-01-23 17:45 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:13 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:32 ` Taylor Blau
2026-01-23 9:42 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-23 0:33 ` Taylor Blau
2026-01-21 12:50 ` [PATCH v3 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-23 0:46 ` Taylor Blau [this message]
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-23 1:06 ` Taylor Blau
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-23 17:48 ` Taylor Blau
2026-01-26 8:53 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-23 1:21 ` Taylor Blau
2026-01-23 9:43 ` Patrick Steinhardt
2026-01-23 18:35 ` Taylor Blau
2026-01-26 8:53 ` Patrick Steinhardt
2026-01-29 11:08 ` Jeff King
2026-01-30 12:57 ` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-21 12:50 ` [PATCH v3 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-01-22 1:33 ` [PATCH v3 00/14] odb: introduce `odb_for_each_object()` Taylor Blau
2026-01-22 17:02 ` Junio C Hamano
2026-01-26 9:51 ` [PATCH v4 " Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 01/14] odb: rename `FOR_EACH_OBJECT_*` flags Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 02/14] odb: fix flags parameter to be unsigned Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 03/14] object-file: extract function to read object info from path Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 04/14] object-file: introduce function to iterate through objects Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 05/14] packfile: extract function to iterate through objects of a store Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 06/14] packfile: introduce function to iterate through objects Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 07/14] odb: introduce `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 08/14] builtin/fsck: refactor to use `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 09/14] treewide: enumerate promisor objects via `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 10/14] treewide: drop uses of `for_each_{loose,packed}_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 11/14] odb: introduce mtime fields for object info requests Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 12/14] builtin/pack-objects: use `packfile_store_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 13/14] reachable: convert to use `odb_for_each_object()` Patrick Steinhardt
2026-01-26 9:51 ` [PATCH v4 14/14] odb: drop unused `for_each_{loose,packed}_object()` functions Patrick Steinhardt
2026-02-20 22:59 ` [PATCH v4 00/14] odb: introduce `odb_for_each_object()` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aXLEzAnNRTf5A6bt@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox