]> git.ipfire.org Git - thirdparty/git.git/commitdiff
notes: avoid empty line in template
authorMichael J Gruber <git@grubix.eu>
Wed, 16 Nov 2022 15:56:40 +0000 (16:56 +0100)
committerTaylor Blau <me@ttaylorr.com>
Wed, 16 Nov 2022 19:57:32 +0000 (14:57 -0500)
When `git notes` prepares the template it adds an empty newline between
the comment header and the content:

>
> #
> # Write/edit the notes for the following object:
>
> # commit 0f3c55d4c2b7864bffb2d92278eff08d0b2e083f
> # etc

This is wrong structurally because that newline is part of the comment,
too, and thus should be commented. Also, it throws off some positioning
strategies of editors and plugins, and it differs from how we do commit
templates.

Change this to follow the standard set by `git commit`:

>
> #
> # Write/edit the notes for the following object:
> #
> # commit 0f3c55d4c2b7864bffb2d92278eff08d0b2e083f
>

Tests pass unchanged after this code change.

Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
builtin/notes.c

index be51f692257f67e2765feb6ff63e8037f3a4f00d..80d9dfd25cad2afcb90c0219894529bcc1558cac 100644 (file)
@@ -181,7 +181,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data *
                strbuf_addch(&buf, '\n');
                strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
                strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)));
-               strbuf_addch(&buf, '\n');
+               strbuf_add_commented_lines(&buf, "\n", strlen("\n"));
                write_or_die(fd, buf.buf, buf.len);
 
                write_commented_object(fd, object);