{"thread":{"id":"53307","subject":"[PATCH] credential: remove unnecessary forward declarations","startedAt":"2020-04-24T11:24:00Z","lastAt":"2020-04-24T20:26:15Z","messageCount":2,"participants":["Carlo Marcelo Arenas Belón","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"396121","messageId":"20200424112356.74165-1-carenas@gmail.com","threadId":"53307","inReplyTo":null,"subject":"[PATCH] credential: remove unnecessary forward declarations","fromName":"Carlo Marcelo Arenas Belón","fromEmail":"carenas@gmail.com","sentAt":"2020-04-24T11:23:56Z","receivedAt":"2020-04-24T11:24:00Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"46fd7b3900 (credential: allow wildcard patterns when matching config,\n2020-02-20) introduced a forward declaration for credential_describe()\nthat wasn't needed as well as a forward declaration for a similar\nfunction that was implemented a few lines below.\n\nremove the unnecessary forward declarations by moving the function\nto where it is needed instead.\n\nSigned-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n---\n credential.c | 37 +++++++++++++++++--------------------\n 1 file changed, 17 insertions(+), 20 deletions(-)\n\ndiff --git a/credential.c b/credential.c\nindex 064e25e5d5..24eabe8929 100644\n--- a/credential.c\n+++ b/credential.c\n@@ -73,15 +73,29 @@ static int proto_is_http(const char *s)\n \treturn !strcmp(s, \"https\") || !strcmp(s, \"http\");\n }\n \n-static void credential_describe(struct credential *c, struct strbuf *out);\n-static void credential_format(struct credential *c, struct strbuf *out);\n-\n static int select_all(const struct urlmatch_item *a,\n \t\t      const struct urlmatch_item *b)\n {\n \treturn 0;\n }\n \n+static void credential_format(struct credential *c, struct strbuf *out)\n+{\n+\tif (!c->protocol)\n+\t\treturn;\n+\tstrbuf_addf(out, \"%s://\", c->protocol);\n+\tif (c->username && *c->username) {\n+\t\tstrbuf_add_percentencode(out, c->username);\n+\t\tstrbuf_addch(out, '@');\n+\t}\n+\tif (c->host)\n+\t\tstrbuf_addstr(out, c->host);\n+\tif (c->path) {\n+\t\tstrbuf_addch(out, '/');\n+\t\tstrbuf_add_percentencode(out, c->path);\n+\t}\n+}\n+\n static void credential_apply_config(struct credential *c)\n {\n \tchar *normalized_url;\n@@ -130,23 +144,6 @@ static void credential_describe(struct credential *c, struct strbuf *out)\n \t\tstrbuf_addf(out, \"/%s\", c->path);\n }\n \n-static void credential_format(struct credential *c, struct strbuf *out)\n-{\n-\tif (!c->protocol)\n-\t\treturn;\n-\tstrbuf_addf(out, \"%s://\", c->protocol);\n-\tif (c->username && *c->username) {\n-\t\tstrbuf_add_percentencode(out, c->username);\n-\t\tstrbuf_addch(out, '@');\n-\t}\n-\tif (c->host)\n-\t\tstrbuf_addstr(out, c->host);\n-\tif (c->path) {\n-\t\tstrbuf_addch(out, '/');\n-\t\tstrbuf_add_percentencode(out, c->path);\n-\t}\n-}\n-\n static char *credential_ask_one(const char *what, struct credential *c,\n \t\t\t\tint flags)\n {\n-- \n2.26.2.569.g1d74ac4d14\n\n"},{"id":"396175","messageId":"xmqq7dy4d40s.fsf@gitster.c.googlers.com","threadId":"53307","inReplyTo":"20200424112356.74165-1-carenas@gmail.com","subject":"Re: [PATCH] credential: remove unnecessary forward declarations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-24T20:26:11Z","receivedAt":"2020-04-24T20:26:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlo Marcelo Arenas Belón  <carenas@gmail.com> writes:\n\n> 46fd7b3900 (credential: allow wildcard patterns when matching config,\n> 2020-02-20) introduced a forward declaration for credential_describe()\n> that wasn't needed as well as a forward declaration for a similar\n> function that was implemented a few lines below.\n>\n> remove the unnecessary forward declarations by moving the function\n> to where it is needed instead.\n>\n> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>\n> ---\n>  credential.c | 37 +++++++++++++++++--------------------\n>  1 file changed, 17 insertions(+), 20 deletions(-)\n\nI would rather not to see this kind of code churn for \"this way it\nis cleaner\" (as opposed to \"this is broken and needs fixing\") in the\narea of code that were _very_ actively touched and across _wide_\nrange of versions.  Maybe long after the dust from 2.17.4 and\nfriends settles, but not now.\n\nThanks.\n"}]}