From: Junio C Hamano <gitster@pobox.com>
To: "Ryan Hendrickson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH v5] http: do not ignore proxy path
Date: Fri, 02 Aug 2024 08:52:05 -0700 [thread overview]
Message-ID: <xmqq7ccygbx6.fsf@gitster.g> (raw)
In-Reply-To: <pull.1767.v5.git.1722576007398.gitgitgadget@gmail.com> (Ryan Hendrickson via GitGitGadget's message of "Fri, 02 Aug 2024 05:20:07 +0000")
"Ryan Hendrickson via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
>
> The documentation for `http.proxy` describes that option, and the
> environment variables it overrides, as supporting "the syntax understood
> by curl". curl allows SOCKS proxies to use a path to a Unix domain
> socket, like `socks5h://localhost/path/to/socket.sock`. Git should
> therefore include, if present, the path part of the proxy URL in what it
> passes to libcurl.
>
> Co-authored-by: Jeff King <peff@peff.net>
> Signed-off-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
The trailer lines should be ordered in chronological order to record
the provenance of the patch. The last two entries make it look as
if what you assembled and signed-off was relayed by peff, with or
without further modification, with his sign-off to me, to become the
final version, but that is not the story you want to tell.
I'd swap the two lines (i.e., sign-offs) while queuing.
> + if (!starts_with(proxy_auth.protocol, "socks"))
> + die("Invalid proxy URL '%s': only SOCKS proxies support paths",
> + curl_http_proxy);
Our error messages that are prefixed with "fatal:" do not typically
begin with a capital letter.
But I'll let it pass, as this copies an existing message in this
file. #leftoverbits clean-up needs to correct the ones added by
this patch and existing "Invalid proxy URL '%s'" by downcasing
"Invalid", possibly enclose the message in _() for i18n, and also
downcase "C" in two "Could not set SSL ..." messages.
> + if (strcasecmp(proxy_auth.host, "localhost"))
> + die("Invalid proxy URL '%s': host must be localhost if a path is present",
> + curl_http_proxy);
Ditto.
Or instead of leaving this for a later clean-up after the dust
settles, we could have a separate "preliminary clean-up" patch to
address existing ones first. Either is fine, but taking "clean-up
after the dust settles" and leaving it a problem for other people is
probably easier.
> diff --git a/t/t5564-http-proxy.sh b/t/t5564-http-proxy.sh
> index bb35b87071d..0d6cfebbfab 100755
> --- a/t/t5564-http-proxy.sh
> +++ b/t/t5564-http-proxy.sh
> @@ -39,4 +39,53 @@ test_expect_success 'clone can prompt for proxy password' '
> expect_askpass pass proxuser
> '
>
> +start_socks() {
> + mkfifo socks_output &&
> + {
> + "$PERL_PATH" "$TEST_DIRECTORY/socks4-proxy.pl" "$1" >socks_output &
> + echo $! > "$TRASH_DIRECTORY/socks.pid"
> + } &&
> + read line <socks_output &&
> + test "$line" = ready
> +}
> +
> +# The %30 tests that the correct amount of percent-encoding is applied to the
> +# proxy string passed to curl.
> +test_lazy_prereq SOCKS_PROXY 'test_have_prereq PERL && start_socks "$TRASH_DIRECTORY/%30.sock"'
> +
> +test_atexit 'test ! -e "$TRASH_DIRECTORY/socks.pid" || kill "$(cat "$TRASH_DIRECTORY/socks.pid")"'
Let's line-wrap these overly long ones.
# The %30 tests that the correct amount of percent-encoding is
# applied to the proxy string passed to curl.
test_lazy_prereq SOCKS_PROXY '
test_have_prereq PERL &&
start_socks "$TRASH_DIRECTORY/%30.sock"
'
test_atexit '
test ! -e "$TRASH_DIRECTORY/socks.pid" ||
kill "$(cat "$TRASH_DIRECTORY/socks.pid")"
'
> +# The below tests morally ought to be gated on a prerequisite that Git is
> +# linked with a libcurl that supports Unix socket paths for proxies (7.84 or
> +# later), but this is not easy to test right now. Instead, we || the tests with
> +# this function.
> +old_libcurl_error() {
> + grep -Fx "fatal: libcurl 7.84 or later is required to support paths in proxy URLs" "$1"
> +}
Cute.
This fixes the polarity of the result from the whole "{ test } ||
this helper" construct. Even if the test proper fails, we will
allow such a failure only when the reason of the failure is due to
this message.
If I were writing this, I would shorten to look for a bit fuzzier
pattern like
grep "^fatal: .* is required to support paths in proxy URLs" "$1"
as that would allow us to fix the code later without needing to
update the pattern, if we discover reasons, other than being older
than libcURL 7.84, why paths in proxy URLs cannot be supported.
Other than that, very nicely done.
Thanks.
next prev parent reply other threads:[~2024-08-02 15:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 15:52 [PATCH] http: do not ignore proxy path Ryan Hendrickson via GitGitGadget
2024-07-26 16:29 ` Junio C Hamano
2024-07-26 17:12 ` Ryan Hendrickson
2024-07-26 17:45 ` Junio C Hamano
2024-07-26 21:11 ` Jeff King
2024-07-26 22:43 ` Ryan Hendrickson
2024-07-29 19:31 ` Jeff King
2024-07-27 6:44 ` [PATCH v2] " Ryan Hendrickson via GitGitGadget
2024-07-29 20:09 ` Jeff King
2024-07-31 15:33 ` Ryan Hendrickson
2024-07-31 16:01 ` [PATCH v3] " Ryan Hendrickson via GitGitGadget
2024-07-31 22:24 ` Junio C Hamano
2024-08-01 3:44 ` Ryan Hendrickson
2024-08-01 5:21 ` Junio C Hamano
2024-08-01 5:45 ` Jeff King
2024-08-01 14:40 ` Junio C Hamano
2024-08-01 5:22 ` [PATCH v4] " Ryan Hendrickson via GitGitGadget
2024-08-01 6:04 ` Jeff King
2024-08-01 17:04 ` Junio C Hamano
2024-08-02 5:20 ` [PATCH v5] " Ryan Hendrickson via GitGitGadget
2024-08-02 15:52 ` Junio C Hamano [this message]
2024-08-02 16:43 ` Ryan Hendrickson
2024-08-02 17:10 ` Junio C Hamano
2024-08-02 18:03 ` Ryan Hendrickson
2024-08-02 19:28 ` Junio C Hamano
2024-08-02 19:39 ` Ryan Hendrickson
2024-08-02 21:13 ` Junio C Hamano
2024-08-02 21:26 ` Ryan Hendrickson
2024-08-02 21:43 ` Junio C Hamano
2024-08-02 21:47 ` Junio C Hamano
2024-08-02 22:14 ` Ryan Hendrickson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7ccygbx6.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=peff@peff.net \
--cc=ryan.hendrickson@alum.mit.edu \
/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.
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 NNTP newsgroup(s).