Skip to content

Commit fb79f5b

Browse files
avargitster
authored andcommitted
fsck.c: refactor and rename common config callback
Refactor code I recently changed in 1f3299f (fsck: make fsck_config() re-usable, 2021-01-05) so that I could use fsck's config callback in mktag in 1f3299f (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5828ae commit fb79f5b

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

builtin/fsck.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ static const char *printable_type(const struct object_id *oid,
7171
return ret;
7272
}
7373

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-
7974
static int objerror(struct object *obj, const char *err)
8075
{
8176
errors_found |= ERROR_OBJECT;
@@ -803,7 +798,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
803798
if (name_objects)
804799
fsck_enable_object_names(&fsck_walk_options);
805800

806-
git_config(fsck_config, NULL);
801+
git_config(git_fsck_config, &fsck_obj_options);
807802

808803
if (connectivity_only) {
809804
for_each_loose_object(mark_loose_for_connectivity, NULL, 0);

builtin/mktag.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ static int option_strict = 1;
1414

1515
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
1616

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-
2217
static int mktag_fsck_error_func(struct fsck_options *o,
2318
const struct object_id *oid,
2419
enum object_type object_type,
@@ -93,7 +88,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
9388
fsck_options.error_func = mktag_fsck_error_func;
9489
fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn");
9590
/* config might set fsck.extraHeaderEntry=* again */
96-
git_config(mktag_config, NULL);
91+
git_config(git_fsck_config, &fsck_options);
9792
if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options,
9893
&tagged_oid, &tagged_type))
9994
die(_("tag on stdin did not pass our strict fsck check"));

fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,9 +1323,9 @@ int fsck_finish(struct fsck_options *options)
13231323
return ret;
13241324
}
13251325

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)
13281327
{
1328+
struct fsck_options *options = cb;
13291329
if (strcmp(var, "fsck.skiplist") == 0) {
13301330
const char *path;
13311331
struct strbuf sb = STRBUF_INIT;

fsck.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const char *fsck_describe_object(struct fsck_options *options,
109109
* git_config() callback for use by fsck-y tools that want to support
110110
* fsck.<msg> fsck.skipList etc.
111111
*/
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);
114113

115114
#endif

0 commit comments

Comments
 (0)