Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Documentation/gitcredentials.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -166,11 +165,12 @@ 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 path prefix: 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). To match as a prefix, the pattern
must include protocol and host.


CONFIGURATION OPTIONS
Expand Down
19 changes: 15 additions & 4 deletions t/t0300-credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/repo.git >stdin &&
test_write_lines url=https://[email protected]/org/repo.git >stdin &&
for partial in \
example.com \
example.com/org/repo.git \
[email protected] \
[email protected]/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://[email protected] \
https://[email protected]/ \
https://example.com/repo.git \
https://[email protected]/repo.git \
/repo.git
https://[email protected]/org \
https://[email protected]/org/ \
https://[email protected]/org/repo.git \
/org/repo.git
do
git -c credential.$partial.helper=yep \
credential fill <stdin >stdout &&
Expand All @@ -1012,7 +1018,12 @@ test_expect_success 'credential config with partial URLs' '

for partial in \
dont.use.this \
example.com/o \
[email protected]/o \
http:// \
https://example.com/o \
https://[email protected]/o \
/o \
/repo
do
git -c credential.$partial.helper=yep \
Expand Down
Loading