Skip to content

Commit f44af51

Browse files
tanayabhgitster
authored andcommitted
fetchpack.c: replace git_config() with git_config_get_*() family
Use `git_config_get_*()` family instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow. Signed-off-by: Tanay Abhra <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 95790ff commit f44af51

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

fetch-pack.c

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -869,42 +869,23 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
869869
return ref;
870870
}
871871

872-
static int fetch_pack_config(const char *var, const char *value, void *cb)
872+
static void fetch_pack_config(void)
873873
{
874-
if (strcmp(var, "fetch.unpacklimit") == 0) {
875-
fetch_unpack_limit = git_config_int(var, value);
876-
return 0;
877-
}
878-
879-
if (strcmp(var, "transfer.unpacklimit") == 0) {
880-
transfer_unpack_limit = git_config_int(var, value);
881-
return 0;
882-
}
883-
884-
if (strcmp(var, "repack.usedeltabaseoffset") == 0) {
885-
prefer_ofs_delta = git_config_bool(var, value);
886-
return 0;
887-
}
888-
889-
if (!strcmp(var, "fetch.fsckobjects")) {
890-
fetch_fsck_objects = git_config_bool(var, value);
891-
return 0;
892-
}
893-
894-
if (!strcmp(var, "transfer.fsckobjects")) {
895-
transfer_fsck_objects = git_config_bool(var, value);
896-
return 0;
897-
}
874+
git_config_get_int("fetch.unpacklimit", &fetch_unpack_limit);
875+
git_config_get_int("transfer.unpacklimit", &transfer_unpack_limit);
876+
git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta);
877+
git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects);
878+
git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
898879

899-
return git_default_config(var, value, cb);
880+
git_config(git_default_config, NULL);
900881
}
901882

902883
static void fetch_pack_setup(void)
903884
{
904885
static int did_setup;
905886
if (did_setup)
906887
return;
907-
git_config(fetch_pack_config, NULL);
888+
fetch_pack_config();
908889
if (0 <= transfer_unpack_limit)
909890
unpack_limit = transfer_unpack_limit;
910891
else if (0 <= fetch_unpack_limit)

0 commit comments

Comments
 (0)