Repository navigation
lfsapi: handle SSH hostnames and aliases without users - #3230
Merged
Merged
Conversation
bk2204
force-pushed
the
ssh-shorthands
branch
from
September 5, 2018 21:46
c782c3b to
51c05e0
Compare
Contributor
Thanks also for the detailed walkthrough of what's going on and how the changes works. I've always been somewhat wary of changing this part of the code, so your detailed message helped me build confidence that my understanding was correct. |
It's very common for a user to specify an SSH remote that refers to an alias in their gitconfig file. For example, if a user must use different SSH keys when pushing to different remotes, setting different aliases that use those different keys is the simplest and easiest way to accomplish that goal. Unfortunately, our parsing logic was broken for SSH remotes that used bare SSH URLs (that is, without “ssh://”) with a hostname or alias, but without a username component. The URL parser we used saw the hostname portion as the scheme of a URL, and we passed through any URLs with unknown schemes. This led to a failure to push, since we misparsed the URL as a non-SSH URL and gave up when it also didn't look like an HTTP(S) URL. If we get an unknown “scheme” when parsing a URL, check if the URL uses a remote helper (that is, it contains a double colon), and pass it through. Otherwise, do what Git does, and assume the URL is in fact an SSH URL, and handle it accordingly. We already handle the url.insteadof syntax properly, even if it looks like a scheme. Add tests that we continue to do so, and for the new code and all the various permutations mentioned above, and update the existing integration test to reflect our new parsing strategy.
bk2204
force-pushed
the
ssh-shorthands
branch
from
September 6, 2018 14:53
51c05e0 to
f137f45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's very common for a user to specify an SSH remote that refers to an
alias in their gitconfig file. For example, if a user must use
different SSH keys when pushing to different remotes, setting different
aliases that use those different keys is the simplest and easiest way to
accomplish that goal.
Unfortunately, our parsing logic was broken for SSH remotes that used
bare SSH URLs (that is, without “ssh://”) with a hostname or alias, but
without a username component. The URL parser we used saw the hostname
portion as the scheme of a URL, and we passed through any URLs with
unknown schemes. This led to a failure to push, since we misparsed the
URL as a non-SSH URL and gave up when it also didn't look like an
HTTP(S) URL.
If we get an unknown “scheme” when parsing a URL, check if the URL uses a
remote helper (that is, it contains a double colon), and pass it
through. Otherwise, do what Git does, and assume the URL is in fact an
SSH URL, and handle it accordingly.
We already handle the url.insteadof syntax properly, even if it looks
like a scheme. Add tests that we continue to do so, and for the new
code and all the various permutations mentioned above.
This should fix #278 and also fix #2842.