Use Gnus to apply patch sent by `git send-email`

  |   Source

Gnus to apply patch sent by `git send-email` :git:email:patch:en:emacs:

Setup git-send-email

On Debian run sudo apt-get install git-email to install git command line tools.

Then run cpan Authen::SASL MIME::Base64 Net::SMTP::SSL to install perl packages (check cpan howto).

Modify ~/.gitconfig to use Gmail SMTP:

[sendemail]
    smtpencryption = tls
    smtpserver = smtp.gmail.com
    smtpuser = username@gmail.com
    smtpserverport = 587

Send the latest commit

# send one commit
git send-email -1 --annotate

Apply patch

Select one mail. Run command "M-x gnus-summary-save-article-email" whose short key is "O m" in summary buffer.

Emacs will ask for directory to save that patch. Say I save it as ~/News/patch/hello.patch.

git am ~/News/patch/hello.patch

Syntax highlight patch embedded in mail (OPTIONAL)

Use gnus-article-treat-patch.el.

Add below code to setup:

(require 'gnus-article-treat-patch)
(setq gnus-article-patch-conditions
      '( "^@@ -[0-9]+,[0-9]+ \\+[0-9]+,[0-9]+ @@" ))
Comments powered by Disqus