Skip to content

Commit b35b10d

Browse files
tanayabhgitster
authored andcommitted
builtin/apply.c: replace git_config() with git_config_get_string_const()
Use `git_config_get_string_const()` 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 0e7bcb1 commit b35b10d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

builtin/apply.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,13 +4269,11 @@ static int apply_patch(int fd, const char *filename, int options)
42694269
return 0;
42704270
}
42714271

4272-
static int git_apply_config(const char *var, const char *value, void *cb)
4272+
static void git_apply_config(void)
42734273
{
4274-
if (!strcmp(var, "apply.whitespace"))
4275-
return git_config_string(&apply_default_whitespace, var, value);
4276-
else if (!strcmp(var, "apply.ignorewhitespace"))
4277-
return git_config_string(&apply_default_ignorewhitespace, var, value);
4278-
return git_default_config(var, value, cb);
4274+
git_config_get_string_const("apply.whitespace", &apply_default_whitespace);
4275+
git_config_get_string_const("apply.ignorewhitespace", &apply_default_ignorewhitespace);
4276+
git_config(git_default_config, NULL);
42794277
}
42804278

42814279
static int option_parse_exclude(const struct option *opt,
@@ -4423,7 +4421,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
44234421

44244422
prefix = prefix_;
44254423
prefix_length = prefix ? strlen(prefix) : 0;
4426-
git_config(git_apply_config, NULL);
4424+
git_apply_config();
44274425
if (apply_default_whitespace)
44284426
parse_whitespace_option(apply_default_whitespace);
44294427
if (apply_default_ignorewhitespace)

0 commit comments

Comments
 (0)