Merge branch 'jk/format-patch-multiline-header'
* jk/format-patch-multiline-header: format-patch: wrap email addresses after long names
This commit is contained in:
commit
5ead6a6fdb
9
pretty.c
9
pretty.c
@ -287,6 +287,7 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
|
|||||||
if (fmt == CMIT_FMT_EMAIL) {
|
if (fmt == CMIT_FMT_EMAIL) {
|
||||||
char *name_tail = strchr(line, '<');
|
char *name_tail = strchr(line, '<');
|
||||||
int display_name_length;
|
int display_name_length;
|
||||||
|
int final_line;
|
||||||
if (!name_tail)
|
if (!name_tail)
|
||||||
return;
|
return;
|
||||||
while (line < name_tail && isspace(name_tail[-1]))
|
while (line < name_tail && isspace(name_tail[-1]))
|
||||||
@ -294,6 +295,14 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
|
|||||||
display_name_length = name_tail - line;
|
display_name_length = name_tail - line;
|
||||||
strbuf_addstr(sb, "From: ");
|
strbuf_addstr(sb, "From: ");
|
||||||
add_rfc2047(sb, line, display_name_length, encoding);
|
add_rfc2047(sb, line, display_name_length, encoding);
|
||||||
|
for (final_line = 0; final_line < sb->len; final_line++)
|
||||||
|
if (sb->buf[sb->len - final_line - 1] == '\n')
|
||||||
|
break;
|
||||||
|
if (namelen - display_name_length + final_line > 78) {
|
||||||
|
strbuf_addch(sb, '\n');
|
||||||
|
if (!isspace(name_tail[0]))
|
||||||
|
strbuf_addch(sb, ' ');
|
||||||
|
}
|
||||||
strbuf_add(sb, name_tail, namelen - display_name_length);
|
strbuf_add(sb, name_tail, namelen - display_name_length);
|
||||||
strbuf_addch(sb, '\n');
|
strbuf_addch(sb, '\n');
|
||||||
} else {
|
} else {
|
||||||
|
@ -793,4 +793,19 @@ test_expect_success 'format-patch wraps extremely long headers (rfc2047)' '
|
|||||||
test_cmp expect subject
|
test_cmp expect subject
|
||||||
'
|
'
|
||||||
|
|
||||||
|
M8="foo_bar_"
|
||||||
|
M64=$M8$M8$M8$M8$M8$M8$M8$M8
|
||||||
|
cat >expect <<EOF
|
||||||
|
From: $M64
|
||||||
|
<foobar@foo.bar>
|
||||||
|
EOF
|
||||||
|
test_expect_success 'format-patch wraps non-quotable headers' '
|
||||||
|
rm -rf patches/ &&
|
||||||
|
echo content >>file &&
|
||||||
|
git add file &&
|
||||||
|
git commit -mfoo --author "$M64 <foobar@foo.bar>" &&
|
||||||
|
git format-patch --stdout -1 >patch &&
|
||||||
|
sed -n "/^From: /p; /^ /p; /^$/q" <patch >from &&
|
||||||
|
test_cmp expect from
|
||||||
|
'
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user