Skip to content

Commit 702cbaa

Browse files
pyokagangitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f1b696 commit 702cbaa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

builtin/am.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct am_state {
9898
int signoff;
9999
int utf8;
100100
int keep; /* enum keep_type */
101+
int message_id;
101102
const char *resolvemsg;
102103
int rebasing;
103104
};
@@ -116,6 +117,8 @@ static void am_state_init(struct am_state *state, const char *dir)
116117
state->prec = 4;
117118

118119
state->utf8 = 1;
120+
121+
git_config_get_bool("am.messageid", &state->message_id);
119122
}
120123

121124
/**
@@ -388,6 +391,9 @@ static void am_load(struct am_state *state)
388391
else
389392
state->keep = KEEP_FALSE;
390393

394+
read_state_file(&sb, state, "messageid", 1);
395+
state->message_id = !strcmp(sb.buf, "t");
396+
391397
state->rebasing = !!file_exists(am_path(state, "rebasing"));
392398

393399
strbuf_release(&sb);
@@ -596,6 +602,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
596602

597603
write_file(am_path(state, "keep"), 1, "%s", str);
598604

605+
write_file(am_path(state, "messageid"), 1, state->message_id ? "t" : "f");
606+
599607
if (state->rebasing)
600608
write_file(am_path(state, "rebasing"), 1, "%s", "");
601609
else
@@ -777,6 +785,9 @@ static int parse_mail(struct am_state *state, const char *mail)
777785
die("BUG: invalid value for state->keep");
778786
}
779787

788+
if (state->message_id)
789+
argv_array_push(&cp.args, "-m");
790+
780791
argv_array_push(&cp.args, am_path(state, "msg"));
781792
argv_array_push(&cp.args, am_path(state, "patch"));
782793

@@ -1521,6 +1532,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
15211532
N_("pass -k flag to git-mailinfo"), KEEP_TRUE),
15221533
OPT_SET_INT(0, "keep-non-patch", &state.keep,
15231534
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")),
15241537
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
15251538
N_("format the patch(es) are in"),
15261539
parse_opt_patchformat),

0 commit comments

Comments
 (0)