{"thread":{"id":"12193","subject":"[PATCH 2/4] Fix format.headers not ending with a newline","startedAt":"2008-02-19T07:40:31Z","lastAt":"2008-02-19T07:40:31Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"69240","messageId":"alpine.LNX.1.00.0802190239440.5816@iabervon.org","threadId":"12193","inReplyTo":null,"subject":"[PATCH 2/4] Fix format.headers not ending with a newline","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-19T07:40:31Z","receivedAt":"2008-02-19T07:40:31Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Now each value of format.headers will always be treated as a single\nvalid header, and newlines will be inserted between them as needed.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n builtin-log.c           |    8 ++++++--\n t/t4014-format-patch.sh |    2 +-\n 2 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex a67b463..73b6d53 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -425,10 +425,14 @@ static int git_format_config(const char *var, const char *value)\n \t\tif (!value)\n \t\t\tdie(\"format.headers without value\");\n \t\tlen = strlen(value);\n-\t\textra_headers_size += len + 1;\n+\t\twhile (value[len - 1] == '\\n')\n+\t\t\tlen--;\n+\t\textra_headers_size += len + 2;\n \t\textra_headers = xrealloc(extra_headers, extra_headers_size);\n-\t\textra_headers[extra_headers_size - len - 1] = 0;\n+\t\textra_headers[extra_headers_size - len - 2] = 0;\n \t\tstrcat(extra_headers, value);\n+\t\textra_headers[extra_headers_size - 2] = '\\n';\n+\t\textra_headers[extra_headers_size - 1] = 0;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"format.suffix\")) {\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 28ab7b9..755fe6d 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -101,7 +101,7 @@ test_expect_success 'extra headers' '\n \t\n '\n \n-test_expect_failure 'extra headers without newlines' '\n+test_expect_success 'extra headers without newlines' '\n \n \tgit config --replace-all format.headers \"To: R. E. Cipient <rcipient@example.com>\" &&\n \tgit config --add format.headers \"Cc: S. E. Cipient <scipient@example.com>\" &&\n-- \n1.5.4.1.192.g8ea3a\n"}]}