Fossil Forum

chungy 2 months, 3 weeks ago

Post: /urllist page errors out with a ssh-based git remote

In a few repositories that I have set up a git export on, I have set the --autopush value to include a short ssh hostname for.

Eg, in ~/.ssh/config I have:

Host gh
HostName github.com
User git

This allows me to use URLs for git clone (or push, or fetch...) in the form of gh:user/repository.

With fossil git export --autopush gh:user/repository, I am able to use this same style of URL for synchronizing a Fossil repository to GitHub. This works fine and well, except for the /urllist page, which causes a yellow screen, a 400 HTTP response, and the message "unknown repository: gh:user/repository".

It looks to me like the function url_parse_local() in url.c doesn't know how to recognize it as a valid URL and eventually fossil_fatal is called, making the whole thing crash out. From what I'm seeing in the code, I believe it will fail also with the more common [email protected]:user/repository format of URL too, but I haven't tested that.

It looks also that in stat.c, there's an attempt to convert these into hyperlinks. Perhaps these unresolveable links should just be displayed as plain-text. The Fossil git export works because it just calls the system's git push commands and git can take care of URL parsing from that point.

andybradford 2 months, 3 weeks ago

Have you tried using the full URL form of "ssh://gh:user/repository"

fossil git export --autopush ssh://gh:user/repository

One could argue that there may be a bug in the "git export" command in that it is not rejecting the URL that you give it when it doesn't have a scheme/protocol. Yes, it is blindly passing it to the "git push" command, but should it?

chungy 2 months, 3 weeks ago

I didn't consider using that form of URL. It does seem to change the behavior of the /urllist page, but there is a new error: “url missing '/' after port number”

It doesn't like the “:user” part :) Z c9769

andybradford 2 months, 3 weeks ago

It doesn't like the “:user” part

Of course, I failed to understand what you were trying to do here. Perhaps what you really want is:

fossil git export --autopush ssh://gh/user/repository

Does that work? Z 3

chungy 2 months, 3 weeks ago

No, that would not work. It transitions the server call into beginning at the root rather than the git user's home directory.

This is pretty standard SSH syntax: [host]:[path]

andybradford 2 months, 3 weeks ago

No, that would not work.

Did you try it?

As for should it work, that kind of depends I suppose on interpretation.

When you're using any of the SSH URL schemes, "scp://", "sftp://", and arguably "ssh://" relative vs absolute takes on a different meaning. Observe:

$ ls /tmp/test.txt /tmp/test.txt

$ sftp sftp://localhost/tmp/test.txt Connected to localhost. File "/home/user/tmp/test.txt" not found. Connection closed.

Notice that it did NOT treat "tmp/test.txt" as absolute path beginning at / but instead interpreted it as a relative path starting in my user's home directory. To get an absolute path using the sftp:// scheme, one must use 2 slashes:

$ sftp sftp://localhost//tmp/test.txt Connected to localhost. Fetching /tmp/test.txt to test.txt Connection closed.

Also, if I put :user in the sftp:// URL it behaves the same way that Fossil does:

$ sftp sftp://localhost:user/tmp/test.txt usage: sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher] ... $ sftp sftp://localhost:1234/tmp/test.txt ssh: connect to host localhost port 1234: Connection refused Connection closed

scp behaves in a similar way:

Relative path: $ scp scp://localhost/tmp/junk.txt /tmp/other.txt scp: tmp/junk.txt: No such file or directory

Absolute path: $ scp scp://localhost//tmp/junk.txt /tmp/other.txt junk.txt 100% 292 206.3KB/s 00:00

Colon in URL: $ scp scp://localhost:tmp/junk.txt /tmp/other.txt
scp://localhost:tmp/junk.txt: invalid uri

I would expect ssh:// to also have similar interpretation, that's how Fossil interprets SSH URLs for example and I think Fossil's interpretation is consistent with both sftp and scp. Apparently Git decided to do things differently for the ssh:// scheme and I would argue that Git is doing it wrong if it treats ssh://localhost/tmp/repo.git as an absolute path or treats :user relative path in ssh://localhost:user/repo.git

Also, how indeed would Git's interpretation allow for different ports to be specified in the URL?

The git-clone man page lists:

 o   ssh://[<user>@]<host>[:<port>]/<path-to-git-repo>

 The ssh and git protocols additionally support ~<username> expansion:

 o   ssh://[<user>@]<host>[:<port>]/~<user>/<path-to-git-repo>

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button