Browse Source

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 <tanayabh@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Tanay Abhra 11 years ago committed by Junio C Hamano
parent
commit
b35b10d463
  1. 12
      builtin/apply.c

12
builtin/apply.c

@ -4269,13 +4269,11 @@ static int apply_patch(int fd, const char *filename, int options) @@ -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,
@ -4423,7 +4421,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_) @@ -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)

Loading…
Cancel
Save