git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] format-patch does not wrap From-field after author name

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Apr 14, 2011, 17:01 UTC
Message-ID
<BANLkTimruwojkq_HNMZeCDBV6K8_aFc_XQ@mail.gmail.com>

With certain combinations of author name and email lengths, git format-patch does not correctly wrap the From line to be below 78 characters, violating rfc2047.

This happens because pp_user_info in pretty.c use add_rfc2047 (which wraps) for the name, but strbuf_add (which does not wrap) for the email part.

Here's a test that illustrate the problem:
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 9c66367..a4b8b59 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -793,4 +793,19 @@ test_expect_success 'format-patch wraps extremely
long headers (rfc2047)' '
 	test_cmp expect subject
 '

+M8="foo_bar_"
+M64=$M8$M8$M8$M8$M8$M8$M8$M8
+cat >expect <<'EOF'
+From: foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar
+ <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
Next: Junio C Hamano
Message 1 of 15 in “[BUG] format-patch does not wrap From-field after author name”
  1. Erik Faye-LundApr 14, 2011
  2. Junio C HamanoApr 14, 2011
  3. Jeff KingApr 14, 2011
  4. Erik Faye-LundApr 14, 2011
  5. Jeff KingApr 14, 2011
  6. Jeff KingApr 14, 2011
  7. Erik Faye-LundApr 14, 2011
  8. Jeff KingApr 14, 2011
  9. Erik Faye-LundApr 14, 2011
  10. Jeff KingApr 15, 2011
  11. Erik Faye-LundApr 15, 2011
  12. Jeff KingApr 16, 2011
  13. Jeff KingApr 14, 2011
  14. Erik Faye-LundApr 14, 2011
  15. Erik Faye-LundApr 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.