# Feature request: partial URL matching for credential config

4 messages from 2025-09-27 to 2025-09-30. Participants: M Hickford, brian m. carlson.
Thread: https://gitlist.dev/t/64219

## M Hickford, 2025-09-27 18:48

Subject: Feature request: partial URL matching for credential config
Message-ID: <CAGJzqsn7BbaVckJ17XhsDHLtmS3OZPBG=oniwe+FRjhEwGc+Eg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGJzqsn7BbaVckJ17XhsDHLtmS3OZPBG%3Doniwe%2BFRjhEwGc%2BEg%40mail.gmail.com

```
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, 2025-09-28 14:13

Subject: Re: Feature request: partial URL matching for credential config
Message-ID: <CAGJzqs=8QHB2UjECVpEB2_R85dG1oHg2F2ewDRVpun8XqbboKQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGJzqs%3D8QHB2UjECVpEB2_R85dG1oHg2F2ewDRVpun8XqbboKQ%40mail.gmail.com
In-Reply-To: <CAGJzqsn7BbaVckJ17XhsDHLtmS3OZPBG=oniwe+FRjhEwGc+Eg@mail.gmail.com>

```
On Sat, 27 Sept 2025 at 19:48, M Hickford <mirth.hickford@gmail.com> wrote:
>
> 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, 2025-09-30 15:03

Subject: Re: Feature request: partial URL matching for credential config
Message-ID: <aNvxVOUyijGaJfsr@fruit.crustytoothpaste.net>
URL: https://gitlist.dev/e/aNvxVOUyijGaJfsr%40fruit.crustytoothpaste.net
In-Reply-To: <CAGJzqsn7BbaVckJ17XhsDHLtmS3OZPBG=oniwe+FRjhEwGc+Eg@mail.gmail.com>

```
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?

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, 2025-09-30 18:59

Subject: Re: Feature request: partial URL matching for credential config
Message-ID: <CAGJzqskzfpyobvV1abTr9qUgGWLuhfTE4FdbgKJy4HZgfO-oLw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGJzqskzfpyobvV1abTr9qUgGWLuhfTE4FdbgKJy4HZgfO-oLw%40mail.gmail.com
In-Reply-To: <aNvxVOUyijGaJfsr@fruit.crustytoothpaste.net>

```
On Tue, 30 Sept 2025 at 16:03, brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> 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

>
> 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.

>
> [0] I believe Dscho graciously helped fix a few bugs in my changes,
> which I appreciate.
> --
> brian m. carlson (they/them)
> Toronto, Ontario, CA

```
