{"thread":{"id":"64236","subject":"[PATCH] docs/gitcredentials: describe URL prefix matching","startedAt":"2025-10-01T20:56:51Z","lastAt":"2025-10-03T21:24:10Z","messageCount":4,"participants":["M Hickford via GitGitGadget","brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"527724","messageId":"pull.1979.git.1759352209657.gitgitgadget@gmail.com","threadId":"64236","inReplyTo":null,"subject":"[PATCH] docs/gitcredentials: describe URL prefix matching","fromName":"M Hickford via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-01T20:56:49Z","receivedAt":"2025-10-01T20:56:51Z","isPatch":true,"sender":{"key":"mirth.hickford@gmail.com","avatar":"https://avatars.githubusercontent.com/u/105314?v=4"},"body":"From: M Hickford <mirth.hickford@gmail.com>\n\nDocumentation was inaccurate since 9a121b0d226 (credential: handle\n`credential.<partial-URL>.<key>` again, 2020-04-24)\n\nAdd tests for documented behaviour.\n\nSigned-off-by: M Hickford <mirth.hickford@gmail.com>\n---\n    docs/gitcredentials: describe URL prefix matching\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1979%2Fhickford%2Furl-prefix-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1979/hickford/url-prefix-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1979\n\n Documentation/gitcredentials.adoc | 15 +++++++--------\n t/t0300-credentials.sh            | 19 +++++++++++++++----\n 2 files changed, 22 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..60c2cc4ade 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -150,9 +150,8 @@ pattern in the config file. For example, if you have this in your config file:\n \tusername = foo\n --------------------------------------\n \n-then we will match: both protocols are the same, both hosts are the same, and\n-the \"pattern\" URL does not care about the path component at all. However, this\n-context would not match:\n+then we will match: both protocols are the same and both hosts are the same.\n+However, this context would not match:\n \n --------------------------------------\n [credential \"https://kernel.org\"]\n@@ -166,11 +165,11 @@ match: Git compares the protocols exactly.  However, you may use wildcards in\n the domain name and other pattern matching techniques as with the `http.<URL>.*`\n options.\n \n-If the \"pattern\" URL does include a path component, then this too must match\n-exactly: the context `https://example.com/bar/baz.git` will match a config\n-entry for `https://example.com/bar/baz.git` (in addition to matching the config\n-entry for `https://example.com`) but will not match a config entry for\n-`https://example.com/bar`.\n+If the \"pattern\" URL does include a path component, then this must match\n+as a prefix path: the context `https://example.com/bar` will match a config\n+entry for `https://example.com/bar/baz.git` but will not match a config entry for\n+`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`\n+(even though it is a string prefix).\n \n \n CONFIGURATION OPTIONS\ndiff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh\nindex cb3a85c7ff..07aa834d33 100755\n--- a/t/t0300-credentials.sh\n+++ b/t/t0300-credentials.sh\n@@ -991,18 +991,24 @@ test_expect_success 'url parser not confused by encoded markers' '\n \n test_expect_success 'credential config with partial URLs' '\n \techo \"echo password=yep\" | write_script git-credential-yep &&\n-\ttest_write_lines url=https://user@example.com/repo.git >stdin &&\n+\ttest_write_lines url=https://user@example.com/org/repo.git >stdin &&\n \tfor partial in \\\n \t\texample.com \\\n+\t\texample.com/org/repo.git \\\n \t\tuser@example.com \\\n+\t\tuser@example.com/org/repo.git \\\n \t\thttps:// \\\n \t\thttps://example.com \\\n \t\thttps://example.com/ \\\n+\t\thttps://example.com/org \\\n+\t\thttps://example.com/org/ \\\n+\t\thttps://example.com/org/repo.git \\\n \t\thttps://user@example.com \\\n \t\thttps://user@example.com/ \\\n-\t\thttps://example.com/repo.git \\\n-\t\thttps://user@example.com/repo.git \\\n-\t\t/repo.git\n+\t\thttps://user@example.com/org \\\n+\t\thttps://user@example.com/org/ \\\n+\t\thttps://user@example.com/org/repo.git \\\n+\t\t/org/repo.git\n \tdo\n \t\tgit -c credential.$partial.helper=yep \\\n \t\t\tcredential fill <stdin >stdout &&\n@@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '\n \n \tfor partial in \\\n \t\tdont.use.this \\\n+\t\texample.com/o \\\n+\t\tuser@example.com/o \\\n \t\thttp:// \\\n+\t\thttps://example.com/o \\\n+\t\thttps://user@example.com/o \\\n+\t\t/o \\\n \t\t/repo\n \tdo\n \t\tgit -c credential.$partial.helper=yep \\\n\nbase-commit: 821f583da6d30a84249f75f33501504d597bc16b\n-- \ngitgitgadget\n"},{"id":"527736","messageId":"aN2pItzrFaga7m9z@fruit.crustytoothpaste.net","threadId":"64236","inReplyTo":"pull.1979.git.1759352209657.gitgitgadget@gmail.com","subject":"Re: [PATCH] docs/gitcredentials: describe URL prefix matching","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-10-01T22:20:18Z","receivedAt":"2025-10-01T22:20:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-10-01 at 20:56:49, M Hickford via GitGitGadget wrote:\n> diff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\n> index 3337bb475d..60c2cc4ade 100644\n> --- a/Documentation/gitcredentials.adoc\n> +++ b/Documentation/gitcredentials.adoc\n> @@ -150,9 +150,8 @@ pattern in the config file. For example, if you have this in your config file:\n>  \tusername = foo\n>  --------------------------------------\n>  \n> -then we will match: both protocols are the same, both hosts are the same, and\n> -the \"pattern\" URL does not care about the path component at all. However, this\n> -context would not match:\n> +then we will match: both protocols are the same and both hosts are the same.\n> +However, this context would not match:\n>  \n>  --------------------------------------\n>  [credential \"https://kernel.org\"]\n> @@ -166,11 +165,11 @@ match: Git compares the protocols exactly.  However, you may use wildcards in\n>  the domain name and other pattern matching techniques as with the `http.<URL>.*`\n>  options.\n>  \n> -If the \"pattern\" URL does include a path component, then this too must match\n> -exactly: the context `https://example.com/bar/baz.git` will match a config\n> -entry for `https://example.com/bar/baz.git` (in addition to matching the config\n> -entry for `https://example.com`) but will not match a config entry for\n> -`https://example.com/bar`.\n> +If the \"pattern\" URL does include a path component, then this must match\n> +as a prefix path: the context `https://example.com/bar` will match a config\n> +entry for `https://example.com/bar/baz.git` but will not match a config entry for\n> +`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`\n> +(even though it is a string prefix).\n\nThis looks like a good description.\n\n>  CONFIGURATION OPTIONS\n> diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh\n> index cb3a85c7ff..07aa834d33 100755\n> --- a/t/t0300-credentials.sh\n> +++ b/t/t0300-credentials.sh\n> @@ -991,18 +991,24 @@ test_expect_success 'url parser not confused by encoded markers' '\n>  \n>  test_expect_success 'credential config with partial URLs' '\n>  \techo \"echo password=yep\" | write_script git-credential-yep &&\n> -\ttest_write_lines url=https://user@example.com/repo.git >stdin &&\n> +\ttest_write_lines url=https://user@example.com/org/repo.git >stdin &&\n>  \tfor partial in \\\n>  \t\texample.com \\\n> +\t\texample.com/org/repo.git \\\n>  \t\tuser@example.com \\\n> +\t\tuser@example.com/org/repo.git \\\n>  \t\thttps:// \\\n>  \t\thttps://example.com \\\n>  \t\thttps://example.com/ \\\n> +\t\thttps://example.com/org \\\n> +\t\thttps://example.com/org/ \\\n> +\t\thttps://example.com/org/repo.git \\\n>  \t\thttps://user@example.com \\\n>  \t\thttps://user@example.com/ \\\n> -\t\thttps://example.com/repo.git \\\n> -\t\thttps://user@example.com/repo.git \\\n> -\t\t/repo.git\n> +\t\thttps://user@example.com/org \\\n> +\t\thttps://user@example.com/org/ \\\n> +\t\thttps://user@example.com/org/repo.git \\\n> +\t\t/org/repo.git\n>  \tdo\n>  \t\tgit -c credential.$partial.helper=yep \\\n>  \t\t\tcredential fill <stdin >stdout &&\n> @@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '\n>  \n>  \tfor partial in \\\n>  \t\tdont.use.this \\\n> +\t\texample.com/o \\\n> +\t\tuser@example.com/o \\\n>  \t\thttp:// \\\n> +\t\thttps://example.com/o \\\n> +\t\thttps://user@example.com/o \\\n> +\t\t/o \\\n>  \t\t/repo\n>  \tdo\n>  \t\tgit -c credential.$partial.helper=yep \\\n\nI appreciate the additional tests here.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\n"},{"id":"527907","messageId":"pull.1979.v2.git.1759525133638.gitgitgadget@gmail.com","threadId":"64236","inReplyTo":"pull.1979.git.1759352209657.gitgitgadget@gmail.com","subject":"[PATCH v2] docs/gitcredentials: describe URL prefix matching","fromName":"M Hickford via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-10-03T20:58:53Z","receivedAt":"2025-10-03T20:58:57Z","isPatch":true,"sender":{"key":"mirth.hickford@gmail.com","avatar":"https://avatars.githubusercontent.com/u/105314?v=4"},"body":"From: M Hickford <mirth.hickford@gmail.com>\n\nDocumentation was inaccurate since 9a121b0d226 (credential: handle\n`credential.<partial-URL>.<key>` again, 2020-04-24)\n\nAdd tests for documented behaviour.\n\nSigned-off-by: M Hickford <mirth.hickford@gmail.com>\n---\n    docs/gitcredentials: describe URL prefix matching\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1979%2Fhickford%2Furl-prefix-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1979/hickford/url-prefix-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/1979\n\nRange-diff vs v1:\n\n 1:  15f44a2ac5 ! 1:  4b64cf47e9 docs/gitcredentials: describe URL prefix matching\n     @@ Documentation/gitcredentials.adoc: match: Git compares the protocols exactly.  H\n      -entry for `https://example.com`) but will not match a config entry for\n      -`https://example.com/bar`.\n      +If the \"pattern\" URL does include a path component, then this must match\n     -+as a prefix path: the context `https://example.com/bar` will match a config\n     ++as a path prefix: the context `https://example.com/bar` will match a config\n      +entry for `https://example.com/bar/baz.git` but will not match a config entry for\n      +`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`\n     -+(even though it is a string prefix).\n     ++(even though it is a string prefix). To match as a prefix, the pattern\n     ++must include protocol and host.\n       \n       \n       CONFIGURATION OPTIONS\n\n\n Documentation/gitcredentials.adoc | 16 ++++++++--------\n t/t0300-credentials.sh            | 19 +++++++++++++++----\n 2 files changed, 23 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/gitcredentials.adoc b/Documentation/gitcredentials.adoc\nindex 3337bb475d..bf595f7918 100644\n--- a/Documentation/gitcredentials.adoc\n+++ b/Documentation/gitcredentials.adoc\n@@ -150,9 +150,8 @@ pattern in the config file. For example, if you have this in your config file:\n \tusername = foo\n --------------------------------------\n \n-then we will match: both protocols are the same, both hosts are the same, and\n-the \"pattern\" URL does not care about the path component at all. However, this\n-context would not match:\n+then we will match: both protocols are the same and both hosts are the same.\n+However, this context would not match:\n \n --------------------------------------\n [credential \"https://kernel.org\"]\n@@ -166,11 +165,12 @@ match: Git compares the protocols exactly.  However, you may use wildcards in\n the domain name and other pattern matching techniques as with the `http.<URL>.*`\n options.\n \n-If the \"pattern\" URL does include a path component, then this too must match\n-exactly: the context `https://example.com/bar/baz.git` will match a config\n-entry for `https://example.com/bar/baz.git` (in addition to matching the config\n-entry for `https://example.com`) but will not match a config entry for\n-`https://example.com/bar`.\n+If the \"pattern\" URL does include a path component, then this must match\n+as a path prefix: the context `https://example.com/bar` will match a config\n+entry for `https://example.com/bar/baz.git` but will not match a config entry for\n+`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`\n+(even though it is a string prefix). To match as a prefix, the pattern\n+must include protocol and host.\n \n \n CONFIGURATION OPTIONS\ndiff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh\nindex cb3a85c7ff..07aa834d33 100755\n--- a/t/t0300-credentials.sh\n+++ b/t/t0300-credentials.sh\n@@ -991,18 +991,24 @@ test_expect_success 'url parser not confused by encoded markers' '\n \n test_expect_success 'credential config with partial URLs' '\n \techo \"echo password=yep\" | write_script git-credential-yep &&\n-\ttest_write_lines url=https://user@example.com/repo.git >stdin &&\n+\ttest_write_lines url=https://user@example.com/org/repo.git >stdin &&\n \tfor partial in \\\n \t\texample.com \\\n+\t\texample.com/org/repo.git \\\n \t\tuser@example.com \\\n+\t\tuser@example.com/org/repo.git \\\n \t\thttps:// \\\n \t\thttps://example.com \\\n \t\thttps://example.com/ \\\n+\t\thttps://example.com/org \\\n+\t\thttps://example.com/org/ \\\n+\t\thttps://example.com/org/repo.git \\\n \t\thttps://user@example.com \\\n \t\thttps://user@example.com/ \\\n-\t\thttps://example.com/repo.git \\\n-\t\thttps://user@example.com/repo.git \\\n-\t\t/repo.git\n+\t\thttps://user@example.com/org \\\n+\t\thttps://user@example.com/org/ \\\n+\t\thttps://user@example.com/org/repo.git \\\n+\t\t/org/repo.git\n \tdo\n \t\tgit -c credential.$partial.helper=yep \\\n \t\t\tcredential fill <stdin >stdout &&\n@@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '\n \n \tfor partial in \\\n \t\tdont.use.this \\\n+\t\texample.com/o \\\n+\t\tuser@example.com/o \\\n \t\thttp:// \\\n+\t\thttps://example.com/o \\\n+\t\thttps://user@example.com/o \\\n+\t\t/o \\\n \t\t/repo\n \tdo\n \t\tgit -c credential.$partial.helper=yep \\\n\nbase-commit: 821f583da6d30a84249f75f33501504d597bc16b\n-- \ngitgitgadget\n"},{"id":"527910","messageId":"xmqqwm5bsmpz.fsf@gitster.g","threadId":"64236","inReplyTo":"pull.1979.v2.git.1759525133638.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] docs/gitcredentials: describe URL prefix matching","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-03T21:24:08Z","receivedAt":"2025-10-03T21:24:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"M Hickford via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: M Hickford <mirth.hickford@gmail.com>\n>\n> Documentation was inaccurate since 9a121b0d226 (credential: handle\n> `credential.<partial-URL>.<key>` again, 2020-04-24)\n>\n> Add tests for documented behaviour.\n>\n> Signed-off-by: M Hickford <mirth.hickford@gmail.com>\n> ---\n>     docs/gitcredentials: describe URL prefix matching\n\nHmph, v1 was merged to 'next' already yesterday, so a replacement\npatch is not what I was expecting to see.  Can you make an\nincremental update instead?\n\nThanks.\n"}]}