public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 01/14] fsck: drop `the_repository` in `fsck_walk()`
Date: Mon, 23 Mar 2026 13:22:34 +0100	[thread overview]
Message-ID: <acEwis6mGCaY4WtR@pks.im> (raw)
In-Reply-To: <xmqq341udrob.fsf@gitster.g>

On Fri, Mar 20, 2026 at 04:09:24PM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > The function `fsck_walk()` and its object type specific functions
> > `fsck_walk_tree()` et al implicitly rely on `the_repository`. Remove
> > this dependency by injecting the repository as a parameter instead.
> >
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> >  builtin/fsck.c           |  6 +++---
> >  builtin/index-pack.c     |  2 +-
> >  builtin/unpack-objects.c |  2 +-
> >  fsck.c                   | 40 ++++++++++++++++++++++++++--------------
> >  fsck.h                   | 15 ++++++++++++---
> >  5 files changed, 43 insertions(+), 22 deletions(-)
> 
> OK.
> 
> While the conversion is cleanly done, the resulting code makes me
> wonder if fsck_options struct
> 
>         struct fsck_options {
>                 fsck_walk_func walk;
>                 fsck_error error_func;
>                 unsigned strict;
>                 unsigned verbose;
>                 enum fsck_msg_type *msg_type;
>                 struct oidset skip_oids;
>                 struct oidset gitmodules_found;
>                 struct oidset gitmodules_done;
>                 struct oidset gitattributes_found;
>                 struct oidset gitattributes_done;
>                 kh_oid_map_t *object_names;
>         };
> 
> should gain a repository pointer.  After all, these oidset and oidmap
> are about objects in one particular repository.

That's fair, and indeed this was my first attempt at solving the
dependency on `the_repository`. The reason why I discarded that approach
though is the way that we currenlty initialize `struct fsck_options` via
a set of macros. And as we often do this in file-static scope we don't
have a repository available there.

I had a second look at this though and have now introduced a new
function to initialize the options instead. It's a tiny bit ugly, and
ideally we'd just not have the options in global scope in the first
place. But I guess that overall it's okayish.

Will update and send the revised version soonish.

Thanks!

Patrick

  reply	other threads:[~2026-03-23 12:22 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 11:47 [PATCH 00/14] fsck: drop use of `the_repository` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 01/14] fsck: drop `the_repository` in `fsck_walk()` Patrick Steinhardt
2026-03-20 23:09   ` Junio C Hamano
2026-03-23 12:22     ` Patrick Steinhardt [this message]
2026-03-20 11:47 ` [PATCH 02/14] fsck: drop `the_repository` in `fsck_finish()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 03/14] fsck: refactor interface to parse fsck options Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 04/14] fsck: drop `the_repository` in `fsck_set_msg_types()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 05/14] fsck: stop relying on global state via `parse_oid_hex()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 06/14] builtin/fsck: fix trivial dependence on `the_repository` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 07/14] builtin/fsck: stop using `the_repository` when snapshotting refs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 08/14] builtin/fsck: stop using `the_repository` when checking refs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 09/14] builtin/fsck: stop using `the_repository` when checking reflogs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 10/14] builtin/fsck: stop using `the_repository` with loose objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 11/14] builtin/fsck: stop using `the_repository` when checking packed objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 12/14] builtin/fsck: stop using `the_repository` when marking objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 13/14] fsck: provide repository in `struct fsck_report_object` Patrick Steinhardt
2026-03-20 23:13   ` Junio C Hamano
2026-03-20 11:47 ` [PATCH 14/14] builtin/fsck: stop using `the_repository` in error reporting Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 00/12] fsck: drop use of `the_repository` Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 01/12] fetch-pack: move fsck options into function scope Patrick Steinhardt
2026-03-23 15:43     ` Junio C Hamano
2026-03-23 15:02   ` [PATCH v2 02/12] fsck: initialize fsck options via a function Patrick Steinhardt
2026-03-23 15:48     ` Junio C Hamano
2026-03-23 15:02   ` [PATCH v2 03/12] fsck: store repository in fsck options Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 04/12] fsck: drop USE_THE_REPOSITORY Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 05/12] builtin/fsck: fix trivial dependence on `the_repository` Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 06/12] builtin/fsck: stop using `the_repository` when snapshotting refs Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 07/12] builtin/fsck: stop using `the_repository` when checking refs Patrick Steinhardt
2026-03-23 15:02   ` [PATCH v2 08/12] builtin/fsck: stop using `the_repository` when checking reflogs Patrick Steinhardt
2026-03-23 15:03   ` [PATCH v2 09/12] builtin/fsck: stop using `the_repository` with loose objects Patrick Steinhardt
2026-03-23 15:03   ` [PATCH v2 10/12] builtin/fsck: stop using `the_repository` when checking packed objects Patrick Steinhardt
2026-03-23 15:03   ` [PATCH v2 11/12] builtin/fsck: stop using `the_repository` when marking objects Patrick Steinhardt
2026-03-23 15:03   ` [PATCH v2 12/12] builtin/fsck: stop using `the_repository` in error reporting Patrick Steinhardt

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=acEwis6mGCaY4WtR@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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