Tuesday, September 13, 2011

Git and Bugzilla patches

I am one of these unteachable conservatives that sometimes prefer the shell over IDE. Using git is not an exception here. One of the things I've always been missing was to apply a patch that is attached to a bugzilla entry directly, i.e. by referring to its URL without downloading it to a file. Fiddling arround a bit, I found a solution that I think is elegant.

You'll need wget for this to work. On my Mac I use the one from Mac Ports.

Add the following line to your .profile (or the config file of whatever shell you use)
git config --global alias.applyurl '!wget -qO- $1 | git apply -'
You should now have a new git command applyurl. Now open the bug with the patch you want to apply in your browser and copy the link of the patch. Finally you can on the command line, you can type
git applyurl [paste the url here]
That's it.


Unknown said...

Nice. Thanks for sharing this one.

Karsten Thoms said...

Good work. I've added this to my profile.