diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2017-04-26 13:50:03 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-04-26 17:48:50 -0700 |
commit | 44dc738a39f2c4dba41c0ddacae280d0f88dc71f (patch) | |
tree | f68e4d005851dbeaee837137855fdeacc57dd6a8 /sequencer.c | |
parent | 967dfd4d568c2b102281de8cc22ee35f7558358b (diff) | |
download | git-44dc738a39f2c4dba41c0ddacae280d0f88dc71f.tar.gz |
sequencer: add newline before adding footersjt/use-trailer-api-in-commands
When encountering a commit message that does not end in a newline,
sequencer does not complete the line before determining if a blank line
should be added. This causes the "(cherry picked..." and sign-off lines
to sometimes appear on the same line as the last line of the commit
message.
This behavior was introduced by commit 967dfd4 ("sequencer: use
trailer's trailer layout", 2016-11-29). However, a revert of that commit
would not resolve this issue completely: prior to that commit, a
conforming footer was deemed to be non-conforming by
has_conforming_footer() if there was no terminating newline, resulting
in both conforming and non-conforming footers being treated the same
when they should not be.
Resolve this issue, both for conforming and non-conforming footers, and
in both do_pick_commit() and append_signoff(), by always adding a
newline to the commit message if it does not end in one before checking
the footer for conformity.
Reported-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sequencer.c b/sequencer.c index d64c97397b..5df080dada 100644 --- a/sequencer.c +++ b/sequencer.c @@ -698,6 +698,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, strbuf_addstr(&msgbuf, skip_blank_lines(p + 2)); if (opts->record_origin) { + strbuf_complete_line(&msgbuf); if (!has_conforming_footer(&msgbuf, NULL, 0)) strbuf_addch(&msgbuf, '\n'); strbuf_addstr(&msgbuf, cherry_picked_prefix); @@ -1362,6 +1363,9 @@ void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag) getenv("GIT_COMMITTER_EMAIL"))); strbuf_addch(&sob, '\n'); + if (!ignore_footer) + strbuf_complete_line(msgbuf); + /* * If the whole message buffer is equal to the sob, pretend that we * found a conforming footer with a matching sob @@ -1382,13 +1386,6 @@ void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag) * the title and body to be filled in by the user. */ append_newlines = "\n\n"; - } else if (msgbuf->buf[len - 1] != '\n') { - /* - * Incomplete line. Complete the line and add a - * blank one so that there is an empty line between - * the message body and the sob. - */ - append_newlines = "\n\n"; } else if (len == 1) { /* * Buffer contains a single newline. Add another |