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

Re: Re* [PATCH] Add MIME information to outgoing email

From
Jeff King <peff@peff.net>
Date
Mar 14, 2008, 21:27 UTC
Message-ID
<20080314212707.GA1027@coredump.intra.peff.net>
In-Reply-To
<7vbq5hoy48.fsf_-_@gitster.siamese.dyndns.org>
On Fri, Mar 14, 2008 at 01:21:27PM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> I think the real culprit was the way the "after_subject" was added to the
> callchain (it had loaded semantics -- "here is what we want to say after
> emitting Subject: line" and "have we done any MIME yet?"), not the poor
> guy who did format.headers.
> 
> In any case, this patch would hopefully separate the two.  The old
> "plain_non_ascii" parameter is now need_8bit_ct_header and now can have
> one of three values:

I was just about to submit a patch splitting after_subject into "mime_headers" and "extra_headers".

I noticed another bug while doing mine: we are sometimes not strict _enough_ in squelching headers. A patch made with "-s --attach" when the signoff has non-ascii characters would end up with duplicated MIME headers. Your patch handles this fine.

I think your approach is a little nicer. Here is the test case I wrote for my patch. It covers the original problem and the one I mentioned above; both fail with current master but pass with your patch.

---
diff --git a/t/t4021-format-patch-signer-mime.sh b/t/t4021-format-patch-signer-mime.sh
index 67a70fa..9bc47a5 100755
--- a/t/t4021-format-patch-signer-mime.sh
+++ b/t/t4021-format-patch-signer-mime.sh
@@ -38,5 +38,13 @@ test_expect_success 'format with non ASCII signer name' '
 
 '
 
+test_expect_success 'attach and signoff do not duplicate mime headers' '
+
+	GIT_COMMITTER_NAME="$B$O$^$N(B $B$U$K$*$&(B" \
+	git format-patch -s --stdout -1 --attach >output &&
+	test `grep -ci ^MIME-Version: output` = 1
+
+'
+
 test_done
 
diff --git a/t/t4028-format-patch-mime-headers.sh b/t/t4028-format-patch-mime-headers.sh
new file mode 100755
index 0000000..204ba67
--- /dev/null
+++ b/t/t4028-format-patch-mime-headers.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='format-patch mime headers and extra headers do not conflict'
+. ./test-lib.sh
+
+test_expect_success 'create commit with utf-8 body' '
+	echo content >file &&
+	git add file &&
+	git commit -m one &&
+	echo more >>file &&
+	git commit -a -m "two
+
+	utf-8 body: ñ"
+'
+
+test_expect_success 'patch has mime headers' '
+	rm -f 0001-two.patch &&
+	git format-patch HEAD^ &&
+	grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch
+'
+
+test_expect_success 'patch has mime and extra headers' '
+	rm -f 0001-two.patch &&
+	git config format.headers "x-foo: bar" &&
+	git format-patch HEAD^ &&
+	grep -i "x-foo: bar" 0001-two.patch &&
+	grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch
+'
+
+test_done
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 25 in “Add MIME information to outgoing email”
  1. Add MIME information to outgoing emailSamuel Tardieu, Mar 13, 2008
  2. Jeff KingMar 13, 2008
  3. Samuel TardieuMar 13, 2008
  4. Jeff KingMar 14, 2008
  5. Samuel TardieuMar 14, 2008
  6. Jeff KingMar 14, 2008
  7. Samuel TardieuMar 14, 2008
  8. Jeff KingMar 14, 2008
  9. Samuel TardieuMar 14, 2008
  10. Junio C HamanoMar 14, 2008
  11. Re* [PATCH] Add MIME information to outgoing emailJunio C Hamano, Mar 14, 2008
  12. Jeff KingMar 14, 2008
  13. Junio C HamanoMar 13, 2008
  14. Samuel TardieuMar 13, 2008
  15. Brian SwetlandMar 14, 2008
  16. Samuel TardieuMar 14, 2008
  17. MIME headers in introductory message (git send-email --compose)Teemu Likonen, Mar 25, 2008
  18. Jay SoffianMar 25, 2008
  19. Junio C HamanoMar 25, 2008
  20. Jay SoffianMar 25, 2008
  21. Jeff KingMar 25, 2008
  22. Jeff KingMar 25, 2008
  23. Jeff KingMar 25, 2008
  24. Jay SoffianMar 26, 2008
  25. Jan HudecApr 10, 2008

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.