]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fsck.c: refactor and rename common config callback
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 17 Mar 2021 18:20:36 +0000 (19:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Mar 2021 21:02:43 +0000 (14:02 -0700)
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>
builtin/fsck.c
builtin/mktag.c
fsck.c
fsck.h

index 821e7798c706dfa1b6f2ae61b7fb08a036280242..a56a2d0513a5cb5be75c7c25e707cfa343a465cb 100644 (file)
@@ -71,11 +71,6 @@ static const char *printable_type(const struct object_id *oid,
        return ret;
 }
 
-static int fsck_config(const char *var, const char *value, void *cb)
-{
-       return fsck_config_internal(var, value, cb, &fsck_obj_options);
-}
-
 static int objerror(struct object *obj, const char *err)
 {
        errors_found |= ERROR_OBJECT;
@@ -803,7 +798,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
        if (name_objects)
                fsck_enable_object_names(&fsck_walk_options);
 
-       git_config(fsck_config, NULL);
+       git_config(git_fsck_config, &fsck_obj_options);
 
        if (connectivity_only) {
                for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
index 41a399a69e4c08d3ab16274b7e8523e8a96ee3c6..23c4b8763fa18aeb1d92e4d71ce14c7186cc7a27 100644 (file)
@@ -14,11 +14,6 @@ static int option_strict = 1;
 
 static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
 
-static int mktag_config(const char *var, const char *value, void *cb)
-{
-       return fsck_config_internal(var, value, cb, &fsck_options);
-}
-
 static int mktag_fsck_error_func(struct fsck_options *o,
                                 const struct object_id *oid,
                                 enum object_type object_type,
@@ -93,7 +88,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
        fsck_options.error_func = mktag_fsck_error_func;
        fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn");
        /* config might set fsck.extraHeaderEntry=* again */
-       git_config(mktag_config, NULL);
+       git_config(git_fsck_config, &fsck_options);
        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/fsck.c b/fsck.c
index e3030f3b358045cfad4f4cdcc64d529677bda124..5dfb99665ae6ce5fbbdaf95b3ef46f7013ca654e 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -1323,9 +1323,9 @@ int fsck_finish(struct fsck_options *options)
        return ret;
 }
 
-int fsck_config_internal(const char *var, const char *value, void *cb,
-                        struct fsck_options *options)
+int git_fsck_config(const char *var, const char *value, void *cb)
 {
+       struct fsck_options *options = cb;
        if (strcmp(var, "fsck.skiplist") == 0) {
                const char *path;
                struct strbuf sb = STRBUF_INIT;
diff --git a/fsck.h b/fsck.h
index 733378f1260a89bcda654e1f6e2b5144e8d2ab3e..f70d11c5594d0489023a90676e5b187201c96347 100644 (file)
--- a/fsck.h
+++ b/fsck.h
@@ -109,7 +109,6 @@ const char *fsck_describe_object(struct fsck_options *options,
  * git_config() callback for use by fsck-y tools that want to support
  * fsck.<msg> fsck.skipList etc.
  */
-int fsck_config_internal(const char *var, const char *value, void *cb,
-                        struct fsck_options *options);
+int git_fsck_config(const char *var, const char *value, void *cb);
 
 #endif