git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
tboegi@web.de <tboegi@web.de>
Date
Jun 5, 2016, 11:09 UTC
Message-ID
<1465124993-3379-1-git-send-email-tboegi@web.de>
In-Reply-To
<xmqqinxozzuj.fsf@gitster.mtv.corp.google.com>
From: Torsten Bögershausen <tboegi@web.de>

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@web.de>
---
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
Previous: Torsten BögershausenNext: Eric Sunshine
Message 12 of 13 in “What's cooking in git.git (Jun 2016, #01; Thu, 2)”
  1. Junio C HamanoJun 2, 2016
  2. Mike HommeyJun 2, 2016
  3. Torsten BögershausenJun 3, 2016
  4. Junio C HamanoJun 3, 2016
  5. Mike HommeyJun 3, 2016
  6. Junio C HamanoJun 3, 2016
  7. Mike HommeyJun 4, 2016
  8. Torsten BögershausenJun 4, 2016
  9. Mike HommeyJun 4, 2016
  10. Junio C HamanoJun 4, 2016
  11. Torsten BögershausenJun 5, 2016
  12. 1/1 connect: [host:port] is lagacy for sshtboegi@web.de, Jun 5, 2016
  13. Eric SunshineJun 5, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.