Last updated on December 14, 2016
Git is a popular version control system that manages many impacting open source projects. Many of these projects, such as Linux kernel, zsh, GNU Emacs, etc. require patches and pull requests to be sent to their mailing lists. This can usually be done via git send-email
or git imap-send
, which, however, often takes a large amount of configuration and headaches for many people to make it work for the first time. Here, I propose a new approach to send git patches via email with GUI email clients, such as Thunderbird, Evolution, Claws Mail and Apple Mail.
Similar to the “standard” way, the first step is again to generate the patch with git format-patch
. For example, to contribute to zsh:
git clone git://git.code.sf.net/p/zsh/code
git checkout -b new-branch
# Edit files...
git commit -a -m "My contribution"
git format-patch master
You should now have a file named 0001-My-contribution.patch
in the current directory—this is the patch we are going to send out. It looks like something like follows:
From 6837a6dc0d8bc968ee058d9259baa27ca5fb79c2 Mon Sep 17 00:00:00 2001
From: Hong Xu <hong@topbug.net>
Date: Tue, 13 Dec 2016 14:52:37 -0800
Subject: [PATCH] My contribution
---
Src/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/main.c b/Src/main.c
index 30eef5a2549c..af6b3c6b93a5 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -86,7 +86,7 @@ cygwin_premain0 (int argc, char **argv, void *myself)
/**/
#endif /* __CYGWIN__ */
-/**/
+/* My new contribution: add Docs for the main function! */
int
main(int argc, char **argv)
{
--
2.1.4
At this point, the standard route would tell you to send it out using git send-email
or git imap-send
. Here, we are going to convert the patch to a mailto
URL that GUI email clients can recognize with the following script git-gui-email.py
(also available on GitHub gist):
Download the script and run it:
python3 git-gui-email.py zsh-workers@zsh.org < 0001-My-contribution.patch
Your default GUI email client should now automatically pop up with the contents filled with the patch. Below is a screenshot from my Claws Mail:
Finally, don't forget to change your email format to plain text!
I didn’t see any open source verbiage in the python source which would likely double or triple the size of the git-gui-email.py script file. How is this licensed?
I would need to make a change to handle Subject lines which ‘git format-patch’ wraps to multiple lines.
Otherwise, the script looks like it could be useful.
Thanks!
Thank you for the suggestion, I’ve added a licensing line.
Is not working to download the script. Do you have any advice?
Fixed now. Thanks!