Skip to content

Commit 052b49d

Browse files
tboegigitster
authored andcommitted
connect: [host:port] is legacy for ssh
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0e2386 commit 052b49d

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

connect.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_user,
618618
}
619619
}
620620

621-
/*
622-
* Don't do destructive transforms as protocol code does
623-
* '[]' unwrapping in get_host_and_port()
624-
*/
621+
/* '[]' unwrapping is done in get_host_and_port() */
625622
end = host_end(&host, 0);
626623

627624
if (protocol == PROTO_LOCAL)
@@ -670,10 +667,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_user,
670667
/*
671668
* get_host_and_port does not return a port in the [host:port]:path
672669
* case. In that case, it is called with "[host:port]" and returns
673-
* "host:port" and NULL.
674-
* To support this undocumented legacy we still need to split the port.
670+
* "host:port" and NULL. To support this undocumented legacy
671+
* (for ssh only) we still need to split the port.
675672
*/
676-
if (!port)
673+
if (!port && protocol == PROTO_SSH)
677674
port = get_port(host);
678675

679676
*ret_user = user ? xstrdup(user) : NULL;

t/t5500-fetch-pack.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,23 @@ do
618618
'
619619
done
620620
done
621+
# git with scheme and []
622+
for p in git
623+
do
624+
for h in [host:123]
625+
do
626+
for c in "" :
627+
do
628+
test_expect_success "fetch-pack --diag-url $p://$h$c/$r" '
629+
check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r"
630+
'
631+
# "/~" -> "~" conversion
632+
test_expect_success "fetch-pack --diag-url $p://$h$c/~$r" '
633+
check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r"
634+
'
635+
done
636+
done
637+
done
621638
# file with scheme
622639
for p in file
623640
do

0 commit comments

Comments
 (0)