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

[PATCH 03/14] fsck: refactor interface to parse fsck options

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 20, 2026, 11:47 UTC
Message-ID
<20260320-b4-pks-fsck-without-the-repository-v1-3-6594f997926b@pks.im>
In-Reply-To
<20260320-b4-pks-fsck-without-the-repository-v1-0-6594f997926b@pks.im>

The function `git_fsck_config()` is supposed to be used as a callback function for `repo_config()`. It expects the caller to provide a repository as callback payload, which is easy to miss. Furthermore, in the next commit we're about to refactor the function to not rely on global state anymore, which will require callers to pass a different payload.

Prepare for this change by refactoring the interface to be fully self-contained. Like this, callers know exactly which parameters are expected.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/fsck.c  |  2 +-
 builtin/mktag.c |  3 ++-
 builtin/refs.c  |  2 +-
 fsck.c          | 11 +++++++++--
 fsck.h          |  9 ++++-----
 5 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 8f994010da..fd689a1e14 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1023,7 +1023,7 @@ int cmd_fsck(int argc,
 	if (name_objects)
 		fsck_enable_object_names(&fsck_walk_options);
 
-	repo_config(the_repository, git_fsck_config, &fsck_obj_options);
+	fsck_options_parse_config(&fsck_obj_options, the_repository);
 	prepare_repo_settings(the_repository);
 
 	if (check_references)
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 7cf6e1230a..2cf843c195 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -98,7 +98,8 @@ int cmd_mktag(int argc,
 	fsck_set_msg_type_from_ids(&fsck_options, FSCK_MSG_EXTRA_HEADER_ENTRY,
 				   FSCK_WARN);
 	/* config might set fsck.extraHeaderEntry=* again */
-	repo_config(the_repository, git_fsck_config, &fsck_options);
+	fsck_options_parse_config(&fsck_options, the_repository);
+
 	if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options,
 				&tagged_oid, &tagged_type))
 		die(_("tag on stdin did not pass our strict fsck check"));
diff --git a/builtin/refs.c b/builtin/refs.c
index 3064f888b2..c0a3b475e9 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -97,7 +97,7 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix,
 	if (argc)
 		usage(_("'git refs verify' takes no arguments"));
 
-	repo_config(the_repository, git_fsck_config, &fsck_refs_options);
+	fsck_options_parse_config(&fsck_refs_options, the_repository);
 	prepare_repo_settings(the_repository);
 
 	worktrees = get_worktrees_without_reading_head();
diff --git a/fsck.c b/fsck.c
index 1f7d568acf..a7ebab9581 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1404,8 +1404,9 @@ void fsck_options_clear(struct fsck_options *options)
 	kh_clear_oid_map(options->object_names);
 }
 
-int git_fsck_config(const char *var, const char *value,
-		    const struct config_context *ctx, void *cb)
+static int fsck_options_parse_config_key(const char *var, const char *value,
+					 const struct config_context *ctx,
+					 void *cb)
 {
 	struct fsck_options *options = cb;
 	const char *msg_id;
@@ -1435,6 +1436,12 @@ int git_fsck_config(const char *var, const char *value,
 	return git_default_config(var, value, ctx, cb);
 }
 
+void fsck_options_parse_config(struct fsck_options *options,
+			       struct repository *repo)
+{
+	repo_config(repo, fsck_options_parse_config_key, options);
+}
+
 /*
  * Custom error callbacks that are used in more than one place.
  */
diff --git a/fsck.h b/fsck.h
index bfe9b3ffc9..7d0d876103 100644
--- a/fsck.h
+++ b/fsck.h
@@ -304,12 +304,11 @@ void fsck_put_object_name(struct fsck_options *options,
 const char *fsck_describe_object(struct fsck_options *options,
 				 const struct object_id *oid);
 
-struct key_value_info;
 /*
- * repo_config() callback for use by fsck-y tools that want to support
- * fsck.<msg> fsck.skipList etc.
+ * Parse fsck options from the gitconfig. This covers settings like for example
+ * fsck.<msg> fsck.skipList.
  */
-int git_fsck_config(const char *var, const char *value,
-		    const struct config_context *ctx, void *cb);
+void fsck_options_parse_config(struct fsck_options *options,
+			       struct repository *repo);
 
 #endif
-- 
2.53.0.1055.ga2ffed1127.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 6 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.