Skip to content

Commit fdd21ba

Browse files
hickfordgitster
authored andcommitted
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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a1cf0cf commit fdd21ba

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

Documentation/gitcredentials.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,8 @@ pattern in the config file. For example, if you have this in your config file:
133133
username = foo
134134
--------------------------------------
135135

136-
then we will match: both protocols are the same, both hosts are the same, and
137-
the "pattern" URL does not care about the path component at all. However, this
138-
context would not match:
136+
then we will match: both protocols are the same and both hosts are the same.
137+
However, this context would not match:
139138

140139
--------------------------------------
141140
[credential "https://kernel.org"]
@@ -149,11 +148,11 @@ match: Git compares the protocols exactly. However, you may use wildcards in
149148
the domain name and other pattern matching techniques as with the `http.<URL>.*`
150149
options.
151150

152-
If the "pattern" URL does include a path component, then this too must match
153-
exactly: the context `https://example.com/bar/baz.git` will match a config
154-
entry for `https://example.com/bar/baz.git` (in addition to matching the config
155-
entry for `https://example.com`) but will not match a config entry for
156-
`https://example.com/bar`.
151+
If the "pattern" URL does include a path component, then this must match
152+
as a prefix path: the context `https://example.com/bar` will match a config
153+
entry for `https://example.com/bar/baz.git` but will not match a config entry for
154+
`https://example.com/other/repo.git` or `https://example.com/barry/repo.git`
155+
(even though it is a string prefix).
157156

158157

159158
CONFIGURATION OPTIONS

t/t0300-credentials.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,18 +991,24 @@ 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 \
997+
example.com/org/repo.git \
997998
999+
[email protected]/org/repo.git \
9981000
https:// \
9991001
https://example.com \
10001002
https://example.com/ \
1003+
https://example.com/org \
1004+
https://example.com/org/ \
1005+
https://example.com/org/repo.git \
10011006
10021007
https://[email protected]/ \
1003-
https://example.com/repo.git \
1004-
https://[email protected]/repo.git \
1005-
/repo.git
1008+
https://[email protected]/org \
1009+
https://[email protected]/org/ \
1010+
https://[email protected]/org/repo.git \
1011+
/org/repo.git
10061012
do
10071013
git -c credential.$partial.helper=yep \
10081014
credential fill <stdin >stdout &&
@@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '
10121018
10131019
for partial in \
10141020
dont.use.this \
1021+
example.com/o \
1022+
10151023
http:// \
1024+
https://example.com/o \
1025+
https://[email protected]/o \
1026+
/o \
10161027
/repo
10171028
do
10181029
git -c credential.$partial.helper=yep \

0 commit comments

Comments
 (0)