|
18 | 18 | #include "diffcore.h" |
19 | 19 | #include "unpack-trees.h" |
20 | 20 | #include "branch.h" |
| 21 | +#include "sequencer.h" |
21 | 22 |
|
22 | 23 | /** |
23 | 24 | * Returns 1 if the file is empty or does not exist, 0 otherwise. |
@@ -83,6 +84,7 @@ struct am_state { |
83 | 84 |
|
84 | 85 | /* various operating modes and command line options */ |
85 | 86 | int quiet; |
| 87 | + int signoff; |
86 | 88 | const char *resolvemsg; |
87 | 89 | }; |
88 | 90 |
|
@@ -353,6 +355,9 @@ static void am_load(struct am_state *state) |
353 | 355 | read_state_file(&sb, state, "quiet", 1); |
354 | 356 | state->quiet = !strcmp(sb.buf, "t"); |
355 | 357 |
|
| 358 | + read_state_file(&sb, state, "sign", 1); |
| 359 | + state->signoff = !strcmp(sb.buf, "t"); |
| 360 | + |
356 | 361 | strbuf_release(&sb); |
357 | 362 | } |
358 | 363 |
|
@@ -533,6 +538,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, |
533 | 538 |
|
534 | 539 | write_file(am_path(state, "quiet"), 1, state->quiet ? "t" : "f"); |
535 | 540 |
|
| 541 | + write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f"); |
| 542 | + |
536 | 543 | if (!get_sha1("HEAD", curr_head)) { |
537 | 544 | write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(curr_head)); |
538 | 545 | update_ref("am", "ORIG_HEAD", curr_head, NULL, 0, UPDATE_REFS_DIE_ON_ERR); |
@@ -734,6 +741,9 @@ static int parse_mail(struct am_state *state, const char *mail) |
734 | 741 | die_errno(_("could not read '%s'"), am_path(state, "msg")); |
735 | 742 | stripspace(&msg, 0); |
736 | 743 |
|
| 744 | + if (state->signoff) |
| 745 | + append_signoff(&msg, 0, 0); |
| 746 | + |
737 | 747 | assert(!state->author_name); |
738 | 748 | state->author_name = strbuf_detach(&author_name, NULL); |
739 | 749 |
|
@@ -1150,6 +1160,8 @@ int cmd_am(int argc, const char **argv, const char *prefix) |
1150 | 1160 |
|
1151 | 1161 | struct option options[] = { |
1152 | 1162 | OPT__QUIET(&state.quiet, N_("be quiet")), |
| 1163 | + OPT_BOOL('s', "signoff", &state.signoff, |
| 1164 | + N_("add a Signed-off-by line to the commit message")), |
1153 | 1165 | OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"), |
1154 | 1166 | N_("format the patch(es) are in"), |
1155 | 1167 | parse_opt_patchformat), |
|
0 commit comments