Description
There has been a latent sentiment amongst contributors that jj
has outgrown its need to depend on libgit2
, and as such we are moving to replace it and eventually deprecate it. This issue tracks the reasoning for this move, as well as the steps needed to make it happen and a deprecation plan.
Steps
- Implement shelling out to a git subprocess for
push/fetch
. git: spawn a separate git process for network operations #5228 - Migrate remote operations with
gitoxide
. - Migrate git tests to
gitoxide
- cli/tests: move a lot of the cli tests to gitoxide #5575 #5639
- lib/tests: port lib tests to gitoxide #5757
- cli/tests: move bookmark_command test to gitoxide #5754
- cli/tests: migrate more tests from
git2
togitoxide
#5655 - lib/tests: move remaining git test to gitoxide #5813
- cli/tests: move test_git_colocated to gitoxide #5803
- lib: move git_backend tests to gitoxide #5770
- cli/tests: move remaining tests to gitoxide #5846
- Switch the default
push/fetch
code path to use thegit
subprocess git: enable subprocessing by default #5652 - Barricade the
git2
code behind a (enabled by default) feature flag git: makegit2
support optional #5956 - Enable a deprecation warning for
git2
git: add deprecation warnings forgit.subprocess
#6047 - Remove
git2
git: removegit.subprocess
setting #6048
Outstanding bugs
We list here bugs that have arisen with git subprocessing. Although sometimes git2
might not be the solution (some of them were use-cases that were wholly blocked by git2
), it is good to have them registered and try to figure them out before we fully deprecate git2
.
- authentication problems
- git-push ref failures
Rationale
Issues with git2
libgit2
(with git2
being its Rust bindings) is a project to implement git
as a library so that external applications can interact programmatically with git
repos without having to shell out to git and parse its output.
This effort is commendable and git2
has been crucial in making jj
git compatible from the get go. I'd like to emphasize that this is by no means a bash on libgit2
. However, we have found some pain points with its usage:
- Missing support for
SSH
. This regularly comes up when users try to push to Github, with over 20 issues opened about it forjj
plus multiple reports a week. - Packaging problems.
libgit2
only supports one version at a time, meaning packagers have a problematic window of time whilejj
has not updatedgit2
to its latest version. - Performance. For the main (current) usage of
libgit2
, which is interacting withgit
remotes,libgit2
has been reported to be slow.
Change to what
jj
actually uses another git
library to interact with repositories: gitoxide
. This means that, as it stands, we have two libraries for interacting with git
, which is arguably one too many.
As gitoxide
has become more feature complete, relying on git2
becomes less desirable.
For the remaining cases (which turn out to be simply the push
/fetch
operations), the consensus is to rely on shelling out to a git
subprocess.