[PATCH v4 25/44] builtin-am: implement --[no-]message-id, am.messageid
- From
Paul Tan <pyokagan@gmail.com>
- Date
- Jun 28, 2015, 14:05 UTC
- Message-ID
- <1435500366-31700-26-git-send-email-pyokagan@gmail.com>
- In-Reply-To
- <1435500366-31700-1-git-send-email-pyokagan@gmail.com>
Since a078f73 (git-am: add --message-id/--no-message-id, 2014-11-25), git-am.sh supported the --[no-]message-id options, and the "am.messageid" setting which specifies the default option.
--[no-]message-id tells git-am whether or not the -m option should be passed to git-mailinfo.
Re-implement this option in builtin/am.c.
Signed-off-by: Paul Tan <pyokagan@gmail.com> ---
Notes:
No test for am.messageidbuiltin/am.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/builtin/am.c b/builtin/am.c index 3410601..52e5b5a 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -103,6 +103,9 @@ struct am_state { /* one of the enum keep_type values */ int keep; + /* pass -m flag to git-mailinfo */ + int message_id; + /* override error message when patch failure occurs */ const char *resolvemsg; @@ -131,6 +134,8 @@ static void am_state_init(struct am_state *state, const char *dir) state->quiet = 1; state->utf8 = 1; + + git_config_get_bool("am.messageid", &state->message_id); } /** @@ -420,6 +425,9 @@ static void am_load(struct am_state *state) else state->keep = KEEP_FALSE; + read_state_file(&sb, state, "messageid", 1); + state->message_id = !strcmp(sb.buf, "t"); + state->rebasing = !!file_exists(am_path(state, "rebasing")); strbuf_release(&sb); @@ -628,6 +636,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, write_file(am_path(state, "keep"), 1, "%s", str); + write_file(am_path(state, "messageid"), 1, state->message_id ? "t" : "f"); + if (state->rebasing) write_file(am_path(state, "rebasing"), 1, "%s", ""); else @@ -814,6 +824,9 @@ static int parse_mail(struct am_state *state, const char *mail) die("BUG: invalid value for state->keep"); } + if (state->message_id) + argv_array_push(&cp.args, "-m"); + argv_array_push(&cp.args, am_path(state, "msg")); argv_array_push(&cp.args, am_path(state, "patch")); @@ -1534,6 +1547,8 @@ int cmd_am(int argc, const char **argv, const char *prefix) N_("pass -k flag to git-mailinfo"), KEEP_TRUE), OPT_SET_INT(0, "keep-non-patch", &state.keep, N_("pass -b flag to git-mailinfo"), KEEP_NON_PATCH), + OPT_BOOL('m', "message-id", &state.message_id, + N_("pass -m flag to git-mailinfo")), OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"), N_("format the patch(es) are in"), parse_opt_patchformat),
-- 2.5.0.rc0.76.gb2c6e93