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>
Christian Couder committed
Aug 8, 2016 at 23:03 UTC
f95fdc256b4732e6363823daa707ea6058e6db8e
1 file changed
+7
-7
builtin/apply.c
+7
-7
@@ -57,20 +57,20 @@ static int parse_whitespace_option(struct apply_state *state, const char *option
57
return error(_("unrecognized whitespace option '%s'"), option);
58
}
59
60
-static void parse_ignorewhitespace_option(struct apply_state *state,
61
- const char *option)
60
+static int parse_ignorewhitespace_option(struct apply_state *state,
61
+ const char *option)
62
{
63
if (!option || !strcmp(option, "no") ||
64
!strcmp(option, "false") || !strcmp(option, "never") ||
65
!strcmp(option, "none")) {
66
state->ws_ignore_action = ignore_ws_none;
67
- return;
67
+ return 0;
68
}
69
if (!strcmp(option, "change")) {
70
state->ws_ignore_action = ignore_ws_change;
71
- return;
71
+ return 0;
72
}
73
- die(_("unrecognized whitespace ignore option '%s'"), option);
73
+ return error(_("unrecognized whitespace ignore option '%s'"), option);
74
}
75
76
static void set_default_whitespace_mode(struct apply_state *state)
@@ -4629,8 +4629,8 @@ static void init_apply_state(struct apply_state *state,
4629
git_apply_config();
4630
if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace))
4631
exit(1);
4632
- if (apply_default_ignorewhitespace)
4633
- parse_ignorewhitespace_option(state, apply_default_ignorewhitespace);
4632
+ if (apply_default_ignorewhitespace && parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
4633
+ exit(1);
4634
}
4635
4636
static void clear_apply_state(struct apply_state *state)