Don't assert in git_checkout_tree

According to the first error message in `git_checkout_tree`, it is valid to pass _either_ a repository or a treeish to it. However, it does just assert in the case that treeish was passed as `NULL`.

This patch changes
- the git_checkout signatures to all use a `const` opts parameter
- use HEAD when no treeish is given to `git_checkout_tree`
- reimplement `git_checkout_head` on top of that.