问题
Git accepts a lot of different url formats (e.g. ssh, http, https etc). Are there any specifications/official docs where I can find the supported git url formats?
I wrote a git url parser and I want to be sure that what it's done there is correct.
Here, on YonderGit, I found the list below. It is not complete since https://<token>:x-oauth-basic@host.xz/path/to/repo.git
is not there.
Secure Shell Transport Protocol
ssh://user@host.xz:port/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz:port/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://user@host.xz/~user/path/to/repo.git/
ssh://host.xz/~user/path/to/repo.git/
ssh://user@host.xz/~/path/to/repo.git
ssh://host.xz/~/path/to/repo.git
user@host.xz:/path/to/repo.git/
host.xz:/path/to/repo.git/
user@host.xz:~user/path/to/repo.git/
host.xz:~user/path/to/repo.git/
user@host.xz:path/to/repo.git
host.xz:path/to/repo.git
rsync://host.xz/path/to/repo.git/
Git Transport Protocol
git://host.xz/path/to/repo.git/
git://host.xz/~user/path/to/repo.git/
HTTP/S Transport Protocol
http://host.xz/path/to/repo.git/
https://host.xz/path/to/repo.git/
Local (Filesystem) Transport Protocol
/path/to/repo.git/
path/to/repo.git/
~/path/to/repo.git
file:///path/to/repo.git/
file://~/path/to/repo.git/
回答1:
You can see what git is prepared to parse in urlmatch.h and urlmatch.c.
That is used by t0110-urlmatch-normalization.sh, which illustrates the full list of possible url tested by git.
url.c does mention:
The set of valid URL schemes, as per STD66 (RFC3986) is '
[A-Za-z][A-Za-z0-9+.-]*
'.
But use sightly looser check of '[A-Za-z0-9][A-Za-z0-9+.-]*
' because earlier version of check used '[A-Za-z0-9]+
' so not to break any remote helpers.
来源:https://stackoverflow.com/questions/31801271/what-are-the-supported-git-url-formats