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>
This commit is contained in:
parent
9f6976528b
commit
3f55ccab8e
31
connect.c
31
connect.c
@ -675,7 +675,7 @@ struct child_process *git_connect(int fd[2], const char *url,
|
|||||||
signal(SIGCHLD, SIG_DFL);
|
signal(SIGCHLD, SIG_DFL);
|
||||||
|
|
||||||
protocol = parse_connect_url(url, &hostandport, &path);
|
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: url=%s\n", url ? url : "NULL");
|
||||||
printf("Diag: protocol=%s\n", prot_name(protocol));
|
printf("Diag: protocol=%s\n", prot_name(protocol));
|
||||||
printf("Diag: hostandport=%s\n", hostandport ? hostandport : "NULL");
|
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);
|
get_host_and_port(&ssh_host, &port);
|
||||||
if (!port)
|
if (!port)
|
||||||
port = get_port(ssh_host);
|
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");
|
||||||
|
|
||||||
if (!ssh) ssh = "ssh";
|
free(hostandport);
|
||||||
|
free(path);
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
if (!ssh) ssh = "ssh";
|
||||||
|
|
||||||
argv_array_push(&conn->args, ssh);
|
argv_array_push(&conn->args, ssh);
|
||||||
if (putty && !strcasestr(ssh, "tortoiseplink"))
|
if (putty && !strcasestr(ssh, "tortoiseplink"))
|
||||||
argv_array_push(&conn->args, "-batch");
|
argv_array_push(&conn->args, "-batch");
|
||||||
if (port) {
|
if (port) {
|
||||||
/* P is for PuTTY, p is for OpenSSH */
|
/* P is for PuTTY, p is for OpenSSH */
|
||||||
argv_array_push(&conn->args, putty ? "-P" : "-p");
|
argv_array_push(&conn->args, putty ? "-P" : "-p");
|
||||||
argv_array_push(&conn->args, port);
|
argv_array_push(&conn->args, port);
|
||||||
|
}
|
||||||
|
argv_array_push(&conn->args, ssh_host);
|
||||||
}
|
}
|
||||||
argv_array_push(&conn->args, ssh_host);
|
|
||||||
} else {
|
} else {
|
||||||
/* remove repo-local variables from the environment */
|
/* remove repo-local variables from the environment */
|
||||||
conn->env = local_repo_env;
|
conn->env = local_repo_env;
|
||||||
|
@ -541,13 +541,30 @@ check_prot_path () {
|
|||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
}
|
}
|
||||||
|
|
||||||
check_prot_host_path () {
|
check_prot_host_port_path () {
|
||||||
cat >expected <<-EOF &&
|
local diagport
|
||||||
|
case "$2" in
|
||||||
|
*ssh*)
|
||||||
|
pp=ssh
|
||||||
|
uah=userandhost
|
||||||
|
ehost=$(echo $3 | tr -d "[]")
|
||||||
|
diagport="Diag: port=$4"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
pp=$p
|
||||||
|
uah=hostandport
|
||||||
|
ehost=$(echo $3$4 | sed -e "s/22$/:22/" -e "s/NONE//")
|
||||||
|
diagport=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cat >exp <<-EOF &&
|
||||||
Diag: url=$1
|
Diag: url=$1
|
||||||
Diag: protocol=$2
|
Diag: protocol=$pp
|
||||||
Diag: hostandport=$3
|
Diag: $uah=$ehost
|
||||||
Diag: path=$4
|
$diagport
|
||||||
|
Diag: path=$5
|
||||||
EOF
|
EOF
|
||||||
|
grep -v "^$" exp >expected
|
||||||
git fetch-pack --diag-url "$1" >actual &&
|
git fetch-pack --diag-url "$1" >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
}
|
}
|
||||||
@ -557,22 +574,20 @@ do
|
|||||||
# git or ssh with scheme
|
# git or ssh with scheme
|
||||||
for p in "ssh+git" "git+ssh" git ssh
|
for p in "ssh+git" "git+ssh" git ssh
|
||||||
do
|
do
|
||||||
for h in host host:12 [::1] [::1]:23
|
for h in host user@host user@[::1] user@::1
|
||||||
do
|
do
|
||||||
case "$p" in
|
|
||||||
*ssh*)
|
|
||||||
pp=ssh
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
pp=$p
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
test_expect_success "fetch-pack --diag-url $p://$h/$r" '
|
test_expect_success "fetch-pack --diag-url $p://$h/$r" '
|
||||||
check_prot_host_path $p://$h/$r $pp "$h" "/$r"
|
check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r"
|
||||||
'
|
'
|
||||||
# "/~" -> "~" conversion
|
# "/~" -> "~" conversion
|
||||||
test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
|
test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
|
||||||
check_prot_host_path $p://$h/~$r $pp "$h" "~$r"
|
check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r"
|
||||||
|
'
|
||||||
|
done
|
||||||
|
for h in host User@host User@[::1]
|
||||||
|
do
|
||||||
|
test_expect_success "fetch-pack --diag-url $p://$h:22/$r" '
|
||||||
|
check_prot_host_port_path $p://$h:22/$r $p "$h" 22 "/$r"
|
||||||
'
|
'
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -603,11 +618,11 @@ do
|
|||||||
for h in host [::1]
|
for h in host [::1]
|
||||||
do
|
do
|
||||||
test_expect_success "fetch-pack --diag-url $h:$r" '
|
test_expect_success "fetch-pack --diag-url $h:$r" '
|
||||||
check_prot_path $h:$r $p "$r"
|
check_prot_host_port_path $h:$r $p "$h" NONE "$r"
|
||||||
'
|
'
|
||||||
# Do "/~" -> "~" conversion
|
# Do "/~" -> "~" conversion
|
||||||
test_expect_success "fetch-pack --diag-url $h:/~$r" '
|
test_expect_success "fetch-pack --diag-url $h:/~$r" '
|
||||||
check_prot_host_path $h:/~$r $p "$h" "~$r"
|
check_prot_host_port_path $h:/~$r $p "$h" NONE "~$r"
|
||||||
'
|
'
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user