Skip to content

Commit f95fdc2

Browse files
chriscoolgitster
authored andcommitted
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>
1 parent aaf6c44 commit f95fdc2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

builtin/apply.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ static int parse_whitespace_option(struct apply_state *state, const char *option
5757
return error(_("unrecognized whitespace option '%s'"), option);
5858
}
5959

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)
6262
{
6363
if (!option || !strcmp(option, "no") ||
6464
!strcmp(option, "false") || !strcmp(option, "never") ||
6565
!strcmp(option, "none")) {
6666
state->ws_ignore_action = ignore_ws_none;
67-
return;
67+
return 0;
6868
}
6969
if (!strcmp(option, "change")) {
7070
state->ws_ignore_action = ignore_ws_change;
71-
return;
71+
return 0;
7272
}
73-
die(_("unrecognized whitespace ignore option '%s'"), option);
73+
return error(_("unrecognized whitespace ignore option '%s'"), option);
7474
}
7575

7676
static void set_default_whitespace_mode(struct apply_state *state)
@@ -4629,8 +4629,8 @@ static void init_apply_state(struct apply_state *state,
46294629
git_apply_config();
46304630
if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace))
46314631
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);
46344634
}
46354635

46364636
static void clear_apply_state(struct apply_state *state)

0 commit comments

Comments
 (0)