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

Re: [PATCH] Add MIME information to outgoing email

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2008, 16:20 UTC
Message-ID
<7v4pb9qnuu.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080313170016.GA3439@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Thu, Mar 13, 2008 at 05:40:19PM +0100, Samuel Tardieu wrote:
>
>> Add MIME-Version/Content-Type/Content-Transfer-Encoding headers in
>> messages generated with git-format-patch. Without it, messages generated
>> without using --attach or --inline didn't have any content type information.
>> 
>> I got hit with this problem yesterday when sending a patch to linux-kernel
>> with a commit message containing the name "Pádraig" in it. Moreover,
>> the mailing-list software added an incorrect ISO-8859-1 encoding information
>> which mangled Pádraig's name.
>
> It's supposed to handle this automatically if the commit message
> contains non-ascii characters. What version of git were you using?
You are right.  The call-chain looks like this:
    log_tree_diff_flush()
     show_log()
      log_write_email_headers()     writes mbox From
      pretty_print_commit()
                                    check commit log if it is pure ascii
       pp_header()
        pp_user_info()              writes RFC2822 From:
       pp_title_line()              writes RFC2822 Subject:
                                    writes MIME-Version: and friends if needed
       pp_remainder()               writes the remainder of the log message
      append_signoff()
     printf("---\n")
     diff_flush()                   writes the patch

At the beginning of pretty_print_commit() we look at the log and if it is not ascii we pass that information down to pp_title_line() which is responsible for writing MIME header at the appropriate place.

If your patch itself has some non-ASCII material, and if your commit log message is pure ASCII, the above would end up not writing MIME at all. If your commit log message is non ASCII, then we will mark it as if the entire message is in the encoding of the log in pp_title_line(). This might look like a problem, but it is not something non multipart output of format-patch should even try to cater to. The payload (i.e. the patch) out of git has always been uninterpreted sequence of bytes (and it is not going to change).

A patch to i18n po/ files for example could contain patches to different files encoded in KOI-8, BIG5, EUC-JP and UTF-8 at the same time. There is no way to say "text/plain; charset=X" for such a payload (because there is no single charset used in such a patch), and git simply does not know nor care about what encoding each file is in. The output from git marks only the part git knows the encoding about (i.e. the commit log message).

Having said all that, I notice that addition of format.headers variable (which I think is a later invention) was done not quite correctly. In the callchain above, pretty_print_commit() function checks the commit log but it is meant to do so only when we haven't emitted MIME Content-Type: (because the user told us to do multipart), and "after_subject" parameter was getting passed around for it (and its callees) to detect exactly that. But format.headers misused that variable to carry its contents along --- there needs a way to pass "have we said MIME-Version crap already" separately.

Previous: Samuel TardieuNext: Junio C Hamano
Message 10 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.