Skip to content

Commit eb898b8

Browse files
pyokagangitster
authored andcommitted
builtin-am: implement -s/--signoff
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am supported the --signoff option which will append a signoff at the end of the commit messsage. Re-implement this feature in parse_mail() by calling append_signoff() if the option is set. Signed-off-by: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d83109 commit eb898b8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

builtin/am.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "diffcore.h"
1919
#include "unpack-trees.h"
2020
#include "branch.h"
21+
#include "sequencer.h"
2122

2223
/**
2324
* Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -83,6 +84,7 @@ struct am_state {
8384

8485
/* various operating modes and command line options */
8586
int quiet;
87+
int signoff;
8688
const char *resolvemsg;
8789
};
8890

@@ -353,6 +355,9 @@ static void am_load(struct am_state *state)
353355
read_state_file(&sb, state, "quiet", 1);
354356
state->quiet = !strcmp(sb.buf, "t");
355357

358+
read_state_file(&sb, state, "sign", 1);
359+
state->signoff = !strcmp(sb.buf, "t");
360+
356361
strbuf_release(&sb);
357362
}
358363

@@ -533,6 +538,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
533538

534539
write_file(am_path(state, "quiet"), 1, state->quiet ? "t" : "f");
535540

541+
write_file(am_path(state, "sign"), 1, state->signoff ? "t" : "f");
542+
536543
if (!get_sha1("HEAD", curr_head)) {
537544
write_file(am_path(state, "abort-safety"), 1, "%s", sha1_to_hex(curr_head));
538545
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)
734741
die_errno(_("could not read '%s'"), am_path(state, "msg"));
735742
stripspace(&msg, 0);
736743

744+
if (state->signoff)
745+
append_signoff(&msg, 0, 0);
746+
737747
assert(!state->author_name);
738748
state->author_name = strbuf_detach(&author_name, NULL);
739749

@@ -1150,6 +1160,8 @@ int cmd_am(int argc, const char **argv, const char *prefix)
11501160

11511161
struct option options[] = {
11521162
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")),
11531165
OPT_CALLBACK(0, "patch-format", &patch_format, N_("format"),
11541166
N_("format the patch(es) are in"),
11551167
parse_opt_patchformat),

0 commit comments

Comments
 (0)