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.