The outstanding patches from upstream so far this year, except the whitespace cleanup one

This PR includes the patches from upstream git so far this year, with the exception of the whitespace cleanup one which didn't apply cleanly.

    http://repo.or.cz/w/git-dm.git

If the whitespace one is also needed, it could probably be done too with a bit of manual adjustment.