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

[PATCH v2] make "git remote" report multiple URLs

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 22, 2008, 08:57 UTC
Message-ID
<1222073871-495-1-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<7vej3fswwe.fsf@gitster.siamese.dyndns.org>

This patch makes "git remote -v" and "git remote show" report multiple URLs rather than warn about them. Multiple URLs are OK for pushing into multiple repos simultaneously. Without "-v" each repo is shown once only.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin-remote.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

Change in v2: report each repo once only if "-v" is not used (i.e. URL is not shown), as requested by JC.

JC wrote:
> MJG wrote:
>> This passes all tests, so I think the new output does not break anything.
> Or just there is no existing tests that verify the output from this command.
JC, sounds as if you're a mathematician, as well ;)
diff --git a/builtin-remote.c b/builtin-remote.c
index 01945a8..1e2edc2 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
 {
 	struct string_list *list = priv;
 
-	string_list_append(remote->name, list)->util = remote->url_nr ?
-		(void *)remote->url[0] : NULL;
-	if (remote->url_nr > 1)
-		warning("Remote %s has more than one URL", remote->name);
+	if (remote->url_nr > 0) {
+		int i;
+
+		for (i = 0; i < remote->url_nr; i++)
+			string_list_append(remote->name, list)->util = (void *)remote->url[i];
+	} else
+		string_list_append(remote->name, list)->util = NULL;
 
 	return 0;
 }
@@ -671,10 +674,14 @@ static int show_all(void)
 		sort_string_list(&list);
 		for (i = 0; i < list.nr; i++) {
 			struct string_list_item *item = list.items + i;
-			printf("%s%s%s\n", item->string,
-				verbose ? "\t" : "",
-				verbose && item->util ?
-					(const char *)item->util : "");
+			if (verbose)
+				printf("%s\t%s\n", item->string,
+					item->util ? (const char *)item->util : "");
+			else {
+				if (i && !strcmp((item - 1)->string, item->string))
+					continue;
+				printf("%s\n", item->string);
+			}
 		}
 	}
 	return result;
-- 
1.6.0.2.287.g3791f
Previous: Junio C Hamano
Message 4 of 4 in “Re: git equivalent to svn info?”
  1. Junio C HamanoSep 18, 2008
  2. make "git remote" report multiple URLsMichael J Gruber, Sep 18, 2008
  3. Junio C HamanoSep 19, 2008
  4. make "git remote" report multiple URLsMichael J Gruber, Sep 22, 2008

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.