Check the result of git_reference_peel, not the pointer

There’s no reason `obj` is guaranteed to be NULL here. Trying to use it
could result in a crash.
Merge pull request #307 from libgit2/fail-on-resolve-error

Check the result of git_reference_peel, not the pointer