X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=connect.c;h=6b6d6133a0ad943c3b6018541a656a66833b85d2;hb=c06818e20a88f58294de0a948a437c7c32c382fe;hp=93f6f80d3e8c5f1592353b6feadb9de2c768b649;hpb=069b20a198f171512a1d2d2163b40f70c94f5257;p=git.git diff --git a/connect.c b/connect.c index 93f6f80d..6b6d6133 100644 --- a/connect.c +++ b/connect.c @@ -561,7 +561,8 @@ int git_connect(int fd[2], char *url, const char *prog) { char command[1024]; char *host, *path = url; - char *colon = NULL; + char *end; + int c; int pipefd[2][2]; pid_t pid; enum protocol protocol = PROTO_LOCAL; @@ -571,15 +572,30 @@ int git_connect(int fd[2], char *url, const char *prog) *host = '\0'; protocol = get_protocol(url); host += 3; - path = strchr(host, '/'); - } - else { + c = '/'; + } else { host = url; - if ((colon = strchr(host, ':'))) { + c = ':'; + } + + if (host[0] == '[') { + end = strchr(host + 1, ']'); + if (end) { + *end = 0; + end++; + host++; + } else + end = host; + } else + end = host; + + path = strchr(end, c); + if (c == ':') { + if (path) { protocol = PROTO_SSH; - *colon = '\0'; - path = colon + 1; - } + *path++ = '\0'; + } else + path = host; } if (!path || !*path)