So, it has been some months I last wrote on my blog. Not because I don’t have things to write, but because sometimes I’m too lazy do empty my “queue of things to write about”. Nothing better than start with one thing at a time.
Since january I’m working at ProFUSION. As before when I was mainly developing for Linux kernel and finishing my thesis (@ USP / Polimi), I’m using git a lot. Even in projects in which upstream is using a centralized approach like subversion, I simply can’t live without a local tree and thus, git. So here I’ll post somethings I’ve been using:
1. Incrementally add your changes to commit
One thing that is essential to keep your tree clean is to commit each new feature in a different commit and write a proper description of what you are doing and perhaps why you are doing that (often in case of a bug fix). But, sometimes you don’t code “atomically” several logically separated parts. Instead, you may prefer to code a lot (whilst you still have a great amount of caffeine in blood) and separate them when you finish. Here comes the savior command:
$ git add --patch file-to-partially-add-to-commit
So you will be presented to a series of options where you can choose which parts are going to next commit and the ones that will remain on unstaged area.
See The Thing About Git for more details.
2. Using gmail to receive patches
While our googler friends do not implement a proper way to export emails as mbox, with this tip we can circunvent the problem without relying on standalone clients such as mutt. Steps:
- Create a ‘patch’ label in Gmail (or whatever name you want).
-
Install fetchmail and procmail from your distro repository:
- Archlinux: sudo pacman -S fetchmail procmail
- Gentoo: sudo emerge …
- Ubuntu: sudo apt-get install …
-
Configure fetchmail to use your google account. Put this in your \$HOME/.fetchmailrc
set postmaster "YOUR_LINUX_USER"
set bouncemail
set no spambounce
set softbounce
set properties ""
set no showdots
poll imap.gmail.com with proto IMAP
user 'YOUR_EMAIL@gmail.com' there with password 'YOUR_PASS' is 'YOUR_LINUX_USER' here
options keep fetchall ssl mda "formail -c >> /PATH/TO/SAVE/patches.mbox"
folder patch
Workflow
- Find patches to be applied in gmail;
- Mark them with ‘patch’ label;
-
Use fetchmail to download patches:
bash $ fetchmail
-
Now you can happily apply patches saved in /PATH/TO/SAVE/patches.mbox to your project with:
bash $ git am /PATH/TO/SAVE/patches.mbox