git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v7 1/2] format-patch: make newline after signature conditional

From
Junio C Hamano <gitster@pobox.com>
Date
May 21, 2014, 21:22 UTC
Message-ID
<xmqq1tvmq129.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1400706472-13471-2-git-send-email-jmmahler@gmail.com>
Jeremiah Mahler <jmmahler@gmail.com> writes:
Show 18 quoted lines
> From: Jeff King <peff@peff.net>
>
> When we print an email signature, we print the divider "--
> \n", then the signature string, then two newlines.
> Traditionally the signature is a one-liner (and the default
> is just the git version), so the extra newline makes sense.
>
> But one could easily specify a longer, multi-line signature,
> like:
>
>   git format-patch --signature='
>   this is my long signature
>
>   it has multiple lines
>   ' ...
>
> We should notice that it already has its own trailing
> newline, and suppress one of ours.

That is a half-good example; the first line being a blank is misleading, as we are not doing anything about that, though.

Other than that, the patch looks OK to me. If anybody complains we can fix it later to do more cleansing.

Show 26 quoted lines
> Signed-off-by: Jeff King <peff@peff.net>
> Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
> ---
>  builtin/log.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index 39e8836..5acc048 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -844,8 +844,13 @@ static void gen_message_id(struct rev_info *info, char *base)
>  
>  static void print_signature(void)
>  {
> -	if (signature && *signature)
> -		printf("-- \n%s\n\n", signature);
> +	if (!signature || !*signature)
> +		return;
> +
> +	printf("-- \n%s", signature);
> +	if (signature[strlen(signature)-1] != '\n')
> +		putchar('\n');
> +	putchar('\n');
>  }
>  
>  static void add_branch_description(struct strbuf *buf, const char *branch_name)
Previous: Jeremiah MahlerNext: Jeremiah Mahler
Message 3 of 5 in “format-patch --signature-file <file>”
  1. 0/2 format-patch --signature-file <file>Jeremiah Mahler, May 21, 2014
  2. 1/2 format-patch: make newline after signature conditionalJeremiah Mahler, May 21, 2014
  3. Junio C HamanoMay 21, 2014
  4. 2/2 format-patch --signature-file <file>Jeremiah Mahler, May 21, 2014
  5. Junio C HamanoMay 21, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.