Yes with **out** parameter it's work, I know. 
But your code gives  different result, it always allocate libgit2 repository data and return handle that I will have to destroy if it can open git repository.

My version not allocate repository handle at all.
```
 * @param out Pointer to the repo which will be opened.  This can
 *        actually be NULL if you only want to use the error code to
 *        see if a repo at this path could be opened.
```