builtin-am: implement --[no-]message-id, am.messageid
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Paul Tan committed
Aug 4, 2015 at 21:51 UTC
702cbaad61a15b035fd022bae57403baeb324d82
1 file changed
+13
builtin/am.c
+13
@@ -98,6 +98,7 @@ struct am_state {
98
int signoff;
99
int utf8;
100
int keep; /* enum keep_type */
101
+ int message_id;
102
const char *resolvemsg;
103
int rebasing;
104
};
@@ -116,6 +117,8 @@ static void am_state_init(struct am_state *state, const char *dir)
117
state->prec = 4;
118
119
state->utf8 = 1;
120
+
121
+ git_config_get_bool("am.messageid", &state->message_id);
122
}
123
124
/**
@@ -388,6 +391,9 @@ static void am_load(struct am_state *state)
391
else
392
state->keep = KEEP_FALSE;
393
394
+ read_state_file(&sb, state, "messageid", 1);
395
+ state->message_id = !strcmp(sb.buf, "t");
396
+
397
state->rebasing = !!file_exists(am_path(state, "rebasing"));
398
399
strbuf_release(&sb);
@@ -596,6 +602,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
602
603
write_file(am_path(state, "keep"), 1, "%s", str);
604
605
+ write_file(am_path(state, "messageid"), 1, state->message_id ? "t" : "f");
606
+
607
if (state->rebasing)
608
write_file(am_path(state, "rebasing"), 1, "%s", "");
609
else
@@ -777,6 +785,9 @@ static int parse_mail(struct am_state *state, const char *mail)
785
die("BUG: invalid value for state->keep");
786
}
787
788
+ if (state->message_id)
789
+ argv_array_push(&cp.args, "-m");
790
+
791
argv_array_push(&cp.args, am_path(state, "msg"));
792
argv_array_push(&cp.args, am_path(state, "patch"));
793
@@ -1521,6 +1532,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
1532
N_("pass -k flag to git-mailinfo"), KEEP_TRUE),
1533
OPT_SET_INT(0, "keep-non-patch", &state.keep,
1534
N_("pass -b flag to git-mailinfo"), KEEP_NON_PATCH),
1535
+ OPT_BOOL('m', "message-id", &state.message_id,
1536
+ N_("pass -m flag to git-mailinfo")),
1537
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
1538
N_("format the patch(es) are in"),
1539
parse_opt_patchformat),