Skip to content

Commit

Permalink
Fix format.headers not ending with a newline
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Barkalow authored and Junio C Hamano committed Feb 20, 2008
1 parent a8d8173 commit 7d22708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rcipient@example.com>" &&
git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>" &&
Expand Down

0 comments on commit 7d22708

Please sign in to comment.