git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] credential: remove unnecessary forward declarations

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Apr 24, 2020, 11:23 UTC
Message-ID
<20200424112356.74165-1-carenas@gmail.com>

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
Next: Junio C Hamano
Message 1 of 2 in “credential: remove unnecessary forward declarations”
  1. credential: remove unnecessary forward declarationsCarlo Marcelo Arenas Belón, Apr 24, 2020
  2. Junio C HamanoApr 24, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.