Git fork

docs/gitcredentials: describe URL prefix matching

Documentation was inaccurate since 9a121b0d226 (credential: handle
`credential.<partial-URL>.<key>` again, 2020-04-24)

Add tests for documented behaviour.

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

M Hickford and committed by
Junio C Hamano
fdd21ba1 a1cf0cf1

+22 -12
+7 -8
Documentation/gitcredentials.txt
··· 133 133 username = foo 134 134 -------------------------------------- 135 135 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: 139 138 140 139 -------------------------------------- 141 140 [credential "https://kernel.org"] ··· 149 148 the domain name and other pattern matching techniques as with the `http.<URL>.*` 150 149 options. 151 150 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). 157 156 158 157 159 158 CONFIGURATION OPTIONS
+15 -4
t/t0300-credentials.sh
··· 991 991 992 992 test_expect_success 'credential config with partial URLs' ' 993 993 echo "echo password=yep" | write_script git-credential-yep && 994 - test_write_lines url=https://user@example.com/repo.git >stdin && 994 + test_write_lines url=https://user@example.com/org/repo.git >stdin && 995 995 for partial in \ 996 996 example.com \ 997 + example.com/org/repo.git \ 997 998 user@example.com \ 999 + user@example.com/org/repo.git \ 998 1000 https:// \ 999 1001 https://example.com \ 1000 1002 https://example.com/ \ 1003 + https://example.com/org \ 1004 + https://example.com/org/ \ 1005 + https://example.com/org/repo.git \ 1001 1006 https://user@example.com \ 1002 1007 https://user@example.com/ \ 1003 - https://example.com/repo.git \ 1004 - https://user@example.com/repo.git \ 1005 - /repo.git 1008 + https://user@example.com/org \ 1009 + https://user@example.com/org/ \ 1010 + https://user@example.com/org/repo.git \ 1011 + /org/repo.git 1006 1012 do 1007 1013 git -c credential.$partial.helper=yep \ 1008 1014 credential fill <stdin >stdout && ··· 1012 1018 1013 1019 for partial in \ 1014 1020 dont.use.this \ 1021 + example.com/o \ 1022 + user@example.com/o \ 1015 1023 http:// \ 1024 + https://example.com/o \ 1025 + https://user@example.com/o \ 1026 + /o \ 1016 1027 /repo 1017 1028 do 1018 1029 git -c credential.$partial.helper=yep \