threads / discuss / 64219

Feature request: partial URL matching for credential config

Subject: Feature request: partial URL matching for credential config

## tl;dr

4 messages between Sep 27, 2025 and Sep 30, 2025.

replies: 3people: 2as markdown or json

M Hickford· Sep 27, 2025, 18:48 UTC · lore

Hi. A git-credential-oauth user would like to define separate credential config for two URLs prefixes of the same host (eg. https://example.com/org1/* and http://example.com/org2/*) https://github.com/hickford/git-credential-oauth/issues/83

I don't believe this is currently possible https://git-scm.com/docs/gitcredentials

> If the "pattern" URL does include a path component, then this too must match exactly: the context https://example.com/bar/baz.git will match a config entry for https://example.com/bar/baz.git (in addition to matching the config entry for https://example.com) but will not match a config entry for https://example.com/bar.
Any thoughts on adding support for URL prefix matching?

Example syntax could be credential.https://example.com/org1/*.key (explicit wildcard) or credential.https://example.com/org1/.key (implicit wildcard)

Peace -M

M Hickford· Sep 28, 2025, 14:13 UTC · re: M Hickford · lore

Re: Feature request: partial URL matching for credential config

On Sat, 27 Sept 2025 at 19:48, M Hickford <mirth.hickford@gmail.com> wrote:
Show 16 quoted lines
>
> Hi. A git-credential-oauth user would like to define separate
> credential config for two URLs prefixes of the same host (eg.
> https://example.com/org1/* and http://example.com/org2/*)
> https://github.com/hickford/git-credential-oauth/issues/83
>
> I don't believe this is currently possible
> https://git-scm.com/docs/gitcredentials
>
> > If the "pattern" URL does include a path component, then this too must match exactly: the context https://example.com/bar/baz.git will match a config entry for https://example.com/bar/baz.git (in addition to matching the config entry for https://example.com) but will not match a config entry for https://example.com/bar.
>
> Any thoughts on adding support for URL prefix matching?
>
> Example syntax could be credential.https://example.com/org1/*.key
> (explicit wildcard) or credential.https://example.com/org1/.key
> (implicit wildcard)

Here's a simpler example without OAuth -- configuring a personal username for https://git.example.com and an enterprise username for URLs beginning https://git.example.com/syscorp/

credential.https://git.example.com.username=tim credential.https://git.example.com/syscorp/.username=timothy.smith

brian m. carlson· Sep 30, 2025, 15:03 UTC · re: M Hickford · lore

Re: Feature request: partial URL matching for credential config

On 2025-09-27 at 18:48:46, M Hickford wrote:
Show 5 quoted lines
> Any thoughts on adding support for URL prefix matching?
> 
> Example syntax could be credential.https://example.com/org1/*.key
> (explicit wildcard) or credential.https://example.com/org1/.key
> (implicit wildcard)

I think I may have added support for this (using the urlmatch patterns) but didn't document it[0]. I see some tests for it in t0300. Have you tried it?

Regardless, I believe it's a useful feature that we should have.

If, perchance, I did add it and it's still around, would you be willing to write some documentation for it?

[0] I believe Dscho graciously helped fix a few bugs in my changes, which I appreciate.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
M Hickford· Sep 30, 2025, 18:59 UTC · re: brian m. carlson · lore

Re: Feature request: partial URL matching for credential config

On Tue, 30 Sept 2025 at 16:03, brian m. carlson <sandals@crustytoothpaste.net> wrote:

Show 11 quoted lines
>
> On 2025-09-27 at 18:48:46, M Hickford wrote:
> > Any thoughts on adding support for URL prefix matching?
> >
> > Example syntax could be credential.https://example.com/org1/*.key
> > (explicit wildcard) or credential.https://example.com/org1/.key
> > (implicit wildcard)
>
> I think I may have added support for this (using the urlmatch patterns)
> but didn't document it[0].  I see some tests for it in t0300.  Have you
> tried it?
Thanks Brian for your reply. You're right, it already works as desired:
     $ git -c credential.https://example.com/org.username=bingo config
get --url=https://example.com/org/repo.git credential.username
     bingo
It has to be a path prefix, not just a string prefix, which is nice:
     $ git -c credential.https://example.com/org.username=bingo config
get --url=https://example.com/organ/repo.git credential.username
Show 5 quoted lines
>
> Regardless, I believe it's a useful feature that we should have.
>
> If, perchance, I did add it and it's still around, would you be willing
> to write some documentation for it?
I shall send a patch with documentation and expanded tests.
Show 6 quoted lines
>
> [0] I believe Dscho graciously helped fix a few bugs in my changes,
> which I appreciate.
> --
> brian m. carlson (they/them)
> Toronto, Ontario, CA

← back to recent threads