git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] docs/gitcredentials: describe URL prefix matching

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 1, 2025, 22:20 UTC
Message-ID
<aN2pItzrFaga7m9z@fruit.crustytoothpaste.net>
In-Reply-To
<pull.1979.git.1759352209657.gitgitgadget@gmail.com>
On 2025-10-01 at 20:56:49, M Hickford via GitGitGadget wrote:
Show 30 quoted lines
> diff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc
> index 3337bb475d..60c2cc4ade 100644
> --- a/Documentation/gitcredentials.adoc
> +++ b/Documentation/gitcredentials.adoc
> @@ -150,9 +150,8 @@ pattern in the config file. For example, if you have this in your config file:
>  	username = foo
>  --------------------------------------
>  
> -then we will match: both protocols are the same, both hosts are the same, and
> -the "pattern" URL does not care about the path component at all. However, this
> -context would not match:
> +then we will match: both protocols are the same and both hosts are the same.
> +However, this context would not match:
>  
>  --------------------------------------
>  [credential "https://kernel.org"]
> @@ -166,11 +165,11 @@ match: Git compares the protocols exactly.  However, you may use wildcards in
>  the domain name and other pattern matching techniques as with the `http.<URL>.*`
>  options.
>  
> -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`.
> +If the "pattern" URL does include a path component, then this must match
> +as a prefix path: the context `https://example.com/bar` will match a config
> +entry for `https://example.com/bar/baz.git` but will not match a config entry for
> +`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`
> +(even though it is a string prefix).
This looks like a good description.
Show 47 quoted lines
>  CONFIGURATION OPTIONS
> diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
> index cb3a85c7ff..07aa834d33 100755
> --- a/t/t0300-credentials.sh
> +++ b/t/t0300-credentials.sh
> @@ -991,18 +991,24 @@ test_expect_success 'url parser not confused by encoded markers' '
>  
>  test_expect_success 'credential config with partial URLs' '
>  	echo "echo password=yep" | write_script git-credential-yep &&
> -	test_write_lines url=https://user@example.com/repo.git >stdin &&
> +	test_write_lines url=https://user@example.com/org/repo.git >stdin &&
>  	for partial in \
>  		example.com \
> +		example.com/org/repo.git \
>  		user@example.com \
> +		user@example.com/org/repo.git \
>  		https:// \
>  		https://example.com \
>  		https://example.com/ \
> +		https://example.com/org \
> +		https://example.com/org/ \
> +		https://example.com/org/repo.git \
>  		https://user@example.com \
>  		https://user@example.com/ \
> -		https://example.com/repo.git \
> -		https://user@example.com/repo.git \
> -		/repo.git
> +		https://user@example.com/org \
> +		https://user@example.com/org/ \
> +		https://user@example.com/org/repo.git \
> +		/org/repo.git
>  	do
>  		git -c credential.$partial.helper=yep \
>  			credential fill <stdin >stdout &&
> @@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '
>  
>  	for partial in \
>  		dont.use.this \
> +		example.com/o \
> +		user@example.com/o \
>  		http:// \
> +		https://example.com/o \
> +		https://user@example.com/o \
> +		/o \
>  		/repo
>  	do
>  		git -c credential.$partial.helper=yep \
I appreciate the additional tests here.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: M Hickford via GitGitGadgetNext: M Hickford via GitGitGadget
Message 2 of 4 in “docs/gitcredentials: describe URL prefix matching”
  1. docs/gitcredentials: describe URL prefix matchingM Hickford via GitGitGadget, Oct 1, 2025
  2. brian m. carlsonOct 1, 2025
  3. docs/gitcredentials: describe URL prefix matchingM Hickford via GitGitGadget, Oct 3, 2025
  4. Junio C HamanoOct 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.