git squash fixes

* fix BSD `mktemp` incompatibility
* also add some more robust features:
    * stash changes before starting, restore them on exit
    * if the commit step fails, `reset --hard` to the ref that we started at

fixes #50