path: root/strbuf.h
diff options
authorbrian m. carlson <>2020-02-20 02:24:13 (GMT)
committerJunio C Hamano <>2020-02-20 21:05:43 (GMT)
commit46fd7b390034eb5dde6a3f955e677c5260e4d10c (patch)
treea35d6bf10ad09e279feca361865251072a04123f /strbuf.h
parent82eb249853868582d8ba65e3afc5a7dcaeb620ea (diff)
credential: allow wildcard patterns when matching config
In some cases, a user will want to use a specific credential helper for a wildcard pattern, such as https://* We have code that handles this already with the urlmatch code, so let's use that instead of our custom code. Since the urlmatch code is a superset of our current matching in terms of capabilities, there shouldn't be any cases of things that matched previously that don't match now. However, in addition to wildcard matching, we now use partial path matching, which can cause slightly different behavior in the case that a helper applies to the prefix (considering path components) of the remote URL. While different, this is probably the behavior people were wanting anyway. Since we're using the urlmatch code, we need to encode the components we've gotten into a URL to match, so add a function to percent-encode data and format the URL with it. We now also no longer need to the custom code to match URLs, so let's remove it. Additionally, the urlmatch code always looks for the best match, whereas we want all matches for credential helpers to preserve existing behavior. Let's add an optional field, select_fn, that lets us control which items we want (in this case, all of them) and default it to the best-match code that already exists for other users. Signed-off-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'strbuf.h')
1 files changed, 6 insertions, 0 deletions
diff --git a/strbuf.h b/strbuf.h
index bfa6656..2504ae4 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -367,6 +367,12 @@ size_t strbuf_expand_dict_cb(struct strbuf *sb,
void strbuf_addbuf_percentquote(struct strbuf *dst, const struct strbuf *src);
+ * Append the contents of a string to a strbuf, percent-encoding any characters
+ * that are needed to be encoded for a URL.
+ */
+void strbuf_add_percentencode(struct strbuf *dst, const char *src);
* Append the given byte size as a human-readable string (i.e. 12.23 KiB,
* 3.50 MiB).