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

Re: [PATCH 01/14] fsck: drop `the_repository` in `fsck_walk()`

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 23, 2026, 12:22 UTC
Message-ID
<acEwis6mGCaY4WtR@pks.im>
In-Reply-To
<xmqq341udrob.fsf@gitster.g>
On Fri, Mar 20, 2026 at 04:09:24PM -0700, Junio C Hamano wrote:
Show 36 quoted lines
> 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
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 4 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.