Skip to contentSkip to conversation

t5500: Show user name and host in diag-url

PATCH Superseded Torsten Bögershausen 1 participant 1 message Jun 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 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

---
 connect.c             | 35 +++++++++++++++++++++++------------
 t/t5500-fetch-pack.sh | 51 +++++++++++++++++++++++++++++++++------------------
 2 files changed, 56 insertions(+), 30 deletions(-)
connect.c +23 -12
index b608976..84f8156 100644
@@ -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;
t/t5500-fetch-pack.sh +33 -18

79 lines not on this page · raw message

Signature · 1 line
2.2.0.rc1.26.g3e3a70d