From: Daniel Barkalow Date: Tue, 19 Feb 2008 07:40:31 +0000 (-0500) Subject: Fix format.headers not ending with a newline X-Git-Tag: v1.5.5-rc0~134^2~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7d22708b254d4ec28cd865dc5489d175ee6d65c2;p=git.git Fix format.headers not ending with a newline Now each value of format.headers will always be treated as a single valid header, and newlines will be inserted between them as needed. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- diff --git a/builtin-log.c b/builtin-log.c index 3dc765011..fe1a2d78e 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -425,10 +425,14 @@ static int git_format_config(const char *var, const char *value) if (!value) die("format.headers without value"); len = strlen(value); - extra_headers_size += len + 1; + while (value[len - 1] == '\n') + len--; + extra_headers_size += len + 2; extra_headers = xrealloc(extra_headers, extra_headers_size); - extra_headers[extra_headers_size - len - 1] = 0; + extra_headers[extra_headers_size - len - 2] = 0; strcat(extra_headers, value); + extra_headers[extra_headers_size - 2] = '\n'; + extra_headers[extra_headers_size - 1] = 0; return 0; } if (!strcmp(var, "format.suffix")) { diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 28ab7b9a5..755fe6dfa 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -101,7 +101,7 @@ test_expect_success 'extra headers' ' ' -test_expect_failure 'extra headers without newlines' ' +test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R. E. Cipient " && git config --add format.headers "Cc: S. E. Cipient " &&