neithernut / git-dit

Decentralized Issue Tracking for git
Other
457 stars 18 forks source link

malformed URL error for git+ssh://user@host:/path/foo.git #186

Closed jan-matejka closed 5 years ago

jan-matejka commented 5 years ago
yac@remy % git init foo
Initialized empty Git repository in /home/yac/foo/.git/
yac@remy % cd foo
yac@remy % git remote add origin git+ssh://user@host:/path/foo.git
yac@remy % git dit fetch origin
malformed URL 'git+ssh://user@host:/path/foo.git'; class=Net (12); code=InvalidSpec (-12)
neithernut commented 5 years ago

Thanks for the report! Will investigate as soon as I'm back from work.

In the meantime you can add the following refspec line to the [remote "origin"] section of your local repos .git/config:

fetch = +refs/dit/*:refs/remotes/origin/dit/*

It will cause git to fetch the "dit" refs we use on a regular fetch.


Sidenote: we planned to add a "subscription" feature which adds that refspec to the config in a more user-friendly way.

jan-matejka commented 5 years ago

This looks like a workaround. Is this a workaround or something to help you debug? I am in the evaluation phase right now so I don't mind waiting a bit for fix. fyi I encountered this issue when trying a push. I used fetch in the example since it exhibits the same issue and is simpler to set up.

neithernut commented 5 years ago

This looks like a workaround. Is this a workaround or something to help you debug?

It's a workaround. Kinda. Actually, that's how I set up remotes for git-dit for myself. I think I never really used git dit push and git dit fetch, apart from testing its functionality.

neithernut commented 5 years ago

I can reproduce. The error apparently also occurs with other schemas (including ssh://). URLs like user@host:/path/foo.git appear to work fine, at least for ssh. I suspect this will take some time.

The error likely originates from libgit2. So far I've found three possible origins: in the ssh, git transports and in netopts.c. Interestingly, the only one setting the InvalidSpec error code appears to be the last one, but it could as well be set further up the stack.

neithernut commented 5 years ago

I just started investigating the issue some more. The error is emitted in netopts.c. Apparently http_parser_parse_url fails to parse the host (here) using http_parse_host. In there, everything works fine until we reach some sanity check. As we end up at the beginning of the "port" field, the check fails.

I'll report this upstream, but it will take a while until we benefit from a fix, since we have to wait for a git2-rs to pick up the fix/the next release. I'll leave this issue open until the changes have reached us.

A workaround is to use the schema-less form for ssh origins (e.g. user@host:/path/foo.git) or without the (empty) port (e,g, ssh://user@host/path/foo.git). Also note that using the ssh+git schema is generally discouraged.

neithernut commented 5 years ago

I just reported the issue upstream: libgit2/libgit2#5100

neithernut commented 5 years ago

The underlying issue was fixed in https://github.com/libgit2/libgit2, a fixed version was picked up by https://github.com/rust-lang/git2-rs (0.9.2 or later). A cargo update and rebuild should resolve the issue.

I can't test it right now due to other issues. However, I'll close this issue regardless. Please reopen if the issue persists.