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

Re: [PATCH 1/3] connect.c: Improve parsing of literal IPV6 addresses

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 22, 2015, 20:07 UTC
Message-ID
<20150122200702.GA96498@vauxhall.crustytoothpaste.net>
In-Reply-To
<54BD3D14.90309@web.de>
On Mon, Jan 19, 2015 at 06:21:24PM +0100, Torsten Bögershausen wrote:
Show 26 quoted lines
>When parsing an URL, older Git versions did handle
>URLs like ssh://2001:db8::1/repo.git the same way as
>ssh://[2001:db8::1]/repo.git
>
>Commit 83b058 broke the parsing of IPV6 adresses without "[]":
>It was written in mind that the fist ':' in a URL was the beginning of a
>port number, while the old code was more clever:
>Literal IPV6 addresses have always at least two ':'.
>When the "hostandport" had a ':' and the rest of the hostandport string
>could be parsed into an integer between 0 and 65536, then it was used
>as a port number, like "host:22".
>Otherwise the first ':' was assumed to be part of a literal IPV6 address,
>like "ssh://[2001:db8::1]/repo.git" or "ssh://[::1]/repo.git".
>
>Re-introduce the old parsing in get_host_and_port().
>
>Improve the parsing to handle URLs which have a user name and a literal
>IPV6 like "ssh://user@[2001:db8::1]/repo.git".
>(Thanks to Christian Taube <lists@hcf.yourweb.de> for reporting this long
>standing issue)
>
>Another regression was introduced in 83b058:
>A non-RFC conform URL like "[localhost:222]" could be used in older versions
>of Git to connect to run "ssh -p 222 localhost".
>The new stricter parsing did not allow this any more.
>See even 8d3d28f5dba why "[localhost:222]" should be declared a feature.

I'm not sure this is a very good idea. While this may have worked in the past, it's also completely inconsistent with the way all non-SSH URLs work in Git:

  vauxhall ok % git push https://bmc@2001:470:1f05:79::1/git/bmc/homedir.git master
  fatal: unable to access 'https://bmc@2001:470:1f05:79::1/git/bmc/homedir.git/': IPv6 numerical address used in URL without brackets
  vauxhall no % git push https://bmc@[castro.crustytoothpaste.net]/git/bmc/homedir.git master
  fatal: unable to access 'https://bmc@[castro.crustytoothpaste.net]/git/bmc/homedir.git/': Could not resolve host: [castro.crustytoothpaste.net]
  vauxhall no % git push https://bmc@[castro.crustytoothpaste.net:443]/git/bmc/homedir.git master
  fatal: unable to access 'https://bmc@[castro.crustytoothpaste.net:443]/git/bmc/homedir.git/': Could not resolve host: [castro.crustytoothpaste.net

I would argue that people using IPv6 literals in URLs should already know how to do it correctly, and the consistency between SSH and HTTPS URLs is a feature, not a bug. In the non-URL SSH form, you still have to use the bracketed form to deal with the case in which somebody creates a directory called "1" in their home directory and writes:

  git push 2001:470:1f05:79::1:1 master 
when they mean
  git push [2001:470:1f05:79::1]:1 master
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 2 of 9 in “connect.c: Improve parsing of literal IPV6 addresses”
  1. 1/3 connect.c: Improve parsing of literal IPV6 addressesTorsten Bögershausen, Jan 19, 2015
  2. brian m. carlsonJan 22, 2015
  3. Torsten BögershausenJan 22, 2015
  4. brian m. carlsonJan 22, 2015
  5. Junio C HamanoFeb 18, 2015
  6. Torsten BögershausenFeb 19, 2015
  7. Junio C HamanoFeb 19, 2015
  8. brian m. carlsonFeb 19, 2015
  9. Torsten BögershausenFeb 20, 2015

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.