* [PATCH] credential: remove unnecessary forward declarations
@ 2020-04-24 11:23 Carlo Marcelo Arenas Belón
2020-04-24 20:26 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2020-04-24 11:23 UTC (permalink / raw)
To: git; +Cc: sandals, Carlo Marcelo Arenas Belón
46fd7b3900 (credential: allow wildcard patterns when matching config,
2020-02-20) introduced a forward declaration for credential_describe()
that wasn't needed as well as a forward declaration for a similar
function that was implemented a few lines below.
remove the unnecessary forward declarations by moving the function
to where it is needed instead.
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
credential.c | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/credential.c b/credential.c
index 064e25e5d5..24eabe8929 100644
--- a/credential.c
+++ b/credential.c
@@ -73,15 +73,29 @@ static int proto_is_http(const char *s)
return !strcmp(s, "https") || !strcmp(s, "http");
}
-static void credential_describe(struct credential *c, struct strbuf *out);
-static void credential_format(struct credential *c, struct strbuf *out);
-
static int select_all(const struct urlmatch_item *a,
const struct urlmatch_item *b)
{
return 0;
}
+static void credential_format(struct credential *c, struct strbuf *out)
+{
+ if (!c->protocol)
+ return;
+ strbuf_addf(out, "%s://", c->protocol);
+ if (c->username && *c->username) {
+ strbuf_add_percentencode(out, c->username);
+ strbuf_addch(out, '@');
+ }
+ if (c->host)
+ strbuf_addstr(out, c->host);
+ if (c->path) {
+ strbuf_addch(out, '/');
+ strbuf_add_percentencode(out, c->path);
+ }
+}
+
static void credential_apply_config(struct credential *c)
{
char *normalized_url;
@@ -130,23 +144,6 @@ static void credential_describe(struct credential *c, struct strbuf *out)
strbuf_addf(out, "/%s", c->path);
}
-static void credential_format(struct credential *c, struct strbuf *out)
-{
- if (!c->protocol)
- return;
- strbuf_addf(out, "%s://", c->protocol);
- if (c->username && *c->username) {
- strbuf_add_percentencode(out, c->username);
- strbuf_addch(out, '@');
- }
- if (c->host)
- strbuf_addstr(out, c->host);
- if (c->path) {
- strbuf_addch(out, '/');
- strbuf_add_percentencode(out, c->path);
- }
-}
-
static char *credential_ask_one(const char *what, struct credential *c,
int flags)
{
--
2.26.2.569.g1d74ac4d14
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] credential: remove unnecessary forward declarations
2020-04-24 11:23 [PATCH] credential: remove unnecessary forward declarations Carlo Marcelo Arenas Belón
@ 2020-04-24 20:26 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2020-04-24 20:26 UTC (permalink / raw)
To: Carlo Marcelo Arenas Belón; +Cc: git, sandals
Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
> 46fd7b3900 (credential: allow wildcard patterns when matching config,
> 2020-02-20) introduced a forward declaration for credential_describe()
> that wasn't needed as well as a forward declaration for a similar
> function that was implemented a few lines below.
>
> remove the unnecessary forward declarations by moving the function
> to where it is needed instead.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> credential.c | 37 +++++++++++++++++--------------------
> 1 file changed, 17 insertions(+), 20 deletions(-)
I would rather not to see this kind of code churn for "this way it
is cleaner" (as opposed to "this is broken and needs fixing") in the
area of code that were _very_ actively touched and across _wide_
range of versions. Maybe long after the dust from 2.17.4 and
friends settles, but not now.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-24 20:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 11:23 [PATCH] credential: remove unnecessary forward declarations Carlo Marcelo Arenas Belón
2020-04-24 20:26 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).