[PATCH v1 1/1] connect: [host:port] is lagacy for ssh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Torsten Bögershausen <tboegi@xxxxxx>

Early versions of the parser in connect.c handled
git clone [host:123]:/path the same as
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@xxxxxx>
---

This is my attempt to keep the legacy for ssh only,
and fixes my comments
 connect.c             | 11 ++++-------
 t/t5500-fetch-pack.sh | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/connect.c b/connect.c
index 076ae09..9576d0f 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 2d9c4be..b7d21da 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
-- 
2.0.0.rc1.6318.g0c2c796

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]