What are the supported git url formats?

别来无恙 提交于 2020-07-17 08:06:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!