diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-08-22 20:29:07 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-22 20:29:07 +0300 |
commit | 5c3895dfbd24a5ea23a8899ac40730359a6b2613 (patch) | |
tree | e3f3a7813ee6e63eafe9f320de8eb288c230f180 /builtin | |
parent | 5498d6961efdd32665b012d48a7fb8d1554c1643 (diff) | |
parent | 735285b403ee2b09c03d31f2dc8cc95a2d471ead (diff) |
Merge branch 'pw/am-signoff'
"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.c | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/builtin/am.c b/builtin/am.c index ff0869d46f3..81095dae029 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); } |