diff options
author | Torsten Bögershausen <tboegi@web.de> | 2015-02-21 16:52:55 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-02-22 12:04:01 -0800 |
commit | 3f55ccab8e0fec73c8e38b909e9bb4963bfb8f6a (patch) | |
tree | 97b620c4487f3f9c71e64de02067d8e6d268cd12 /connect.c | |
parent | 9f6976528b31356ee522d04aa31b86a3ba922f99 (diff) | |
download | git-3f55ccab8e0fec73c8e38b909e9bb4963bfb8f6a.tar.gz |
t5500: show user name and host in diag-url
The URL for ssh may have include a username before the hostname,
like ssh://user@host/repo.
When literal IPV6 addresses are used together with a username,
the substring "user@[::1]" must be converted into "user@::1".
Make that conversion visible for the user, and write userandhost
in the diagnostics
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -675,7 +675,7 @@ struct child_process *git_connect(int fd[2], const char *url, signal(SIGCHLD, SIG_DFL); protocol = parse_connect_url(url, &hostandport, &path); - if (flags & CONNECT_DIAG_URL) { + if ((flags & CONNECT_DIAG_URL) && (protocol != PROTO_SSH)) { printf("Diag: url=%s\n", url ? url : "NULL"); printf("Diag: protocol=%s\n", prot_name(protocol)); printf("Diag: hostandport=%s\n", hostandport ? hostandport : "NULL"); @@ -719,18 +719,29 @@ struct child_process *git_connect(int fd[2], const char *url, get_host_and_port(&ssh_host, &port); if (!port) port = get_port(ssh_host); - - if (!ssh) ssh = "ssh"; - - 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); + 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"); + + free(hostandport); + free(path); + return NULL; + } else { + if (!ssh) ssh = "ssh"; + + 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; |