-
Notifications
You must be signed in to change notification settings - Fork 596
git: port remote management to gix
#5553
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this. Amazing effort!
I'm still working through the patch, will pick it back up tomorrow
ed8b4dd
to
d0bd11c
Compare
Thanks for reeling me in, and sorry for the late response!
Indeed, renaming isn't supported yet, and having some of the existing logic available would help implementing it.
I don't think this is more than an incomplete API.
I think this is me avoiding hassle. What it really wants to do is to allow passing various inputs, including strings, and parse it when needed. Right now there probably is only one API that does this (
The clone-happy APIs in
And I am really sorry for this being so half-done right now. Probably for you it's very much the same, but if not, or if there is some room to breathe once the first version of a feature is delivered in I will try to make these steps for GitButler eventually (sprinkling even more TODO's there 😁), and encourage you to do the same. |
Thanks for the detailed reply, @Byron!
Higher‐level porcelain APIs would definitely be welcome! But I understand that Git has many layers and there’s a lot of subtlety with higher‐level operations, so just having the lower‐level ones factored in a more reusable way would be great here.
That’s good to know; I’ll leave a comment to that effect in the code so that it can hopefully be cleaned up later.
Right. I guess you’d want a trait for things that can be converted to refspecs, or maybe you can use That said, I think it’d be fine if the remote API just only took pre‐parsed refspecs and you had to explicitly
Right. In this case we get around it by not actually mutating the in‐memory repository configuration (since it isn’t reflected in the In general I think that a bit of refcounting/cloning is usually cheap and can make an API simpler and more general enough that it’s worth it; I would say that lifetimes and error types are probably the trickiest parts of using gitoxide in my experience. But I can also understand wanting to exploit Rust’s capabilities to the fullest and avoid any unnecessary copying.
Yes, the temptation to just dive into the gitoxide code base is strong, but the more I let myself get carried away with such things the less likely I am to actually finish what I promised to do in the first place :) I’m also not too familiar with gitoxide’s codebase and haven’t fully wrapped my head around the code organization yet. Some of these things like the missing API to set the fetch URL seem simple, though, so I’ll see if I find the time to send a PR for that. If not, maybe someone else will see the TODO comment and take up the mantle in future! Thanks again for all your work on gitoxide and for your thoughts on my feedback; a Git reimplementation is a mammoth undertaking and I don’t think you have anything to be sorry for it not yet being perfectly polished! Now that we have code to shell out to |
493711f
to
497fd8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
2eda3ec
to
0e93879
Compare
Are there any major blockers here at the moment? No pressure if you haven't found time for the last bits, but happy to help carry this through in any way I can |
0e93879
to
d523612
Compare
This is more consistent with other similar APIs and minimizes churn in the test code as we move these to `gix`.
d523612
to
b130776
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much. Left a couple of nits and Qs, but I'd be fine with it being merged as is.
That being said, I think @yuja would have a better understanding here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, thanks!
b130776
to
5b5790e
Compare
It's great to see this PR merged, and I am sorry to probably have made the impression of being disinterested in what's going on it. That's not the case, fortunately, I just didn't have bandwidth and won't have bandwidth to do what I'd want to do: read each comment carefully and see if So all I can do here is to encourage opening issues on Thanks and cheers |
Not at all, I appreciate you popping in :) We have some TODOs for things to upstream already, which I will try to get around to if time permits. |
(Plus one more change to remove the other remaining
git_util::get_git_repo
caller.)I’m not wholly confident in the first commit here, but the rest should hopefully be good. It feels like there might be awkward race conditions in here but I think Git is just like that.
@Byron 👋 I thought you might be interested in some API UX feedback I came up with while working on this. If you’d like me to open issues/discussions on the
gix
side for any of these please let me know.It’s awkward that
gix::Remote::save_to
handles the fussy details of removing the other sections for that remote from the config, but leaves you to reimplement it yourself if you need it in any other context. It would be nice if the removal logic was exposed separately, or perhaps if there was a specific way to tellgix
that you’re renaming a remote and the old config should go away.You can change the name of a
gix::Remote
, and you can set its push URL, but you can’t change its fetch URL. Inset_remote_url
I have to manually copy over all the data from the existing remote to achieve this. Not sure if this is a fundamental constraint of the model or just a missing API.It’s a little surprising that there’s a rich representation of parsed refspecs but the remote API expects you to pass in a
BStr
and deal with potentially‐impossible parse errors.The borrowing model of configuration and remotes interact awkwardly. In a previous version of this PR where I tried to persist the remote configuration changes to the
gix::Repository
, I had to clone the entire thing so that I could hold agix::Remote
and agix::config::SnapshotMut
at the same time (otherwise the immutable and mutable borrows conflicted). That felt awkward for a task as simple as adding a remote to the configuration. (In general when using thegix
API I kind of wish there was less borrowing and more refcounting/cloning, though I realize that there’s a subjective element to the trade‐off here and that you can wrap a borrow‐happy API in a clone‐happy one but not vice versa.)Relatedly, there’s this comment in the code:
That would be quite nice for us!
In general there’s more convoluted logic here in the move from
git2
togix
, but thankfully most of that is just dealing with lower‐level APIs that don’t bundle configuration changes, ref renames, etc. into one porcelain call. Other than the things listed above, the process went quite smoothly; thanks again for all your work!Checklist
If applicable:
CHANGELOG.md