Re: [PATCH 2/6] credential-store: move related functions to credential-store file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 2, 2023, 21:52 UTC
- Message-ID
- <xmqq1qjyz9ib.fsf@gitster.g>
- In-Reply-To
- <20230502211454.1673000-3-calvinwan@google.com>
Calvin Wan <calvinwan@google.com> writes:
Show 37 quoted lines
> 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>
> ---
> builtin/credential-store.c | 19 +++++++++++++++++++
> strbuf.c | 19 -------------------
> strbuf.h | 3 ---
> 3 files changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/builtin/credential-store.c b/builtin/credential-store.c
> index 8977604eb9..4776118331 100644
> --- a/builtin/credential-store.c
> +++ b/builtin/credential-store.c
> @@ -73,6 +73,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;
> +}Both the moved ones being static means we even lose the declarations in the header file. Very nice.