setting `out` to `NULL` would allow you to remove the `if` statement around the call to `git_reference_free()`