git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] GIT: Support [address] in URLs

From
YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Date
Dec 21, 2005, 10:23 UTC
Message-ID
<20051221.192342.132228413.yoshfuji@linux-ipv6.org>
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
Next: Junio C Hamano
Message 1 of 13 in “GIT: Support [address] in URLs”
  1. GIT: Support [address] in URLsYOSHIFUJI Hideaki / 吉藤英明, Dec 21, 2005
  2. Junio C HamanoDec 21, 2005
  3. YOSHIFUJI Hideaki / 吉藤英明Dec 21, 2005
  4. Junio C HamanoDec 21, 2005
  5. YOSHIFUJI Hideaki / 吉藤英明Dec 21, 2005
  6. [OT] western cultural imperialism at vger?Junio C Hamano, Dec 21, 2005
  7. David S. MillerDec 21, 2005
  8. Krzysztof HalasaDec 21, 2005
  9. David S. MillerDec 21, 2005
  10. David S. MillerDec 21, 2005
  11. YOSHIFUJI Hideaki / 吉藤英明Dec 21, 2005
  12. David S. MillerDec 22, 2005
  13. Daniel BarkalowDec 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.