Provide a safer (and cleaner) checkout system

A five minute conversation with @arrbee lead to some refactoring of the branch switching code. Two major changes here:

1. Simply performing `git_repository_set_head` is not enough. I have to checkout the tree, _and_ move `HEAD`.
2. Refactoring that code lets me depend on `GIT_CHECKOUT_SAFE`, which fails if a dirty tree interferes with a branch checkout

This in turn will make the branch-switcher package a bit more safer, instead of depending on hacky checks in CoffeeScript.

I had to update _fixtures/references.git_ to be a bit more robust in these cases, hence all the changes there.

/cc @kevinsawicki