git was designed to be very flexible in its workflow. One of the things it was designed to do was handle email patches, since there are a lot of patches sent to and from the mailing list. This is a good thing, even if you don’t have a mailing list, or you have your own bug tracker (in addition to RT), you can use RT to receive email patches from git. First you have to configure your MUA (mail client)(and go write a patch), some suggestions are given in git.git’s SubmittingPatches document. If you like the CLI I suggest you use the git send-email command. I’m going to walk you through using it, but you’ll have to learn how to set it up for your smtp server on your own (one hint: if you don’t provide an smtp pass as an argument or as a config option you will be prompted for it).now you have a patch that you haven’t pushed yet. you can run one of the following sets of steps to get going.git format-patch -M HEAD~1 # commitish. commit before the number of patches you want to generatevi 0001-patch-name # and add some description between the — and the diff statgit send-email 0001-patch-name # can replace this step with MUA of choice git format-patch -M HEAD~5 # generate a patchset of the last 5 patchesgit send-email –annotate *patch # will open the core.editor you set in gitconfig to edit the patchgit send-email –annotate –format-patch -M –to=destination-email origin/master# generate all the patches that aren’t committed against origin/master branch in your local branchfor the time being you should probably just send it to one of your own projects on cpan so you can see. If you look at the web interface for the bug you’ll notice it’s clobbered your formatting, same goes with the email RT sends you… so this is useless right? well… certainly doesn’t help… now look at the ‘with headers’ version. Their are lots of headers here, but all your content is intact. Now download this file (right click save as should do it).you may now ( you may have to run git reset –hard HEAD^ first to undo you last commit).git apply downloaded-file.txtwhich will only apply the diff no commit log or anything (reset without HEAD^ now).or you can git am -i downloaded-file.txt -i is interactive and will allow you to choose whole folders full of mail patches and which to apply.I think this is a good workflow for 1 off patches. obviously you don’t send them to yourself, I’m just trying to show you what it’s like to send and receive.– This work by Caleb Cushing is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Load comments