apply.c | 2 +- apply.h | 2 ++ builtin/am.c | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apply.c b/apply.c index 0912307bd9..28e6fe0cfa 100644 --- a/apply.c +++ b/apply.c @@ -36,7 +36,7 @@ static void git_apply_config(void) git_config(git_xmerge_config, NULL); } -static int parse_whitespace_option(struct apply_state *state, const char *option) +int parse_whitespace_option(struct apply_state *state, const char *option) { if (!option) { state->ws_error_action = warn_on_ws_error; diff --git a/apply.h b/apply.h index 4052da50c0..c931786a2a 100644 --- a/apply.h +++ b/apply.h @@ -173,6 +173,8 @@ int parse_git_diff_header(struct strbuf *root, unsigned int size, struct patch *patch); +int parse_whitespace_option(struct apply_state *state, const char *option); + /* * Some aspects of the apply behavior are controlled by the following * bits in the "options" parameter passed to apply_all_patches(). diff --git a/builtin/am.c b/builtin/am.c index 0f4111bafa..542c6c5cab 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2298,6 +2298,16 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar return 0; } +static int parse_opt_whitespace(const struct option *opt, const char *arg, int unset) +{ + struct apply_state dummy = { }; + + if (parse_whitespace_option(&dummy, arg)) + return -1; + + return parse_opt_passthru_argv(opt, arg, unset); +} + static int git_am_config(const char *k, const char *v, void *cb) { int status; @@ -2355,9 +2365,9 @@ int cmd_am(int argc, const char **argv, const char *prefix) OPT_CALLBACK_F(0, "quoted-cr", &state.quoted_cr, N_("action"), N_("pass it through git-mailinfo"), PARSE_OPT_NONEG, am_option_parse_quoted_cr), - OPT_PASSTHRU_ARGV(0, "whitespace", &state.git_apply_opts, N_("action"), + OPT_CALLBACK(0, "whitespace", &state.git_apply_opts, N_("action"), N_("pass it through git-apply"), - 0), + parse_opt_whitespace), OPT_PASSTHRU_ARGV(0, "ignore-space-change", &state.git_apply_opts, NULL, N_("pass it through git-apply"), PARSE_OPT_NOARG),