mirror of
https://github.com/git/git.git
synced 2024-11-18 00:13:58 +01:00
builtin/apply: make parse_ignorewhitespace_option() return -1 instead of die()ing
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_ignorewhitespace_option() should return -1 instead of calling die(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
aaf6c447aa
commit
f95fdc256b
@ -57,20 +57,20 @@ static int parse_whitespace_option(struct apply_state *state, const char *option
|
|||||||
return error(_("unrecognized whitespace option '%s'"), option);
|
return error(_("unrecognized whitespace option '%s'"), option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_ignorewhitespace_option(struct apply_state *state,
|
static int parse_ignorewhitespace_option(struct apply_state *state,
|
||||||
const char *option)
|
const char *option)
|
||||||
{
|
{
|
||||||
if (!option || !strcmp(option, "no") ||
|
if (!option || !strcmp(option, "no") ||
|
||||||
!strcmp(option, "false") || !strcmp(option, "never") ||
|
!strcmp(option, "false") || !strcmp(option, "never") ||
|
||||||
!strcmp(option, "none")) {
|
!strcmp(option, "none")) {
|
||||||
state->ws_ignore_action = ignore_ws_none;
|
state->ws_ignore_action = ignore_ws_none;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(option, "change")) {
|
if (!strcmp(option, "change")) {
|
||||||
state->ws_ignore_action = ignore_ws_change;
|
state->ws_ignore_action = ignore_ws_change;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
die(_("unrecognized whitespace ignore option '%s'"), option);
|
return error(_("unrecognized whitespace ignore option '%s'"), option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_default_whitespace_mode(struct apply_state *state)
|
static void set_default_whitespace_mode(struct apply_state *state)
|
||||||
@ -4629,8 +4629,8 @@ static void init_apply_state(struct apply_state *state,
|
|||||||
git_apply_config();
|
git_apply_config();
|
||||||
if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace))
|
if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace))
|
||||||
exit(1);
|
exit(1);
|
||||||
if (apply_default_ignorewhitespace)
|
if (apply_default_ignorewhitespace && parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
|
||||||
parse_ignorewhitespace_option(state, apply_default_ignorewhitespace);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_apply_state(struct apply_state *state)
|
static void clear_apply_state(struct apply_state *state)
|
||||||
|
Loading…
Reference in New Issue
Block a user