I've used it - it's lacking a ton of features. Another commenter in this thread said it's very slow compared to the git CLI, which is not surprising given that git is written in C.
I’ve used it for a production service. I thought it was surprisingly robust/featureful. There was one issue I ran into, but IIRC it was a limitation in the library’s filesystem abstraction, not a missing feature.
I would have used libgit2 myself in any languages. If bindings do not exist, I would have made the bindings first. There is no way I would have called out to an external program.
Someone mentioned https://github.com/go-git/go-git. I would have definitely used it unless there are better alternatives. If - as someone who claimed - it turns out it is slow, I would have created my own bindings to libgit2 still, most likely.
Binding to C in Go is a bad idea typically. There’s performance overhead, but more importantly your library (and everything downstream) also loses the ability to do nice things like fast compile times or easy cross compilation. You also likely introduce a runtime dependency on libc if not libgit2, so you have some DLL hell to deal with.
How do you define significant? It is noticeable as compared to C. It is nothing compared to Python.
> Are there any benchmarks on this?
You will see an additional ~20ns per call (assuming the gc compiler; tinygo, for example, can call C functions as fast as C can). In other words, you're not ever going to notice unless you're making millions of calls in a hot loop. The bigger problem in a highly concurrent environment is that blocking C functions can start to mess with the scheduler if they are slow to return. You, again, would never notice in a program of this nature, though. The feature is there to be use. It being a "bad idea" is nonsense.
Some added pain in compilation is, fairly, a tradeoff to consider. But that's just because C compilers, for the most part, aren't very good. It is not like those problems go away if you use C instead.
Yeah, but for this project, why would you choose (as others stated they would or prefer) to call out to an external program instead of using https://github.com/libgit2/git2go (libgit2, FFI) for example? For what it is worth, there is also a pure Go implementation: https://github.com/go-git/go-git (pure Go).
Keep in mind the initial comment, which is "I would have used libgit2 myself in any languages.", and they claimed it is a bad idea due to performance, as opposed to calling out to an external program.
The main reason I cited for avoiding CGo was the impact on the code base, not the performance overhead. I’m not advocating for shelling out to the Git CLI, but rather preferring go-git unless there is a compelling reason to avoid it.
No, I want people to be informed well, and that requires me to hear their side so I can dispute them.
Many people has said they are thankful it calls out to "git" instead of using FFI, which I think is weird, but then there are others who go ahead and say that it is a worse thing to do, and I want people to know that no, it is not.
Yep, ggc is a wrapper around the git CLI — intentionally so.
I chose to shell out to git because it's fast, stable, and has great cross-platform support. Tools like go-git and libgit2 are interesting (and I’ve looked into them), but they come with their own tradeoffs like performance, features, and build complexity.
That said, I totally get the curiosity — thanks for the discussion!
Principally, but not exclusively. It was also told to be a bad idea because of some insignificant performance overhead associated with cgo.
Which is especially funny as using go-git (which is known to be slow) and shelling out to git are apt to bring even greater performance overhead. As always, don't assume – measure!, but if we have to play the odds for the sake of an internet comment, libgit2 is likely to be the most performant option reasonably available, if there is some reason to think that performance is of concern here.
Added complexity in compiling is a tradeoff to consider, of course, but "bad idea" is also nonsense there. It requires a different set of priorities, but those priorities may very well be exactly what a project needs. — And maybe not even. The earlier comment brought a lot of assumptions without offering any background. There are theoretically other options available for libgit2. For example, using the Wasm build. While others have had success using Zig as the C-side compiler, which doesn't have all the messy baggage legacy compilers tend to carry (e.g. poor cross-compilation support).
Yes, measurement may offer reason why those are not suitable options, but missing in the comment is the measurement, or even what is trying to be measured! Instead, we got something that appears to be copy and pasted straight from a Rust advertisement.
> Added complexity in compiling is a tradeoff to consider, of course, but "bad idea" is also nonsense there. It requires a different set of priorities, but those priorities may very well be exactly what a project needs.
Yes, there are cases in which CGo’s tradeoffs are appropriate, but you’re rebutting my claim that CGo is a bad default, so you need to show that CGo is appropriate in the default case (you went so far as to call it “nonsense”), not merely that there exists some project for which CGo’s tradeoffs are appropriate.