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>
YOSHIFUJI Hideaki / 吉藤英明 committed
Dec 21, 2005 at 19:23 UTC
356bece0a2725818191b12f6e991490d52baa1d1
1 file changed
+24
-8
connect.c
+24
-8
@@ -561,7 +561,8 @@ int git_connect(int fd[2], char *url, const char *prog)
561
{
562
char command[1024];
563
char *host, *path = url;
564
- char *colon = NULL;
564
+ char *end;
565
+ int c;
566
int pipefd[2][2];
567
pid_t pid;
568
enum protocol protocol = PROTO_LOCAL;
@@ -571,15 +572,30 @@ int git_connect(int fd[2], char *url, const char *prog)
572
*host = '\0';
573
protocol = get_protocol(url);
574
host += 3;
574
- path = strchr(host, '/');
575
- }
576
- else {
575
+ c = '/';
576
+ } else {
577
host = url;
578
- if ((colon = strchr(host, ':'))) {
578
+ c = ':';
579
+ }
580
+
581
+ if (host[0] == '[') {
582
+ end = strchr(host + 1, ']');
583
+ if (end) {
584
+ *end = 0;
585
+ end++;
586
+ host++;
587
+ } else
588
+ end = host;
589
+ } else
590
+ end = host;
591
+
592
+ path = strchr(end, c);
593
+ if (c == ':') {
594
+ if (path) {
595
protocol = PROTO_SSH;
580
- *colon = '\0';
581
- path = colon + 1;
582
- }
596
+ *path++ = '\0';
597
+ } else
598
+ path = host;
599
}
600
601
if (!path || !*path)