Send source patches with (G Suite) and Thunderbird
Gmail’s web mail client is not suitable for sending code patches, since it doesn’t send the email contents as is. TABs are converted to white spaces, trailing spaces are trimmed.
So the patch cannot be applied with git am
or git apply
!
|
|
We have to use an external email client (MUA; Mail User Agent).
Which email client should I use?
TL;DR: Use Mutt if you’re familiar with it, otherwise use Thunderbird.
If you’re sending git patch, use git-send-email(1) with googling “git send-email gmail”. It is the recommended way to send patches to Linux kernel.
In this article, cvs diff
, svn diff
, or any other unified diff (diff -u
)
formatted patches are supposed to be sent.
So I my checked out all the clients listed in Linux kernel’s document and git-format-patch(1) man page. My requirements are:
- Open source
- Continuously developed; Google changes the Gmail’s IMAP interface several times, so incompatibility in the client should be fixed soon; for instance, in 2019, the password login for IMAP was disabled by default, and the standard authentication was replaced with OAuth
- Many users send patches with that client; If we encounter a problem, someone has likely already solved it on Stack Overflow
Accordingly with the following google results:
Search keywords | GUI or TUI | # results as of 2020/03/13 |
---|---|---|
“git am” Mutt | TUI | 11,800 |
“git am” Thunderbird | GUI | 11,600 |
“git am” Alpine | TUI | 5,300 |
“git am” KMail | GUI | 1,650 |
“git am” Claws Mail | GUI | 2,270 |
“git am” TkRat | GUI | 252 |
“git am” Sylpheed | GUI | 262 |
“git am” Evolution (run only on Linux) | GUI | 11,900 |
“git am” outlook (non open source) | GUI | 6,690 |
“git am” apple mail (non open source) | GUI | 7,850 |
“git am” “apple mail” (non open source) | GUI | 101 |
At first I tried Mutt, which seemed to meet the needs, then faced an error like authentication failed. I discarded mutt right after searching gmail mutt “authentication failed” which didn’t show any useful information to solve it.
Next I tried Thunderbird, and I found out it’s very easy, many people are sending patches with it, and there are many knowledges in the web about sending patches.
Enable Gmail’s IMAP
Enable IMAP in Settings.
Add account in Thunderbird
File → New → Existing Mail Account…
Enter your name and Gmail (foo@gmail.com) or G Suite (foo@foo-organization.com) email address and press Continue. Leave Password blank.
Press Manual config.
Make sure that Authentication is OAuth2 and press Done.
Enter your Google (G Suite) password.
Unfortunately, this time I failed the authentication with the following errors:
- User name or password invalid
- Configuration could not be verified ― is the user name or password wrong?
I believe this will fixed soon.
As a workaround I used the password authentication.
Password authentication
Leave the Thunderbird’s setting window open!
First, we have to allow less secure app access for password authentication.
If you’re adding G Suite account (if email address is you@your-company.com, not you@gmail.com), the G Suite administrator have to allow Control access to less secure apps.
For both Gmail and G Suite, goto Less secure app access settings and turn on Allow less secure apps. Account can be switched by clicking the icon on the upper right.
Then on Thunderbird, choose Normal password as Authentication and press Done.
You will see the received emails on Gmail, hooray 🎉
Disable format=flowed
But still Thunderbird trims white spaces! Change the settings following to git-format-patch(1):
- Edit → Account Settings → Composition & Addressing → uncheck Compose messages in HTML format
- Edit → Preferences → Advanced → Config Editor…
mail.wrap_long_lines
:false
mailnews.wraplength
:0
mailnews.send_plaintext_flowed
:false
Now format=flowed
will be removed from email headers:
|
|
and body will be sent AS IS.