format-patch: do not wrap non-rfc2047 headers too early

Do not wrap the second and later lines of non-rfc2047-encoded headers
substantially before the 78 character limit.

Instead of passing the remaining length of the first line as wrapping
width, use the correct maximum length and tell strbuf_add_wrapped_bytes()
how many characters of the first line are already used.

Signed-off-by: Jan H. Schönherr <schnhrr@cs.tu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jan H. Schönherr
2012-10-18 16:43:29 +02:00
committed by Junio C Hamano
parent 14e1a4e1ff
commit 7a76e68a17
2 changed files with 35 additions and 27 deletions

View File

@ -286,7 +286,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, int len,
if ((i + 1 < len) && (ch == '=' && line[i+1] == '?'))
goto needquote;
}
strbuf_add_wrapped_bytes(sb, line, len, 0, 1, max_length - line_len);
strbuf_add_wrapped_bytes(sb, line, len, -line_len, 1, max_length);
return;
needquote: