interpret-trailers: handle message without trailing newline
When git-interpret-trailers is used to add a trailer to a message that does not end in a trailing newline, the new trailer is added on the line immediately following the message instead of as a trailer block separated from the message by a blank line. For example, if a message's text was exactly "The subject" with no trailing newline present, `git interpret-trailers --trailer my-trailer=true` will result in the following malformed commit message: The subject my-trailer: true While it is generally expected that a commit message should end with a newline character, git-interpret-trailers should not be returning an invalid message in this case. Use `strbuf_complete_line` to ensure that the message ends with a newline character when reading the input. Signed-off-by: Brian Lyles <brianmlyles@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
39bf06adf9
commit
c02414a997
@ -132,6 +132,7 @@ static void read_input_file(struct strbuf *sb, const char *file)
|
||||
if (strbuf_read(sb, fileno(stdin), 0) < 0)
|
||||
die_errno(_("could not read from stdin"));
|
||||
}
|
||||
strbuf_complete_line(sb);
|
||||
}
|
||||
|
||||
static void interpret_trailers(const struct process_trailer_options *opts,
|
||||
|
Reference in New Issue
Block a user