[PATCH] GIT: Support [address] in URLs

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <junkio@...>
Cc: <git@...>, <yoshfuji@...>
Date: Wednesday, December 21, 2005 - 6:23 am

Hello.

Allow address 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>

diff --git a/connect.c b/connect.c
index 93f6f80..49f93c6 100644
--- a/connect.c
+++ b/connect.c
@@ -561,7 +561,8 @@ int git_connect(int fd[2], char *url, co
 {
 	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,26 @@ int git_connect(int fd[2], char *url, co
 		*host = '\0';
 		protocol = get_protocol(url);
 		host += 3;
-		path = strchr(host, '/');
-	}
-	else {
+		c = '/';
+	} else {
 		host = url;
-		if ((colon = strchr(host, ':'))) {
-			protocol = PROTO_SSH;
-			*colon = '\0';
-			path = colon + 1;
-		}
+		c = ':';
+	}
+
+	if (host[0] == '[') {
+		end = strchr(host + 1, ']');
+		if (end) {
+			*end = 0;
+			end++;
+			host++;
+		} else
+			end = host;
+	} else
+		end = host;
+
+	if ((path = strchr(end, c)) && c == ':') {
+		protocol = PROTO_SSH;
+		*path++ = '\0';
 	}
 
 	if (!path || !*path)

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] GIT: Support [address] in URLs, YOSHIFUJI Hideaki / , (Wed Dec 21, 6:23 am)
Re: [PATCH] GIT: Support [address] in URLs, Junio C Hamano, (Wed Dec 21, 6:16 pm)