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 <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Daniel Barkalow committed
Feb 19, 2008 at 02:40 UTC
7d22708b254d4ec28cd865dc5489d175ee6d65c2
2 files changed
+7
-3
builtin-log.c
+6
-2
@@ -425,10 +425,14 @@ static int git_format_config(const char *var, const char *value)
425
if (!value)
426
die("format.headers without value");
427
len = strlen(value);
428
- extra_headers_size += len + 1;
428
+ while (value[len - 1] == '\n')
429
+ len--;
430
+ extra_headers_size += len + 2;
431
extra_headers = xrealloc(extra_headers, extra_headers_size);
430
- extra_headers[extra_headers_size - len - 1] = 0;
432
+ extra_headers[extra_headers_size - len - 2] = 0;
433
strcat(extra_headers, value);
434
+ extra_headers[extra_headers_size - 2] = '\n';
435
+ extra_headers[extra_headers_size - 1] = 0;
436
return 0;
437
}
438
if (!strcmp(var, "format.suffix")) {
t/t4014-format-patch.sh
+1
-1
@@ -101,7 +101,7 @@ test_expect_success 'extra headers' '
101
102
'
103
104
-test_expect_failure 'extra headers without newlines' '
104
+test_expect_success 'extra headers without newlines' '
105
106
git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" &&
107
git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>" &&