faq: Add Q&A for applying patches from email.
Acked-by: Aaron Conole
@@ -121,3 +121,52 @@ Q: What's a Signed-off-by and how do I provide one?
commit -s". If you use the "git citool" GUI for commits, you can add a
Signed-off-by line to the commit message by pressing Control+S. Other Git
user interfaces may provide similar support.
+
+Q: How do I apply patches from email?
+
+ A: You can use ``git am`` on raw email contents, either from a file saved by
+ or piped from an email client. In ``mutt``, for example, when you are
+ viewing a patch, you can apply it to the tree in ~/ovs by issuing the
+ command ``|cd ~/ovs && git am``. If you are an OVS committer, you might
+ want to add ``-s`` to sign off on the patch as part of applying it. If you
+ do this often, then you can make the keystrokes ``,a`` shorthand for it by
+ adding the following line to your ``.muttrc``:
+
+ macro index,pager ,a "<pipe-message>cd ~/ovs && git am -s" "apply patch"
+
+ ``git am`` has a problem with some email messages from the ovs-dev list for
+ which the mailing list manager edits the From: address, replacing it by the
+ list's own address. The mailing list manager must do this for messages
+ whose sender's email domain has DMARC configured, because receivers will
+ otherwise discard these messages when they do not come directly from the
+ sender's email domain. This editing makes the patches look like they come
+ from the mailing list instead of the author. To work around this problem,
+ one can use the following wrapper script for ``git am``::
+
+ #! /bin/sh
+ tmp=$(mktemp)
+ cat >$tmp
+ if grep '^From:.*via dev.*' "$tmp" >/dev/null 2>&1; then
+ sed '/^From:.*via dev.*/d
+ s/^[Rr]eply-[tT]o:/From:/' $tmp
+ else
+ cat "$tmp"
+ fi | git am "$@"
+ rm "$tmp"
+
+ Another way to apply emailed patches is to use the ``pwclient`` program,
+ which can obtain patches from patchwork and apply them directly. Download
+ ``pwclient`` at https://patchwork.ozlabs.org/project/openvswitch/. You
+ probably want to set up a ``.pwclientrc`` that looks something like this::
+
+ [options]
+ default=openvswitch
+ signoff=true
+
+ [openvswitch]
+ url=https://patchwork.ozlabs.org/xmlrpc/
+
+ After you install ``pwclient``, you can apply a patch from patchwork with
+ ``pwclient git-am #``, where # is the patch's number. (This fails with
+ certain patches that contain form-feeds, due to a limitation of the protocol
+ underlying ``pwclient``.)
