aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/interpret-trailers.c
diff options
context:
space:
mode:
authorBrian Lyles <brianmlyles@gmail.com>2024-09-06 09:50:08 -0500
committerJunio C Hamano <gitster@pobox.com>2024-09-06 09:21:44 -0700
commitc02414a99796487a2124e4dbb17c3a88c8606404 (patch)
tree83af73811fe72f1a9b0f0df1a875319a5096a31b /builtin/interpret-trailers.c
parent39bf06adf96da25b87c9aa7d35a32ef3683eb4a4 (diff)
downloadgit-c02414a99796487a2124e4dbb17c3a88c8606404.tar.gz
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>
Diffstat (limited to 'builtin/interpret-trailers.c')
-rw-r--r--builtin/interpret-trailers.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
index 1d969494cf..e6f22459f1 100644
--- a/builtin/interpret-trailers.c
+++ b/builtin/interpret-trailers.c
@@ -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,