git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] GIT: Support [address] in URLs
@ 2005-12-21 10:23 YOSHIFUJI Hideaki / 吉藤英明
  2005-12-21 22:16 ` Junio C Hamano
       [not found] ` <7vr7866uww.fsf@assigned-by-dhcp.cox.net>
  0 siblings, 2 replies; 13+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2005-12-21 10:23 UTC (permalink / raw)
  To: junkio; +Cc: git, yoshfuji

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-12-22 16:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-21 10:23 [PATCH] GIT: Support [address] in URLs YOSHIFUJI Hideaki / 吉藤英明
2005-12-21 22:16 ` Junio C Hamano
     [not found] ` <7vr7866uww.fsf@assigned-by-dhcp.cox.net>
2005-12-21 22:20   ` YOSHIFUJI Hideaki / 吉藤英明
     [not found]     ` <7v1x065blx.fsf@assigned-by-dhcp.cox.net>
2005-12-21 23:03       ` Junio C Hamano
     [not found]       ` <7v3bkm3vw4.fsf@assigned-by-dhcp.cox.net>
2005-12-21 23:08         ` YOSHIFUJI Hideaki / 吉藤英明
2005-12-21 23:24           ` [OT] western cultural imperialism at vger? Junio C Hamano
2005-12-21 23:29             ` David S. Miller
2005-12-21 23:38             ` Krzysztof Halasa
2005-12-21 23:46               ` David S. Miller
2005-12-21 23:26           ` [PATCH] GIT: Support [address] in URLs David S. Miller
2005-12-21 23:59             ` YOSHIFUJI Hideaki / 吉藤英明
2005-12-22  0:08               ` David S. Miller
2005-12-22 16:48             ` Daniel Barkalow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).