Shouldn't we also `assert(git_object_owner((const git_object *)tree) == repo);` here?