From: Junio C Hamano Date: Fri, 20 Mar 2026 23:13:29 GMT Subject: Re: [PATCH 13/14] fsck: provide repository in `struct fsck_report_object` Message-ID: In-Reply-To: <20260320-b4-pks-fsck-without-the-repository-v1-13-6594f997926b@pks.im> Patrick Steinhardt writes: > The `report()` function invokes a callback function with a `struct > fsck_report_object` for every object that failed at least one of our > checks. This report doesn't give the caller enough context though, and > thus they have to rely on global state for `the_repository`. > > Refactor the code and inject the repository into the report. > > As this requires us to touch up all callsites, rename the `report()` > function to `fsck_report_object()` to align it with `fsck_report_ref()`. > We have already discussed this rename in the past, but we decided to not > do it because it required us to adapt too many callsites. > > Signed-off-by: Patrick Steinhardt > --- > fsck.c | 365 ++++++++++++++++++++++++++++++++++++++--------------------------- > fsck.h | 1 + > 2 files changed, 214 insertions(+), 152 deletions(-) > > diff --git a/fsck.c b/fsck.c > index edf7a0618f..59b9163598 100644 > --- a/fsck.c > +++ b/fsck.c > @@ -258,13 +258,15 @@ static int fsck_vreport(struct fsck_options *options, > return result; > } > > -__attribute__((format (printf, 5, 6))) > -static int report(struct fsck_options *options, > - const struct object_id *oid, enum object_type object_type, > - enum fsck_msg_id msg_id, const char *fmt, ...) > +__attribute__((format (printf, 6, 7))) > +static int fsck_report_object(struct repository *repo, > + struct fsck_options *options, > + const struct object_id *oid, enum object_type object_type, > + enum fsck_msg_id msg_id, const char *fmt, ...) Earlier I wondered if struct repository *repo should be added to fsck_options; I didn't comment on individual patches, but almost all patches I saw since that remark made me suspect that fsck_options would be a good place to pass repository throughout the callchain even more.