path: root/builtin/log.c
diff options
authorJeff King <>2014-05-21 21:07:51 (GMT)
committerJunio C Hamano <>2014-05-21 21:27:48 (GMT)
commitc6076e2b4aaebd4a49b01255fe8c67405704aa72 (patch)
treef50fda65508a8183988f26dcdbe6f5d4e51de7c7 /builtin/log.c
parent8ced8e40ac07c1b13b2edbb459d37b9b2d7275d6 (diff)
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 <> Signed-off-by: Jeremiah Mahler <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/log.c')
1 files 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)