From: "Fabian Pottbäcker" <fpottbaecker+git@mailbox.org>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Patrick Steinhardt" <ps@pks.im>,
"Fabian Pottbäcker" <fpottbaecker+git@mailbox.org>
Subject: [PATCH 3/3] config: use url_parse for --url
Date: Fri, 24 Jul 2026 02:40:11 +0200 [thread overview]
Message-ID: <20260724004011.41795-4-fpottbaecker+git@mailbox.org> (raw)
In-Reply-To: <20260724004011.41795-1-fpottbaecker+git@mailbox.org>
This enables the use of the scp-style URL syntax for this option and
the depracated --get-urlmatch. Since URL matching was primarily used
for http(s) transports previously (with the potential exception of
promisor.acceptFromServerUrl), this has little internal effect and
mostly brings the behaviour of this URL argument in line with other
commands.
Signed-off-by: Fabian Pottbäcker <fpottbaecker+git@mailbox.org>
---
Documentation/git-config.adoc | 5 ++++
builtin/config.c | 2 +-
t/t1300-config.sh | 44 +++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-config.adoc b/Documentation/git-config.adoc
index 57af010ade..a38d68512e 100644
--- a/Documentation/git-config.adoc
+++ b/Documentation/git-config.adoc
@@ -143,6 +143,11 @@ permitted).
<section>.<key> is used as a fallback). When given just the
<section> as name, do so for all the keys in the section and
list them. Returns error code 1 if no value is found.
++
+This option supports all URL formats (see linkgit:git-fetch[1]),
+unlike the config file URL syntax explained in the `http.<url>.*`
+options, which requires an explicitly specified scheme and does
+not support the scp-style URL syntax.
--global::
For writing options: write to global `~/.gitconfig` file
diff --git a/builtin/config.c b/builtin/config.c
index 8d8ec0beea..b5488a9497 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -870,7 +870,7 @@ static int get_urlmatch(const struct config_location_options *opts,
config.cascade_fn = NULL;
config.cb = &values;
- if (!url_normalize(url, &config.url))
+ if (!url_parse(url, &config.url))
die("%s", config.url.err);
config.section = section = xstrdup_tolower(var);
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 8310fe6a65..477e030cf3 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1907,6 +1907,50 @@ test_expect_success 'urlmatch' '
test_cmp expect actual
'
+test_expect_success 'urlmatch with scp syntax' '
+ cat >.git/config <<-\EOF &&
+ [section]
+ flag = false
+ [section "ssh://example.com"]
+ flag = true
+ key = value
+ EOF
+
+ echo "fatal: invalid URL scheme name or missing '"'"'://'"'"' suffix" >expect_err &&
+ test_expect_code 128 git config --bool --get-urlmatch section.flag example.com >actual 2>error &&
+ test_cmp expect_err error &&
+ test_must_be_empty actual &&
+ test_expect_code 128 git config get --url=example.com --bool section.flag >actual 2>error &&
+ test_cmp expect_err error &&
+ test_must_be_empty actual &&
+
+ test_expect_code 1 git config --bool --get-urlmatch doesnt.exist example.com: >actual &&
+ test_must_be_empty actual &&
+ test_expect_code 1 git config get --url=example.com: --bool doesnt.exist >actual &&
+ test_must_be_empty actual &&
+
+ echo true >expect &&
+ git config --bool --get-urlmatch section.flag git@example.com:path >actual &&
+ test_cmp expect actual &&
+ git config get --bool --url=git@example.com:path section.flag >actual &&
+ test_cmp expect actual &&
+
+ echo false >expect &&
+ git config --bool --get-urlmatch section.flag https://example.com >actual &&
+ test_cmp expect actual &&
+ git config get --bool --url=https://example.com section.flag >actual &&
+ test_cmp expect actual &&
+
+ {
+ echo section.flag true &&
+ echo section.key value
+ } >expect &&
+ git config --get-urlmatch section git@example.com:path >actual &&
+ test_cmp expect actual &&
+ git config get --url=git@example.com:path section >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'urlmatch with --show-scope' '
cat >.git/config <<-\EOF &&
[http "https://weak.example.com"]
--
2.50.1 (Apple Git-155)
prev parent reply other threads:[~2026-07-24 0:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 0:40 [PATCH 0/3] config: support scp-style --url Fabian Pottbäcker
2026-07-24 0:40 ` [PATCH 1/3] urlmatch: normalize ssh and ftp default ports Fabian Pottbäcker
2026-07-24 0:40 ` [PATCH 2/3] t1300: cover --url for some --get-urlmatch tests Fabian Pottbäcker
2026-07-24 0:40 ` Fabian Pottbäcker [this message]
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=20260724004011.41795-4-fpottbaecker+git@mailbox.org \
--to=fpottbaecker+git@mailbox.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox