Skip to content

Commit

Permalink
format-patch: make newline after signature conditional
Browse files Browse the repository at this point in the history
When we print an email signature, we print the divider
"-- \n", then the signature string, then two newlines.

Usually 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 multi-line signature, like this:

  git format-patch --signature='this is my long signature

  it has multiple lines
  ' ...

and it may end with its own newline, in which case we do not have
to add yet another one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 21, 2014
1 parent 8ced8e4 commit c6076e2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c6076e2

Please sign in to comment.