Skip to content

Commit f898543

Browse files
calvin-wan-googlegitster
authored andcommitted
credential-store: move related functions to credential-store file
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d1344b commit f898543

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

builtin/credential-store.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
7474
die_errno("unable to write credential store");
7575
}
7676

77+
static int is_rfc3986_unreserved(char ch)
78+
{
79+
return isalnum(ch) ||
80+
ch == '-' || ch == '_' || ch == '.' || ch == '~';
81+
}
82+
83+
static int is_rfc3986_reserved_or_unreserved(char ch)
84+
{
85+
if (is_rfc3986_unreserved(ch))
86+
return 1;
87+
switch (ch) {
88+
case '!': case '*': case '\'': case '(': case ')': case ';':
89+
case ':': case '@': case '&': case '=': case '+': case '$':
90+
case ',': case '/': case '?': case '#': case '[': case ']':
91+
return 1;
92+
}
93+
return 0;
94+
}
95+
7796
static void store_credential_file(const char *fn, struct credential *c)
7897
{
7998
struct strbuf buf = STRBUF_INIT;

strbuf.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -810,25 +810,6 @@ void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
810810
}
811811
}
812812

813-
int is_rfc3986_reserved_or_unreserved(char ch)
814-
{
815-
if (is_rfc3986_unreserved(ch))
816-
return 1;
817-
switch (ch) {
818-
case '!': case '*': case '\'': case '(': case ')': case ';':
819-
case ':': case '@': case '&': case '=': case '+': case '$':
820-
case ',': case '/': case '?': case '#': case '[': case ']':
821-
return 1;
822-
}
823-
return 0;
824-
}
825-
826-
int is_rfc3986_unreserved(char ch)
827-
{
828-
return isalnum(ch) ||
829-
ch == '-' || ch == '_' || ch == '.' || ch == '~';
830-
}
831-
832813
static void strbuf_add_urlencode(struct strbuf *sb, const char *s, size_t len,
833814
char_predicate allow_unencoded_fn)
834815
{

strbuf.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,6 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
690690

691691
typedef int (*char_predicate)(char ch);
692692

693-
int is_rfc3986_unreserved(char ch);
694-
int is_rfc3986_reserved_or_unreserved(char ch);
695-
696693
void strbuf_addstr_urlencode(struct strbuf *sb, const char *name,
697694
char_predicate allow_unencoded_fn);
698695

0 commit comments

Comments
 (0)