builtin/credential-store: move is_rfc3986_unreserved to url.[ch]
is_rfc3986_unreserved() was moved to credential-store.c and was made static by f89854362c (credential-store: move related functions to credential-store file, 2023-06-06) under a correct assumption, at the time, that it was the only place using it. However now we need it to apply URL-encoding to submodule names when constructing gitdir paths, to avoid conflicts, so bring it back as a public function exposed via url.h, instead of the old helper path (strbuf), which has nothing to do with 3986 encoding/decoding anymore. This function will be used in subsequent commits which do the encoding. Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Adrian Ratiu committed
Jan 12, 2026 at 20:46 UTC
226694bdf4aaecd18f6cd4df12656cc61b213d16
3 files changed
+14
-6
builtin/credential-store.c
+1
-6
@@ -7,6 +7,7 @@
7
#include "path.h"
8
#include "string-list.h"
9
#include "parse-options.h"
10
+#include "url.h"
11
#include "write-or-die.h"
12
13
static struct lock_file credential_lock;
@@ -76,12 +77,6 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
77
die_errno("unable to write credential store");
78
}
79
79
-static int is_rfc3986_unreserved(char ch)
80
-{
81
- return isalnum(ch) ||
82
- ch == '-' || ch == '_' || ch == '.' || ch == '~';
83
-}
84
-
80
static int is_rfc3986_reserved_or_unreserved(char ch)
81
{
82
if (is_rfc3986_unreserved(ch))
url.c
+6
@@ -3,6 +3,12 @@
3
#include "strbuf.h"
4
#include "url.h"
5
6
+int is_rfc3986_unreserved(char ch)
7
+{
8
+ return isalnum(ch) ||
9
+ ch == '-' || ch == '_' || ch == '.' || ch == '~';
10
+}
11
+
12
int is_urlschemechar(int first_flag, int ch)
13
{
14
/*
url.h
+7
@@ -21,4 +21,11 @@ char *url_decode_parameter_value(const char **query);
21
void end_url_with_slash(struct strbuf *buf, const char *url);
22
void str_end_url_with_slash(const char *url, char **dest);
23
24
+/*
25
+ * The set of unreserved characters as per STD66 (RFC3986) is
26
+ * '[A-Za-z0-9-._~]'. These characters are safe to appear in URI
27
+ * components without percent-encoding.
28
+ */
29
+int is_rfc3986_unreserved(char ch);
30
+
31
#endif /* URL_H */