Lazygit: Use libgit2/git2go instead of command line git

Created on 8 Jan 2020  路  8Comments  路  Source: jesseduffield/lazygit

Topic
There's a library called lib2git that has a library made to integrate with git without having to run command line options in sub shell like (I believe) y'all are currently doing.

Said project has go bindings as well at git2go.

Your thoughts
This is mostly just an "FYI, this thing exists which might be better/useful". I haven't looked into it much, but I feel like it might solve some of the issues I've been dealing with related to interacting with different versions of git, which seem to mostly be changing of flag names. (see #557, #553, #548 (already fixed, but possibly avoided doing it this way).

compatibility discussion performance

Most helpful comment

git2go is just a binding to libgit2, you still need libgit2 C library installed to be able to compile the project using it and go-git is a standalone pure Go implementation of git functionality

All 8 comments

We are aware of this. In fact we are already using go-git for some operations, which is a pure Go git implementation.

Granted that using the library fully instead of mixing it with shell commands would be better, but one needs to actually take some time to make the transition and make sure everything works as expected.

PRs are always welcomed.

Out of curiosity, any reason behind using go-git and not git2go? My (naive) point of view, seems like git2go is the more feature complete option (the go-git website even mentions that their goals is to "each the completeness of libgit2".

git2go is just a binding to libgit2, you still need libgit2 C library installed to be able to compile the project using it and go-git is a standalone pure Go implementation of git functionality

also worth noting that I've spent a bit of time trying to use go-git and it didn't have as much functionality as I first expected, and proved slower in some ways (e.g. fetching commits)

These kinds of libraries that include c files also runes a bit the simplicity of go because if we would include this,
libgit2 also needs to also be installed on the computer separately and for programmers that have never used c this can be a bit scary and might stop some users from committing to lazygit.

I personally don't have a good experience with go libraries that include non go files because they never seem to be working out of the box and always require me to search for the right package in the package manager and for some linux distros this can be a bit tricky not even talking about windows.

Is it possible to install lib2git along with lazygit? I.e. bundle it up into the binary? If so I'd be much keener on using it, especially for expensive operations like loading commits

As far as I know you only need libgit2 when you want to build the binary from source to use the build binary you don't need libgit2.

That would be great, I do want to switch over to something which is reliably fast for loading lots of git objects

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tupaschoal picture tupaschoal  路  6Comments

cbeley picture cbeley  路  6Comments

JoeKlemmer picture JoeKlemmer  路  3Comments

jangalinski picture jangalinski  路  4Comments

rubensr-pc picture rubensr-pc  路  5Comments