Re: [PATCH] notes: avoid empty line in template

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 16, 2022 at 04:56:40PM +0100, Michael J Gruber wrote:

> 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
> >

Yeah, this makes perfect sense.

> Tests pass unchanged after this code change.

I'm mildly surprised that there wasn't some test depending on this in a
stupid way. :) But grepping for "Write/edit" shows that nobody did (and
obviously the tests pass).

We could add a new test here, but it probably is trivial enough not to
worry about.

> diff --git a/builtin/notes.c b/builtin/notes.c
> index be51f69225..80d9dfd25c 100644
> --- a/builtin/notes.c
> +++ b/builtin/notes.c
> @@ -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"));

And the patch looks obviously good. The irony is the version two lines
above which does it correctly. ;)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux