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 08/14] builtin/fsck: refactor to use `odb_for_each_object()`
Date: Thu, 22 Jan 2026 19:32:32 -0500 [thread overview]
Message-ID: <aXLBoFnqbnCcylCD@nand.local> (raw)
In-Reply-To: <20260121-pks-odb-for-each-object-v3-8-12c4dfd24227@pks.im>
On Wed, Jan 21, 2026 at 01:50:24PM +0100, Patrick Steinhardt wrote:
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> builtin/fsck.c | 57 ++++++++++++---------------------------------------------
> 1 file changed, 12 insertions(+), 45 deletions(-)
This patch was a really pleasant read. It's really great to see both
pairs of functions collapse into a single one that acts the same over
loose/packed objects as opposed to two functions which do the same thing
but need to have different signatures to be able to plug into the
iterators for loose vs. packed objects.
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 4979bc795e..96107695ae 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -218,15 +218,17 @@ static int mark_used(struct object *obj, enum object_type type UNUSED,
> return 0;
> }
>
> -static void mark_unreachable_referents(const struct object_id *oid)
> +static int mark_unreachable_referents(const struct object_id *oid,
> + struct object_info *io UNUSED,
s/io/oi/ ?
> + void *data UNUSED)
> {
The transformation here makes sense (and I think aloud through the
similar mark_object_for_connectivity() transformation below). One
thought that I had while reading, though, was how this function behaves
when it is passed the same object more than once, since you mention that
as a possibility in the commit which introduces odb_for_each_object().
I think that this is OK, since we already likely send the same object to
this function multiple times if, e.g., we freshened an object from the
cruft pack, in which case we'd see it both when iterating packed
objects as well as when iterating loose ones.
As far as I can tell, that's OK, but it might be nice to provide a brief
analysis of that in the commit message, just to be sure and to help
future readers.
> @@ -848,26 +831,12 @@ static void fsck_index(struct index_state *istate, const char *index_path,
> fsck_resolve_undo(istate, index_path);
> }
>
> -static void mark_object_for_connectivity(const struct object_id *oid)
> +static int mark_object_for_connectivity(const struct object_id *oid,
> + struct object_info *oi UNUSED,
> + void *cb_data UNUSED)
> {
> struct object *obj = lookup_unknown_object(the_repository, oid);
> obj->flags |= HAS_OBJ;
> -}
> -
> -static int mark_loose_for_connectivity(const struct object_id *oid,
> - const char *path UNUSED,
> - void *data UNUSED)
> -{
> - mark_object_for_connectivity(oid);
> - return 0;
> -}
> -
> -static int mark_packed_for_connectivity(const struct object_id *oid,
> - struct packed_git *pack UNUSED,
> - uint32_t pos UNUSED,
> - void *data UNUSED)
> -{
> - mark_object_for_connectivity(oid);
> return 0;
> }
This is really nice, and everything here makes sense. Both of the old
callback functions merely call mark_object_for_connectivity() but are
different in order to accommodate the different function signatures
required. The new function uses the common interface and does the exact
same thing. Looking great.
> @@ -1001,10 +970,8 @@ int cmd_fsck(int argc,
> fsck_refs(the_repository);
>
> if (connectivity_only) {
> - for_each_loose_object(the_repository->objects,
> - mark_loose_for_connectivity, NULL, 0);
> - for_each_packed_object(the_repository,
> - mark_packed_for_connectivity, NULL, 0);
> + odb_for_each_object(the_repository->objects, NULL,
> + mark_object_for_connectivity, NULL, 0);
Makes sense.
Thanks,
Taylor
next prev parent reply other threads:[~2026-01-23 0:32 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 [this message]
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
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=aXLBoFnqbnCcylCD@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