Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support for ssh+git and git+ssh protocols #3555

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

Merged
merged 7 commits into from
Mar 8, 2016

Conversation

cbargren
Copy link
Contributor

This should add support for the ssh+git:// and git+ssh:// protocol schemes. The behavior is to pass directly through to the ssh:// protocol scheme.

So, as atrocious as this is, this is a protocol that people use. From everything I can tell, they're both functionally identical to ssh:// and are treated as such in this PR. Here is an example of it being used in the linux kernel git core

@cbargren cbargren changed the title [WIP] Support for ssh+git and git+ssh protocols Support for ssh+git and git+ssh protocols Dec 22, 2015
@johnhaley81
Copy link
Contributor

I'd like to see this backported to maint/v0.23 if possible.

@carlosmn
Copy link
Member

These aren't documented by git to be acceptable formats in its list of URLs in man git-clone.

Additionally, I really don't like having to change external code; this especially true for the HTTP parser since we may not use our copy so this won't be supported if it's installed on the system.

@cbargren
Copy link
Contributor Author

Hm... While they're not documented as acceptable formats, they're both supported in the git CLI. I'm having a really hard time finding out why people use this format in the first place (any amount of searching turns up basically no documentation on the format), but for whatever reason, they do and it works in the CLI so I figured that libgit2 should support it as well.

The HTTP parser is definitely something that I missed as being an external dependancy. I can attempt to PR that change upstream as it is probably something that should be supported by them. It is a part of the URI Scheme Spec. Is libgit2's version pulled from https://github.com/nodejs/http-parser?

@carlosmn
Copy link
Member

People probably use it because Subversion uses svn+ssh, which doesn't make it a good idea to support; I don't know of any place which advertises its Git URLs this way. And, again, it's not something that's specified to work.

Anything under deps/ is not our code, but stuff we need, typically on Windows. The parser is indeed the nodejs one (though I think we grabbed the code from Ryan directly back in the day).

@johnhaley81
Copy link
Contributor

Hey @carlosmn. I can't disagree with wrt it being not documented but the issue does remain that there are users that have their urls formatted like this and that git-core does support this. The commit that implements it in git-core does even say that it's stupid syntax.

The bigger issue and sticking point is that there is no current way to work around this issue either. In 0.22 and below you could modify the remote url in memory so a consumer of this library could intercept a url like this and reformat it into a more sane syntax. Now in 0.23+ you'd have to load a remote, mutate its url to something more sane, save it to disk, reload the remote, mutate its url back to the craziness, and then use the remote loaded off of disk to do an operation.

This seems pretty bad to me especially if you are changing a users repo in order to support a feature that they already have working in git-core.

If you aren't open to explicitly supporting this in the library would you be more open to allowing a mutation of remote urls in memory again? Or some other way to work around this issue?

@cbargren
Copy link
Contributor Author

PR for the http-parser: nodejs/http-parser#276

@ethomson
Copy link
Member

Wow, I didn't know that anybody used git+ssh or ssh+git, and am dismayed to learn about it. That said, I think that supporting this the correct thing to do.

Would you mind updating your PR to include support for - and . as well, per the changes in nodejs/http-parser#276.

Additionally, I made some nitpicky comments about style - if you wouldn't mind addressing those since you're already in there. Thanks!

@@ -35,6 +35,8 @@ static transport_definition transports[] = {
{ "file://", git_transport_local, NULL },
#ifdef GIT_SSH
{ "ssh://", git_transport_smart, &ssh_subtransport_definition },
{ "ssh+git://", git_transport_smart, &ssh_subtransport_definition },
{ "git+ssh://", git_transport_smart, &ssh_subtransport_definition },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this (and the line above) a tab not spaces?

@cbargren
Copy link
Contributor Author

@ethomson Wow, great feedback, thanks! I too was disappointed to hear that people are using git+ssh and ssh+git... Seems like a weird schema to use and they add nothing to functionality on top of already existing schemas. 🤷 What can you do... I've addressed all of your comments now. Let me know if there's anything else needed. Thanks again!

Also moving var declarations to top of blocks to support bad old compilers
…nsport

ssh, ssh+git and git+ssh should all successfully build an SSH transport
@cbargren
Copy link
Contributor Author

cbargren commented Jan 8, 2016

Is there anything else you guys need for this before pulling it in?

@cbargren
Copy link
Contributor Author

@ethomson @carlosmn Hey, sorry to be a bother but I haven't heard anything from you guys after your feedback. Is there anything else you needed for this PR?

@ethomson
Copy link
Member

Hi! Terribly sorry - a bunch of us are coincidentally on vacation right now. I'm just getting back to having internet; I'll take a look at this soon! Thanks for your help and your patience!

@cbargren
Copy link
Contributor Author

Cool, thanks for the reply!

@ethomson
Copy link
Member

ethomson commented Feb 5, 2016

So I think that Carlos wanted to double-check with the Git mailing list and either document this in git.git or remove this behavior from git.git. But if the latter, and Git removes this behavior (and I don't think that they will) then we should not merge this. So let's just make sure that this is the right thing to do.

/cc @carlosmn

@carlosmn
Copy link
Member

The consensus from the list is that these were a bad idea and they never should have done it, but git has to support them for backwards compatibility.

Which means we'll have to support it too; it won't be the first bad idea we do.

@johnhaley81
Copy link
Contributor

Is there anything else that needs to be done to finish this up?

@ethomson
Copy link
Member

ethomson commented Mar 8, 2016

Thanks for the contribution! :)

ethomson pushed a commit that referenced this pull request Mar 8, 2016
Support for ssh+git and git+ssh protocols
@ethomson ethomson merged commit b7809b8 into libgit2:master Mar 8, 2016
@cbargren cbargren deleted the ssh-git-protocols branch March 25, 2016 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants