summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>2005-12-21 19:23:42 +0900
committerLibravatar Junio C Hamano <junkio@cox.net>2005-12-21 23:48:56 -0800
commit356bece0a2725818191b12f6e991490d52baa1d1 (patch)
treef3d84dd3b9d7cba4621231ed3ce0cd9ad15f011d
parentwhatchanged: customize diff-tree output (diff)
downloadtgif-356bece0a2725818191b12f6e991490d52baa1d1.tar.xz
GIT: Support [address] in URLs
Allow IPv6address/IPvFuture enclosed by [] in URLs, like: git push '[3ffe:ffff:...:1]:GIT/git' or git push 'ssh://[3ffe:ffff:...:1]/GIT/git' Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--connect.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/connect.c b/connect.c
index 93f6f80d3e..6b6d6133a0 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)