Yeah, unfortunately there's not really much of an alternative here besides dropping libgit2 and subshelling out to git (which we honestly should consider, it just hasn't been a priority).
I think there are two alternatives of increasing difficulty: 1. Write a thicker wrapping around git2 (possibly in a different crate) that achieves an idiomatic API. 2. Write an equivalent to libgit2 in rust.
It’s true that 2 has some significant downsides and probably isn’t worth the effort but it certainly would’ve prevented this bug.