-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Remote URL last-chance resolution #5062
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
b8e1b76
to
bcac837
Compare
bcac837
to
f154cd3
Compare
Rebased, with the unneeded ➰ allocator removed. Most of the code from #5056 has thus been restored. If that's even possible, it would be nice to have this one in quickly: any new contribution that touches one of our structs is going to have to do something like this (and some are pesky). The sooner this happens, the easier it gets for contributors. Maybe. That's how I felt when I noticed the change in #5056. I've tried to take into account some of the ideas from the other backward-compatibility PR (git_refdb_backend?), but this one is simpler, thus I don't think it's sufficient I'll try to revisit the other one, though, in case it's not). It's missing documentation which I'd like to add before this goes in, but a first review round seemed like a good idea. |
I don't understand why you're incrementing the struct version here? You're adding a field, that's not an API breaking change? |
include/git2/remote.h
Outdated
* | ||
* You need to be careful not to overflow url_resolved. If it's too small, | ||
* returning a positive value equal to the size required will cause the | ||
* resolution to be tried again with a buffer of the requested size. |
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.
Is this comment accurate? I don't see this behavior.
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.
Oops, a leftover from the old way, before I re-read buffer.h. Please disregard.
It's binary-breaking because if I get a old v1 struct without the member and try to access it as a new, we'll read some stack data. Hence the bump. I don't think there's a way around, is it? |
Yes, this breaks ABI but not API. We've never tried to be ABI-consistent. It's a noble goal that we should pursue but let's drop those two commits for now and get this merged so we can 🚢. We do need a strategy for coping with API breaking struct changes, which it seems like this aligns to as well. So let's split those two commits out into a new PR. I suspect that there's going to be a few subtle nuances to struct compatibility that we should spend some time to 🤔 about. |
f154cd3
to
12d9940
Compare
Rebased, I've removed the updater and will refile as needed. |
12d9940
to
c7bcb8b
Compare
c7bcb8b
to
33e42d4
Compare
include/git2/remote.h
Outdated
* Resolve URL before connecting to remote. | ||
* The returned URL will be used to connect to the remote instead. | ||
*/ | ||
git_resolve_url_cb resolve_url; |
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.
I'd like this to be git_url_resolve_cb
, since that sounds more like something that acts on (resolves) an object (url) instead of something that urls a resolve.
I'm otherwise 👍 on this, so I'm happy to make this change and merge it though to get this unblocked if you're busy.
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.
I think it sounds weird in any order, so I renamed. A few weeks later, I have the feeling it could be provided as some kind of "proxying" internal transport, but maybe that's too much (that would make this use case go through the already existing custom transport callback just above this one).
33e42d4
to
daa7883
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.
I'm happy with this PR, thanks! @ethomson, you good with this, too?
GIT_UNUSED(url_resolved); | ||
GIT_UNUSED(url); | ||
GIT_UNUSED(direction); | ||
GIT_UNUSED(payload); |
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.
Sometimes I wish we'd be allowed to use variadic macros. Would make such unused blocks at least a tad less awful
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.
I've recently learnt that there's an __attribute__((unused))
that does the same thing, also available as __unused
(for nicer declarations). These can go on parameters, and GCC and Clang looks to be fine with it. Just my 2¢.
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.
Yeah, I've used them in my own projects, too. I'm not sure whether I like those more, though.
ping. merge? |
Yep, this looks good to me. @tiennou can you remove that unused assignment to |
daa7883
to
f7d646a
Compare
Since libssh2 doesn't read host configuration from the config file, this callback can be used to hand over URL resolving to the client without touching the SSH implementation itself.
f7d646a
to
59647e1
Compare
This is #5056, in 3 commits:
git_remote_callbacks
to change the URL before the connection is made.