]> git.ipfire.org Git - thirdparty/git.git/commitdiff
credential-store: move related functions to credential-store file
authorCalvin Wan <calvinwan@google.com>
Tue, 6 Jun 2023 19:48:40 +0000 (19:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jun 2023 20:49:36 +0000 (13:49 -0700)
is_rfc3986_unreserved() and is_rfc3986_reserved_or_unreserved() are only
called from builtin/credential-store.c and they are only relevant to that
file so move those functions and make them static.

Signed-off-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/credential-store.c
strbuf.c
strbuf.h

index 30c6ccf56c05df3ae6e14497a5c6b719f933fecb..5eea5bdb584f44587fa4232004b23df0fe4e7812 100644 (file)
@@ -74,6 +74,25 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
                die_errno("unable to write credential store");
 }
 
+static int is_rfc3986_unreserved(char ch)
+{
+       return isalnum(ch) ||
+               ch == '-' || ch == '_' || ch == '.' || ch == '~';
+}
+
+static int is_rfc3986_reserved_or_unreserved(char ch)
+{
+       if (is_rfc3986_unreserved(ch))
+               return 1;
+       switch (ch) {
+               case '!': case '*': case '\'': case '(': case ')': case ';':
+               case ':': case '@': case '&': case '=': case '+': case '$':
+               case ',': case '/': case '?': case '#': case '[': case ']':
+                       return 1;
+       }
+       return 0;
+}
+
 static void store_credential_file(const char *fn, struct credential *c)
 {
        struct strbuf buf = STRBUF_INIT;
index a2249ae7edc1e1951ee6cb864e5882acb4327605..5244029d91335372343f279f64d2d2ba4b91987d 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -810,25 +810,6 @@ void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
        }
 }
 
-int is_rfc3986_reserved_or_unreserved(char ch)
-{
-       if (is_rfc3986_unreserved(ch))
-               return 1;
-       switch (ch) {
-               case '!': case '*': case '\'': case '(': case ')': case ';':
-               case ':': case '@': case '&': case '=': case '+': case '$':
-               case ',': case '/': case '?': case '#': case '[': case ']':
-                       return 1;
-       }
-       return 0;
-}
-
-int is_rfc3986_unreserved(char ch)
-{
-       return isalnum(ch) ||
-               ch == '-' || ch == '_' || ch == '.' || ch == '~';
-}
-
 static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
                                 char_predicate allow_unencoded_fn)
 {
index 207efb4f98c9fab7e90c0a949a033b43ce9ca9e3..114ad0c02445767a01d2978880f1135afe89bf21 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -690,9 +690,6 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
 
 typedef int (*char_predicate)(char ch);
 
-int is_rfc3986_unreserved(char ch);
-int is_rfc3986_reserved_or_unreserved(char ch);
-
 void strbuf_addstr_urlencode(struct strbuf *sb, const char *name,
                             char_predicate allow_unencoded_fn);