How to email patches formatted with git format-patch?

Viewed 6738

I've got a series of patches I want to send to an open source project but I'm not able to figure out how to properly format an email. I tried running a git format-patch command then attached them all into an email from Thunderbird but they all got rejected because each patch is supposed to be a separate email in itself. I want to avoid the git email commands because I have code in the same tree that is private and some that I need to send, which means I need to be able to manually review each email before it is sent.

I want to keep using Thunderbird, but there seem to be problems with it since it wraps lines and makes patches unusable. I also tried setting up fetchmail and mutt, but after literally 10 hours of reading and trying I gave up. Is there a non-fetchmail and non-thunderbird solution for sending git patches?

4 Answers

If you are using git format-patch, make sure to use it with Git 2.27 (Q2 2020): The output from "git format-patch" uses RFC 2047 encoding for non-ASCII letters on From: and Subject: headers, so that it can directly be fed to e-mail programs.

A new option has been added to produce these headers in raw.

That way, you don't have to deal with encoding if your email client understands just ASCII.

See commit 19d097e (08 Apr 2020) by Emma Brooks (``).
(Merged by Junio C Hamano -- gitster -- in commit f4216e5, 22 Apr 2020)

format-patch: teach --no-encode-email-headers

Signed-off-by: Emma Brooks

When commit subjects or authors have non-ASCII characters, git format-patch Q-encodes them so they can be safely sent over email.

However, if the patch transfer method is something other than email (web review tools, sneakernet), this only serves to make the patch metadata harder to read without first applying it (unless you can decode RFC 2047 in your head).

git am as well as some email software supports non-Q-encoded mail as described in RFC 6531.

Add --[no-]encode-email-headers and format.encodeEmailHeaders to let the user control this behavior.

Related