Skip to content

Commit

Permalink
builtin/apply.c: replace git_config() with `git_config_get_string_c…
Browse files Browse the repository at this point in the history
…onst()`

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 <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tanay Abhra authored and Junio C Hamano committed Aug 13, 2014
1 parent 0e7bcb1 commit b35b10d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -4269,13 +4269,11 @@ static int apply_patch(int fd, const char *filename, int options)
return 0;
}

static int git_apply_config(const char *var, const char *value, void *cb)
static void git_apply_config(void)
{
if (!strcmp(var, "apply.whitespace"))
return git_config_string(&apply_default_whitespace, var, value);
else if (!strcmp(var, "apply.ignorewhitespace"))
return git_config_string(&apply_default_ignorewhitespace, var, value);
return git_default_config(var, value, cb);
git_config_get_string_const("apply.whitespace", &apply_default_whitespace);
git_config_get_string_const("apply.ignorewhitespace", &apply_default_ignorewhitespace);
git_config(git_default_config, NULL);
}

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

prefix = prefix_;
prefix_length = prefix ? strlen(prefix) : 0;
git_config(git_apply_config, NULL);
git_apply_config();
if (apply_default_whitespace)
parse_whitespace_option(apply_default_whitespace);
if (apply_default_ignorewhitespace)
Expand Down

0 comments on commit b35b10d

Please sign in to comment.