summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-09-10 17:02:51 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-09-10 17:02:51 +0900
commit00fd0afefd6b2a37497141d1d2a0d95210806406 (patch)
treed5ac5b39c0ae1852a91e06d78de5ef2a74380a6c /builtin
parentMerge branch 'rs/in-obsd-basename-dirname-take-const' into maint (diff)
parentam: fix signoff when other trailers are present (diff)
downloadtgif-00fd0afefd6b2a37497141d1d2a0d95210806406.tar.xz
Merge branch 'pw/am-signoff' into maint
"git am -s" has been taught that some input may end with a trailer block that is not Signed-off-by: and it should refrain from adding an extra blank line before adding a new sign-off in such a case. * pw/am-signoff: am: fix signoff when other trailers are present
Diffstat (limited to 'builtin')
-rw-r--r--builtin/am.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 6962d4db5f..73f542bec5 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1193,34 +1193,10 @@ static void NORETURN die_user_resolve(const struct am_state *state)
*/
static void am_append_signoff(struct am_state *state)
{
- char *cp;
- struct strbuf mine = STRBUF_INIT;
struct strbuf sb = STRBUF_INIT;
strbuf_attach(&sb, state->msg, state->msg_len, state->msg_len);
-
- /* our sign-off */
- strbuf_addf(&mine, "\n%s%s\n",
- sign_off_header,
- fmt_name(getenv("GIT_COMMITTER_NAME"),
- getenv("GIT_COMMITTER_EMAIL")));
-
- /* Does sb end with it already? */
- if (mine.len < sb.len &&
- !strcmp(mine.buf, sb.buf + sb.len - mine.len))
- goto exit; /* no need to duplicate */
-
- /* Does it have any Signed-off-by: in the text */
- for (cp = sb.buf;
- cp && *cp && (cp = strstr(cp, sign_off_header)) != NULL;
- cp = strchr(cp, '\n')) {
- if (sb.buf == cp || cp[-1] == '\n')
- break;
- }
-
- strbuf_addstr(&sb, mine.buf + !!cp);
-exit:
- strbuf_release(&mine);
+ append_signoff(&sb, 0, 0);
state->msg = strbuf_detach(&sb, &state->msg_len);
}