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

[PATCH] git-remote: distinguish between default and configured URLs

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jan 16, 2013, 10:14 UTC
Message-ID
<a5bf3511b3ecf4e9243d550d11ab977f95ecea30.1358331096.git.git@drmicha.warpmail.net>
In-Reply-To
<7v4nii5tp2.fsf@alter.siamese.dyndns.org>

The current output of "git remote -v" does not distinguish between explicitly configured push URLs and those coming from fetch lines.

Revise the output so so that URLs are distinguished by their labels:

(fetch): fetch config used for fetching only (fetch/push): fetch config used for fetching and pushing (fetch fallback/push): fetch config used for pushing only (fetch fallback): fetch config which is unused (push): push config used for pushing

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Maybe something like this? It even seems to make the code in get_one_entry
clearer.
I yet have to look at the tests, doc and other git-remote invocations.
 builtin/remote.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index 937484d..ec07109 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1509,25 +1509,28 @@ static int get_one_entry(struct remote *remote, void *priv)
 {
 	struct string_list *list = priv;
 	struct strbuf url_buf = STRBUF_INIT;
-	const char **url;
-	int i, url_nr;
+	char *fetchurl0, *fetchurl1;
+	int i;
+
+	if (remote->pushurl_nr > 0) {
+		fetchurl0 = "fetch";
+		fetchurl1 = "fetch fallback";
+	} else {
+		fetchurl0 = "fetch/push";
+		fetchurl1 = "fetch fallback/push";
+	}
 
-	if (remote->url_nr > 0) {
-		strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
+	for (i = 0; i < remote->url_nr; i++) {
+		strbuf_addf(&url_buf, "%s (%s)", remote->url[0], i ? fetchurl1 : fetchurl0);
 		string_list_append(list, remote->name)->util =
 				strbuf_detach(&url_buf, NULL);
-	} else
+	} /* else */
+	if (remote->url_nr == 0)
 		string_list_append(list, remote->name)->util = NULL;
-	if (remote->pushurl_nr) {
-		url = remote->pushurl;
-		url_nr = remote->pushurl_nr;
-	} else {
-		url = remote->url;
-		url_nr = remote->url_nr;
-	}
-	for (i = 0; i < url_nr; i++)
+
+	for (i = 0; i < remote->pushurl_nr; i++)
 	{
-		strbuf_addf(&url_buf, "%s (push)", url[i]);
+		strbuf_addf(&url_buf, "%s (push)", remote->pushurl[i]);
 		string_list_append(list, remote->name)->util =
 				strbuf_detach(&url_buf, NULL);
 	}
-- 
1.8.1.1.456.g93e7b0a
Previous: Junio C HamanoNext: Michael J Gruber
Message 20 of 27 in “[BUG] Possible bug in `remote set-url --add --push`”
  1. Jardel WeyrichJan 12, 2013
  2. Junio C HamanoJan 12, 2013
  3. Jardel WeyrichJan 12, 2013
  4. Junio C HamanoJan 12, 2013
  5. Sascha CunzJan 12, 2013
  6. Jardel WeyrichJan 12, 2013
  7. Michael J GruberJan 14, 2013
  8. Jonathan NiederJan 14, 2013
  9. Junio C HamanoJan 14, 2013
  10. Jardel WeyrichJan 15, 2013
  11. Junio C HamanoJan 15, 2013
  12. Junio C HamanoJan 15, 2013
  13. Michael J GruberJan 15, 2013
  14. Junio C HamanoJan 15, 2013
  15. Michael J GruberJan 16, 2013
  16. Junio C HamanoJan 16, 2013
  17. Michael J GruberJan 16, 2013
  18. Andreas SchwabJan 16, 2013
  19. Junio C HamanoJan 16, 2013
  20. git-remote: distinguish between default and configured URLsMichael J Gruber, Jan 16, 2013
  21. Michael J GruberJan 16, 2013
  22. John KeepingJan 16, 2013
  23. Michael J GruberJan 16, 2013
  24. John KeepingJan 16, 2013
  25. Junio C HamanoJan 16, 2013
  26. Phil HordJan 16, 2013
  27. Michael J GruberJan 16, 2013

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.