It took me a while to figure out why your example code wasn't constantly overwriting the same element. That usage (or name) of `git_array_alloc()` seems rather counter-intuitive. I wouldn't expect something called `array_alloc` to give me a pointer to the middle of the array (props for making it a series of ternaries, though), but I'm not sure of a better name, maybe `alloc_next`?

But yeah, using that (i.e. using the API as it was designed) would make the code flow much better.