summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2016-06-05 13:09:53 +0200
committerJunio C Hamano <gitster@pobox.com>2016-06-06 11:01:39 -0700
commit052b49d560e9cd2f8bf9842437802ff2fab96556 (patch)
tree789bb5ce20775f6f518eee4a1c50abfbe7811076
parentf0e238651d25962ba89417c678aa12d932e437e7 (diff)
downloadgit-mh/connect.tar.gz
connect: [host:port] is legacy for sshmh/connect
Early versions of the parser in connect.c treated these two as the same: git clone [host:123]:/path git clone ssh://host:123/path Keep that feature as legacy, but disable it for all other protocols. Everything inside [] should go into the host part. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--connect.c11
-rwxr-xr-xt/t5500-fetch-pack.sh17
2 files changed, 21 insertions, 7 deletions
diff --git a/connect.c b/connect.c
index 076ae091a8..9576d0f511 100644
--- a/connect.c
+++ b/connect.c
@@ -618,10 +618,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_user,
}
}
- /*
- * Don't do destructive transforms as protocol code does
- * '[]' unwrapping in get_host_and_port()
- */
+ /* '[]' unwrapping is done in get_host_and_port() */
end = host_end(&host, 0);
if (protocol == PROTO_LOCAL)
@@ -670,10 +667,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_user,
/*
* get_host_and_port does not return a port in the [host:port]:path
* case. In that case, it is called with "[host:port]" and returns
- * "host:port" and NULL.
- * To support this undocumented legacy we still need to split the port.
+ * "host:port" and NULL. To support this undocumented legacy
+ * (for ssh only) we still need to split the port.
*/
- if (!port)
+ if (!port && protocol == PROTO_SSH)
port = get_port(host);
*ret_user = user ? xstrdup(user) : NULL;
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 2d9c4beaaa..b7d21da037 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -618,6 +618,23 @@ do
'
done
done
+ # git with scheme and []
+ for p in git
+ do
+ for h in [host:123]
+ do
+ for c in "" :
+ do
+ test_expect_success "fetch-pack --diag-url $p://$h$c/$r" '
+ check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r"
+ '
+ # "/~" -> "~" conversion
+ test_expect_success "fetch-pack --diag-url $p://$h$c/~$r" '
+ check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r"
+ '
+ done
+ done
+ done
# file with scheme
for p in file
do