git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 13/14] fsck: provide repository in `struct fsck_report_object`

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2026, 23:13 UTC
Message-ID
<xmqqy0jmccx2.fsf@gitster.g>
In-Reply-To
<20260320-b4-pks-fsck-without-the-repository-v1-13-6594f997926b@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 35 quoted lines
> 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 <ps@pks.im>
> ---
>  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.

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 17 of 18 in “fsck: drop use of `the_repository`”
  1. 00/14 fsck: drop use of `the_repository`Patrick Steinhardt, Mar 20, 2026
  2. 01/14 fsck: drop `the_repository` in `fsck_walk()`Patrick Steinhardt, Mar 20, 2026
  3. Junio C HamanoMar 20, 2026
  4. Patrick SteinhardtMar 23, 2026
  5. 02/14 fsck: drop `the_repository` in `fsck_finish()`Patrick Steinhardt, Mar 20, 2026
  6. 03/14 fsck: refactor interface to parse fsck optionsPatrick Steinhardt, Mar 20, 2026
  7. 04/14 fsck: drop `the_repository` in `fsck_set_msg_types()`Patrick Steinhardt, Mar 20, 2026
  8. 05/14 fsck: stop relying on global state via `parse_oid_hex()`Patrick Steinhardt, Mar 20, 2026
  9. 06/14 builtin/fsck: fix trivial dependence on `the_repository`Patrick Steinhardt, Mar 20, 2026
  10. 07/14 builtin/fsck: stop using `the_repository` when snapshotting refsPatrick Steinhardt, Mar 20, 2026
  11. 08/14 builtin/fsck: stop using `the_repository` when checking refsPatrick Steinhardt, Mar 20, 2026
  12. 09/14 builtin/fsck: stop using `the_repository` when checking reflogsPatrick Steinhardt, Mar 20, 2026
  13. 10/14 builtin/fsck: stop using `the_repository` with loose objectsPatrick Steinhardt, Mar 20, 2026
  14. 11/14 builtin/fsck: stop using `the_repository` when checking packed objectsPatrick Steinhardt, Mar 20, 2026
  15. 12/14 builtin/fsck: stop using `the_repository` when marking objectsPatrick Steinhardt, Mar 20, 2026
  16. 13/14 fsck: provide repository in `struct fsck_report_object`Patrick Steinhardt, Mar 20, 2026
  17. Junio C HamanoMar 20, 2026
  18. 14/14 builtin/fsck: stop using `the_repository` in error reportingPatrick Steinhardt, Mar 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.