Repository navigation
Accept raw remote URLs as valid - #1085
epriestley wants to merge 1 commit into
Conversation
Fixes issue git-lfs#1069. Currently, `git-lfs` operations only work on named remotes, but the equivalent `git` operations accept raw remote URLs. Accept remote URLs in lieu of named remotes if no named remote matches the argument.
|
From #306, #295, etc., maybe I didn't dig deep enough into the test suite and This issue is also probably adjacent to #295, at least, and maybe a few other things -- I can fish through issues and see what else I can dig up, this just seemed like the kind of thing that might be stepping into "major infrastructure change" territory so I didn't want to dig too deep if this going to snowball into more serious spelunking than I'm currently equipped to handle. |
|
Awesome. Definitely want some test coverage. The shell tests do setup a git server with an https endpoint that can be used. This should test both a remote that is named in
I don't want to use What do you think about attempting to look up the remote name for a URL? If the URL has a remote name, continue passing It may be worth creating a function that returns a Could even cache it in |
|
Cool, I'll see about getting proper coverage.
It can't ever find any descendants of the current HEAD, can it (or if it somehow does, we don't need to push the file data)? The remote could be ahead chronologically, but it can't be ahead ahead unless something terrible happened and all bets are already off anyway (like someone pushed with We (a code review tool called Phabricator) have an unusual situation where we sometimes push unreviewed code into a "staging area" remote which is mostly hidden from the user, identified only by URL, and never fetched, so the local repository will never know about most of the refs in it (and will know about none of the refs on the first push). This is unusual and you may not want to support it, but in our case there is never a named remote and the local repository will rarely have much information about refs present in the remote. I'm not sure how common this is, although I'd imagine that if a push is using a raw URL, it's probably because there isn't a named local remote at least some of the time? But maybe there are situations where other tools pre-resolve the remote and drop the symbolic name for it, but it's still fundamentally |
|
For small repositories it's also believable that |
Oh, sorry, I misunderstood this at first until I read the message in f3bf4ea. The issue is not that a ref ahead of us is wrong, just that it's useless, since I'm going to do a little more digging but don't have a better approach to suggest than the one you outline. |
|
After some digging: #144 has some discussion on the "what do we list to push" issue. I think that issue is actually resolved in #798, #278, and #295 are possibly adjacent. It looks like there may be some peril with host aliases if we try to guess which named remote corresponds to a URL, but that's fine. #693 is a vaguely related peril with #431 and #436 have some cases with multiple remotes which LFS can't reasonably have perfect behavior on, which likely represent limits to how much we can possibly get right here. I think #580 is another copy of these. #930 is another one, although some users also reported the SSH aliases bug there. #1053 is approximately related. So I think this is a maybe-reasonable way to break this down:
|
| } | ||
|
|
||
| switch u.Scheme { | ||
| case "ssh", "http", "https", "git": |
There was a problem hiding this comment.
Will this honor pushInsteadOf ?
There was a problem hiding this comment.
Nope, but I think that'd be worthy of a separate pull request.
|
Dang, what did I do??? The GitHub Platform team uses Marvel Comic characters in their media types. Since I'm a big comic nerd, they ping me on all new features to "approve" them. I approved one in this PR for some reason. |
|
I just commented here that I've moved this to the "nice to have" list for v1.2. However, I wouldn't mind shipping this mostly as-is, with more testing:
I personally agree with this notion:
Having a command that works, but attempts to upload too many objects seems preferable to it not working at all. |
| return u | ||
| } | ||
|
|
||
| err := git.ValidateRemoteURL(remote) |
There was a problem hiding this comment.
Could be usefull to convert err := git.ValidateRemoteURL in remote, err := git.NormalizeRemoteURL. If the user clones an url with a trailing /, es git clone https://github/repo.git/ the NewEndpointFromCloneURLWithConfig [1] adds an unwanted repo.git/.git/info/lfs layer to the Endpoint that should be repo.git/info/lfs
|
I'm currently working on integrating git-lfs into Gerrit repo tool, and I'm facing the same issue, because repo has an automatic fallback mechanism for ssh to https, in case the git push over ssh is failing. For that reason, repo is not using the remote name in the git push command, but the full url instead. I'm not sure to fully understand the plan for fixing that issue, but just wanted to let you know that it's preventing the integration of git-lfs into repo. I'm available for helping in writing some unit tests if needed. |
|
I re-applied @epriestley's commit against master in #1451. I also added some basic tests for |
|
@technoweenie Why did you close this PR? The issue it fixes is still not fixed: #1069. |
|
I closed it because the fix was applied in #1451. I confirmed that the issue is fixed just now too. Please open a new issue with details if you're still having problems. |

Fixes issue #1069, sort of, in theory. This is likely more of a starting point. Major issues:
Overview:
This treats any "ssh", "http", "https", "git" or protocol-free-with-a-colon-in-it remote name as a valid raw remote URL.
I'm not sure how to effectively test this, because it seems difficult to stub/simulate any of these protocols locally, and
git-lfswon't work withfile://, etc. Existing tests pass locally, and the existing test to verify thatgit-lfs push not-a-remoteencounters an error passes (this is correctly detected as not being a valid remote).I manually tested positive cases with, e.g.:
One possible issue is that this causes this
rev-listcommand to execute:gitruns this, but it fails to exclude anything and lists every object in the repository.A better strategy might be:
git ls-remote <url>instead.--notinstead of--remote <remote>.I can pursue this refinement, but didn't want to get too far into things if I'm on the wrong track.