Skip to content

Commit 1894200

Browse files
committed
docs/gitcredentials: describe URL prefix matching
Documentation was inaccurate since 9a121b0 (credential: handle `credential.<partial-URL>.<key>` again, 2020-04-24) Add tests for documented behaviour. Signed-off-by: M Hickford <[email protected]>
1 parent 821f583 commit 1894200

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Documentation/gitcredentials.adoc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,8 @@ pattern in the config file. For example, if you have this in your config file:
150150
username = foo
151151
--------------------------------------
152152
153-
then we will match: both protocols are the same, both hosts are the same, and
154-
the "pattern" URL does not care about the path component at all. However, this
155-
context would not match:
153+
then we will match: both protocols are the same and both hosts are the same.
154+
However, this context would not match:
156155
157156
--------------------------------------
158157
[credential "https://kernel.org"]
@@ -166,11 +165,11 @@ match: Git compares the protocols exactly. However, you may use wildcards in
166165
the domain name and other pattern matching techniques as with the `http.<URL>.*`
167166
options.
168167
169-
If the "pattern" URL does include a path component, then this too must match
170-
exactly: the context `https://example.com/bar/baz.git` will match a config
171-
entry for `https://example.com/bar/baz.git` (in addition to matching the config
172-
entry for `https://example.com`) but will not match a config entry for
173-
`https://example.com/bar`.
168+
If the "pattern" URL does include a path component, then this must match
169+
as a prefix path: the context `https://example.com/bar` will match a config
170+
entry for `https://example.com/bar/baz.git` but will not match a config entry for
171+
`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`
172+
(even though it is a string prefix).
174173
175174
176175
CONFIGURATION OPTIONS

t/t0300-credentials.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ test_expect_success 'url parser not confused by encoded markers' '
991991

992992
test_expect_success 'credential config with partial URLs' '
993993
echo "echo password=yep" | write_script git-credential-yep &&
994-
test_write_lines url=https://[email protected]/repo.git >stdin &&
994+
test_write_lines url=https://[email protected]/org/repo.git >stdin &&
995995
for partial in \
996996
example.com \
997997
@@ -1000,9 +1000,11 @@ test_expect_success 'credential config with partial URLs' '
10001000
https://example.com/ \
10011001
10021002
https://[email protected]/ \
1003-
https://example.com/repo.git \
1004-
https://[email protected]/repo.git \
1005-
/repo.git
1003+
https://[email protected]/org \
1004+
https://[email protected]/org/ \
1005+
https://example.com/org/repo.git \
1006+
https://[email protected]/org/repo.git \
1007+
/org/repo.git
10061008
do
10071009
git -c credential.$partial.helper=yep \
10081010
credential fill <stdin >stdout &&
@@ -1013,6 +1015,7 @@ test_expect_success 'credential config with partial URLs' '
10131015
for partial in \
10141016
dont.use.this \
10151017
http:// \
1018+
https://example.com/o \
10161019
/repo
10171020
do
10181021
git -c credential.$partial.helper=yep \

0 commit comments

Comments
 (0)