format-patch: make newline after signature conditional
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>
Jeff King committed
May 21, 2014 at 14:07 UTC
c6076e2b4aaebd4a49b01255fe8c67405704aa72
1 file changed
+7
-2
builtin/log.c
+7
-2
@@ -844,8 +844,13 @@ static void gen_message_id(struct rev_info *info, char *base)
844
845
static void print_signature(void)
846
{
847
- if (signature && *signature)
848
- printf("-- \n%s\n\n", signature);
847
+ if (!signature || !*signature)
848
+ return;
849
+
850
+ printf("-- \n%s", signature);
851
+ if (signature[strlen(signature)-1] != '\n')
852
+ putchar('\n');
853
+ putchar('\n');
854
}
855
856
static void add_branch_description(struct strbuf *buf, const char *branch_name)