fsck.c: refactor and rename common config callback

Refactor code I recently changed in 1f3299fda9 (fsck: make fsck_config() re-usable, 2021-01-05) so that I could use fsck's config callback in mktag in 1f3299fda9 (fsck: make fsck_config() re-usable, 2021-01-05). I don't know what I was thinking in structuring the code this way, but it clearly makes no sense to have an fsck_config_internal() at all just so it can get a fsck_options when git_config() already supports passing along some void* data. Let's just make use of that instead, which gets us rid of the two wrapper functions, and brings fsck's common config callback in line with other such reusable config callbacks. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 17, 2021 at 19:20 UTC fb79f5bff7f47f41cf3697ecc28bfaa888016ce0
4 files changed +5 -16
builtin/fsck.c
+1 -6
@@ -71,11 +71,6 @@ static const char *printable_type(const struct object_id *oid,
71 return ret;
72 }
73
74 -static int fsck_config(const char *var, const char *value, void *cb)
75 -{
76 - return fsck_config_internal(var, value, cb, &fsck_obj_options);
77 -}
78 -
74 static int objerror(struct object *obj, const char *err)
75 {
76 errors_found |= ERROR_OBJECT;
@@ -803,7 +798,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
798 if (name_objects)
799 fsck_enable_object_names(&fsck_walk_options);
800
806 - git_config(fsck_config, NULL);
801 + git_config(git_fsck_config, &fsck_obj_options);
802
803 if (connectivity_only) {
804 for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
builtin/mktag.c
+1 -6
@@ -14,11 +14,6 @@ static int option_strict = 1;
14
15 static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
16
17 -static int mktag_config(const char *var, const char *value, void *cb)
18 -{
19 - return fsck_config_internal(var, value, cb, &fsck_options);
20 -}
21 -
17 static int mktag_fsck_error_func(struct fsck_options *o,
18 const struct object_id *oid,
19 enum object_type object_type,
@@ -93,7 +88,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
88 fsck_options.error_func = mktag_fsck_error_func;
89 fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn");
90 /* config might set fsck.extraHeaderEntry=* again */
96 - git_config(mktag_config, NULL);
91 + git_config(git_fsck_config, &fsck_options);
92 if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options,
93 &tagged_oid, &tagged_type))
94 die(_("tag on stdin did not pass our strict fsck check"));
fsck.c
+2 -2
@@ -1323,9 +1323,9 @@ int fsck_finish(struct fsck_options *options)
1323 return ret;
1324 }
1325
1326 -int fsck_config_internal(const char *var, const char *value, void *cb,
1327 - struct fsck_options *options)
1326 +int git_fsck_config(const char *var, const char *value, void *cb)
1327 {
1328 + struct fsck_options *options = cb;
1329 if (strcmp(var, "fsck.skiplist") == 0) {
1330 const char *path;
1331 struct strbuf sb = STRBUF_INIT;
fsck.h
+1 -2
@@ -109,7 +109,6 @@ const char *fsck_describe_object(struct fsck_options *options,
109 * git_config() callback for use by fsck-y tools that want to support
110 * fsck.<msg> fsck.skipList etc.
111 */
112 -int fsck_config_internal(const char *var, const char *value, void *cb,
113 - struct fsck_options *options);
112 +int git_fsck_config(const char *var, const char *value, void *cb);
113
114 #endif