From: "Torsten Bögershausen" <tboegi@web.de>
To: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Cc: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org, pclouds@gmail.com
Subject: Re: [PATCH v3 0/6] fix repo name when cloning a server's root
Date: Thu, 6 Aug 2015 09:22:21 +0200 [thread overview]
Message-ID: <55C30B2D.5000308@web.de> (raw)
In-Reply-To: <20150805211947.GC21134@sigill.intra.peff.net>
On 2015-08-05 23.19, Jeff King wrote:
> On Wed, Aug 05, 2015 at 10:34:34AM -0700, Junio C Hamano wrote:
>
>>> As you can see, there is a lot of complexity in there and I'm not
>>> convinced this is better than just exposing
>>> 'parse_connect_url()', which already handles everything for us.
I try expose and use parse_connect_url():
It handles the scp-like syntax "host:/path,
literall IPV6 addresses, port numbers,
':' without a port number and all other Git specific parsing,
which is inside and outside the RFC 3986.
(I should know, because I managed to break the parser twice,
and fix it)
I added a diagnostics to connect.c, and if you run the a simply test,
we can see that the colon slash logic is often unsufficient:
tb@mypc:~/projects/git/tb.150731_connect> ./git fetch-pack --diag-url ssh://host/
Diag: url=ssh://host/
Diag: protocol=ssh
Diag: userandhost=host
Diag: port=NONE
Diag: path=/
Diag: guesseddir=host/
tb@macce:~/projects/git/tb.150731_connect> ./git fetch-pack --diag-url ssh://host:/
Diag: url=ssh://host:/
Diag: protocol=ssh
Diag: userandhost=host
Diag: port=NONE
Diag: path=/
Diag: guesseddir=/
On top of that, you can easily write test cases in t5601, as many as you want.
The (minor) drawback is that it doesn't handle http:// or https://,
but that is easy to add in the parser, and doesn't break existing code.
The major which remains is to search for '@' in userandhost,
and strip that off.
(Or when there is a '@', search for a ':' before the '@', and strip that off)
After that, all non-printable characters should be %-escaped.
If we replace ':' as non-printable as well, we can make Windows users 1% more happy.
>>
>> If the function "handles everything for us", that's fine, but the
>> primary reason I am hesitant is because parse_connect_url() was
>> designed specifically not to have to worry about some protocols
>> (e.g. I think feeding it a "http://" would fail, and more
>> importantly, its current callers want such a call to fail). Also it
>> is meant to handle some non-protocols (e.g. scp style host:path that
>> does not follow <scheme>://...).
>
> True, but the transport code _is_ handling that at some point. It makes
> me wonder if it would be possible to push the call to transport_get
> further up inside cmd_clone(), and then provide some way to query the
> remote path and hostname from the transport code. Then guess_dir_name
> could just go away entirely, in favor of something like:
>
> dir_name = transport_get_path(transport);
> if (!*dir_name)
> dir_name = transport_get_host(transport);
>
> That may be overly simplistic or unworkable, though. I haven't dug into
> the code.
>
>> Also does it handle the "2222" case above? I do not think
>> parse_connect_url() even calls get_host_and_port() to be able to
>> tell what "2222" means in these examples.
>
> Speaking of which, has anyone tested whether the old or new code handles
> external remote helpers? Certainly:
>
> foo::https://host/repo.git
>
> should still use repo.git. But technically the string handed to
> git-remote-foo does not have to look anything like a URL. In those cases
> neither guess_dir_name nor the transport code have any idea what anything
> to the right of the "::" means; we probably have to resort to blind
> guessing based on characters like colon and slash.
>
It is easy to strip the foo:: part of the url, assume that
the remote helper uses a RFC 3986 similar url syntax, so that we
can feed the reminding https://host/repo.git into the parser (see above).
If the remote helper doesn't do this, we can't guess anything, can we ?
So error out and tell the user seems the right thing to do.
In the hope that this is useful, pushed my prototype branch to
https://github.com/tboegi/git/tree/150731_connect_diag_guess_name
next prev parent reply other threads:[~2015-08-06 7:42 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 11:48 [PATCH] clone: fix repo name when cloning a server's root Patrick Steinhardt
2015-07-27 12:51 ` Duy Nguyen
2015-07-27 12:59 ` Patrick Steinhardt
2015-07-27 14:29 ` Junio C Hamano
2015-07-29 15:51 ` [PATCH v2 0/6] " Patrick Steinhardt
2015-07-29 15:51 ` [PATCH v2 1/6] tests: fix broken && chains in t1509-root-worktree Patrick Steinhardt
2015-07-29 15:51 ` [PATCH v2 2/6] tests: fix cleanup after tests " Patrick Steinhardt
2015-07-29 15:51 ` [PATCH v2 3/6] connect: expose parse_connect_url() Patrick Steinhardt
2015-07-29 15:51 ` [PATCH v2 4/6] connect: move error check to caller of parse_connect_url Patrick Steinhardt
2015-07-29 20:32 ` Eric Sunshine
2015-07-30 12:19 ` Patrick Steinhardt
2015-07-29 15:51 ` [PATCH v2 5/6] clone: fix hostname parsing when guessing dir Patrick Steinhardt
2015-07-29 17:42 ` Junio C Hamano
2015-07-30 12:18 ` Patrick Steinhardt
2015-07-30 16:30 ` Junio C Hamano
2015-07-30 16:53 ` Junio C Hamano
2015-08-03 8:34 ` Patrick Steinhardt
2015-08-03 16:37 ` Jeff King
2015-08-03 19:43 ` Junio C Hamano
2015-07-29 15:51 ` [PATCH v2 6/6] clone: add tests for cloning with empty path Patrick Steinhardt
2015-07-30 18:18 ` Eric Sunshine
2015-07-31 0:58 ` Junio C Hamano
2015-07-31 8:45 ` Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 0/6] fix repo name when cloning a server's root Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 1/6] tests: fix broken && chains in t1509-root-worktree Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 2/6] tests: fix cleanup after tests " Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 3/6] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 4/6] clone: do not use port number as dir name Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 5/6] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-04 11:29 ` [PATCH v3 6/6] clone: add tests for cloning with empty path Patrick Steinhardt
2015-08-04 18:37 ` Eric Sunshine
2015-08-05 17:34 ` [PATCH v3 0/6] fix repo name when cloning a server's root Junio C Hamano
2015-08-05 21:19 ` Jeff King
2015-08-06 7:22 ` Torsten Bögershausen [this message]
2015-08-06 8:00 ` Junio C Hamano
2015-08-05 10:06 ` [PATCH v4 0/3] " Patrick Steinhardt
2015-08-05 10:06 ` [PATCH v4 1/3] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-05 17:43 ` Junio C Hamano
2015-08-05 19:36 ` Junio C Hamano
2015-08-05 19:41 ` Junio C Hamano
2015-08-06 9:47 ` Patrick Steinhardt
2015-08-07 20:45 ` Junio C Hamano
2015-08-08 17:37 ` Patrick Steinhardt
2015-08-05 10:06 ` [PATCH v4 2/3] clone: do not use port number as dir name Patrick Steinhardt
2015-08-05 10:06 ` [PATCH v4 3/3] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-05 17:44 ` Junio C Hamano
2015-08-10 15:48 ` [PATCH v5 0/5] Improve guessing of repository names Patrick Steinhardt
2015-08-10 15:48 ` [PATCH v5 1/5] clone: add tests for output directory Patrick Steinhardt
2015-08-10 15:48 ` [PATCH v5 2/5] clone: use computed length in guess_dir_name Patrick Steinhardt
2015-08-10 15:48 ` [PATCH v5 3/5] clone: do not include authentication data in guessed dir Patrick Steinhardt
2015-08-10 15:48 ` [PATCH v5 4/5] clone: do not use port number as dir name Patrick Steinhardt
2015-08-10 15:48 ` [PATCH v5 5/5] clone: abort if no dir name could be guessed Patrick Steinhardt
2015-08-10 18:07 ` [PATCH v5 0/5] Improve guessing of repository names Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55C30B2D.5000308@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).