You could do

```c
while ((error = git_reference_next(&ref_name, iter)) == 0)``
```