-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git_backend: replace git2::Repository with gix::Repository #2478
Conversation
7bb7358
to
979b527
Compare
Thanks for doing this, it's nice to see that we can intergrate Gix so easily. Can we protect the different Git backends with a runtime flag, as I think a feature is overkill? E.g
Can we file a upstream bug for more configuration options and see what happens? I think martin should do the final review though, as the Git backend is not my expertise. |
That's doable, but I don't think we'll need runtime or compile-time flag. They're functionally equivalent, and having separate backends will double the maintenance cost.
gitoxide provides various ways to configure repository instance. It just doesn't have a global switch. I think that's by design. Perhaps, a better workaround is to initialize |
I agree that this doubles the maintenance cost but before we finish the migration to Gix it would be wise to allow a partial rollout.
Maybe we'll need a config shim until libgit2 is gone. |
We won't fully drop the libgit2 dependency anytime soon (because push/fetch API isn't mature afaik.) If we think it's too early to migrate "some" of the git interface to gitoxide, it's probably better to stick to libgit2. |
My main concern is that we might run into some bug in gitoxide that makes it unable to access certain repositories (maybe using some rarely used packfile feature or running into some corner case in the packfile format). I'm going to cut jj 0.11 today, so right after that seems like the perfect time to switch. Then we'll have a full month to test it. Does that sound safe enough, @PhilipMetzger? |
Yes, I'm aware that this won't be anytime soon, but when they have feature parity a flag would make sense.
Yes, that perfectly encapsulates my concerns as well. I just don't want Hyrum to show up. Every "identical" implementation must be bug for bug compatible to not fall victim to it.
Seems great, we'll see what happens. |
@Byron, I thought you might be interested in this PR |
Thanks for reeling me in! I will definitely take a look once you think it's nearing completion to see if I like the
Even though What would help me is to have an issue (maybe over at |
It's actually already complete :) However, this is just for jj's "git commit backend", which just interacts with the object store (read and write commits, trees, blobs).
Interesting! I think ref-deltas was what I was thinking of as a feature gitoxide might not support well (I had heard about them from the Git team at Google), though I didn't even remember how they worked.
Sounds good. We'll continue to use libgit2 for push and fetch for now. |
Since I don't now when the azure-repos issue will be resolved on the side of |
@Byron, just to be sure, the |
|
I've enabled the "index" component from the "basic" feature set, which would be needed to implement colocated repo functionality. The doc suggests that a library shouldn't activate "max-performance-safe", but our crate is also an application so it would be okay to enable the feature. We'll need "parallel" anyway to make GitBackend Sync. https://docs.rs/gix/latest/gix/#feature-flags
These error enums will wrap gix error types, and will become bigger enough for clippy to complain.
Otherwise, the initialized repo could have a different work-dir path than the load()-ed one. libgit2 appears to do some normalization somewhere, but gix won't.
…anch AFAIK, there's no global config state for gitoxide. We can use Config::isolated() in tests, but GitBackend should load config files in a normal way. https://docs.rs/gix/0.55.2/gix/open/permissions/struct.Config.html#method.isolated https://docs.rs/gix/0.55.2/gix/init/constant.DEFAULT_BRANCH_NAME.html
My gut feeling is that gitoxide aims to be more transparent than libgit2. We'll need to know more about the underlying Git data model. Random comments on gix API: * gix::Repository provides API similar to git2::Repository, but has less "convenient" functions. For example, we need to use .find_object() + .try_to/into_<kind>() instead of .find_<kind>(). * gix::Object, Blob, etc. own raw data as bytes. gix::object and gix::objs types provide high-level views on such data. * Tree building is pretty low-level compared to git2. * gix leverages bstr (i.e. bytes) extensively. It's probably not difficult to migrate git::import/export_refs(). It might help eliminate the startup overhead of libssl initialization. The gix-based GitBackend appears to be a bit faster, but that wouldn't practically matter. jj-vcs#2316
…git2 Since gix::Repository::config_snapshot() borrows the repo instance, it has to be allocated in caller's stack. That's why GitBackend::git_config() is removed.
979b527
to
66baeac
Compare
#2316
Checklist
If applicable:
CHANGELOG.md