From: Junio C Hamano Date: Mon, 23 Mar 2015 18:23:12 +0000 (-0700) Subject: Merge branch 'tb/connect-ipv6-parse-fix' into maint X-Git-Tag: v2.3.4~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c2ea51254b41810edf4ee1ac8b2272a784b15df;p=thirdparty%2Fgit.git Merge branch 'tb/connect-ipv6-parse-fix' into maint We did not parse username followed by literal IPv6 address in SSH transport URLs, e.g. ssh://user@[2001:db8::1]:22/repo.git correctly. * tb/connect-ipv6-parse-fix: t5500: show user name and host in diag-url t5601: add more test cases for IPV6 connect.c: allow ssh://user@[2001:db8::1]/repo.git --- 8c2ea51254b41810edf4ee1ac8b2272a784b15df diff --cc connect.c index d50f52ad8b,84f8156a4c..ce0e121423 --- a/connect.c +++ b/connect.c @@@ -714,28 -717,31 +726,42 @@@ struct child_process *git_connect(int f char *ssh_host = hostandport; const char *port = NULL; get_host_and_port(&ssh_host, &port); - port = get_port_numeric(port); + - ssh = getenv("GIT_SSH_COMMAND"); - if (ssh) { - conn->use_shell = 1; - putty = 0; - } else { - ssh = getenv("GIT_SSH"); - if (!ssh) - ssh = "ssh"; - putty = !!strcasestr(ssh, "plink"); - } + if (!port) + port = get_port(ssh_host); ++ + if (flags & CONNECT_DIAG_URL) { + printf("Diag: url=%s\n", url ? url : "NULL"); + printf("Diag: protocol=%s\n", prot_name(protocol)); + printf("Diag: userandhost=%s\n", ssh_host ? ssh_host : "NULL"); + printf("Diag: port=%s\n", port ? port : "NONE"); + printf("Diag: path=%s\n", path ? path : "NULL"); - argv_array_push(&conn->args, ssh); - if (putty && !strcasestr(ssh, "tortoiseplink")) - argv_array_push(&conn->args, "-batch"); - if (port) { - /* P is for PuTTY, p is for OpenSSH */ - argv_array_push(&conn->args, putty ? "-P" : "-p"); - argv_array_push(&conn->args, port); + free(hostandport); + free(path); + return NULL; + } else { - if (!ssh) ssh = "ssh"; ++ ssh = getenv("GIT_SSH_COMMAND"); ++ if (ssh) { ++ conn->use_shell = 1; ++ putty = 0; ++ } else { ++ ssh = getenv("GIT_SSH"); ++ if (!ssh) ++ ssh = "ssh"; ++ putty = !!strcasestr(ssh, "plink"); ++ } + + argv_array_push(&conn->args, ssh); + if (putty && !strcasestr(ssh, "tortoiseplink")) + argv_array_push(&conn->args, "-batch"); + if (port) { + /* P is for PuTTY, p is for OpenSSH */ + argv_array_push(&conn->args, putty ? "-P" : "-p"); + argv_array_push(&conn->args, port); + } + argv_array_push(&conn->args, ssh_host); } - argv_array_push(&conn->args, ssh_host); } else { /* remove repo-local variables from the environment */ conn->env = local_repo_env;