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

[PATCHv2 5/5] builtin-remote: Make "remote -v" display push urls

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 13, 2009, 16:29 UTC
Message-ID
<1244910551-4420-3-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<1244910551-4420-2-git-send-email-git@drmicha.warpmail.net>

Currently, "remote -v" simply lists all urls so that one has to remember that only the first one is used for fetches, and all are used for pushes.

Change this so that the role of an url is displayed in parentheses, and also display push urls.

Example with "one" having one url, "two" two urls, "three" one url and one pushurl:

one hostone.com:/somepath/repoone.git (fetch) one hostone.com:/somepath/repoone.git (push) three http://hostthree.com/otherpath/repothree.git (fetch) three hostthree.com:/pathforpushes/repothree.git (push) two hosttwo.com:/somepath/repotwo.git (fetch) two hosttwo.com:/somepath/repotwo.git (push) two hosttwobackup.com:/somewheresafe/repotwo.git (push)

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin-remote.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index b350b18..80b2536 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -1276,14 +1276,31 @@ static int update(int argc, const char **argv)
 static int get_one_entry(struct remote *remote, void *priv)
 {
 	struct string_list *list = priv;
+	const char **url;
+	int i, url_nr;
+	void **utilp;
 
 	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];
+		utilp = &(string_list_append(remote->name, list)->util);
+		*utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
+		strcpy((char *) *utilp, remote->url[0]);
+		strcat((char *) *utilp, " (fetch)");
 	} else
 		string_list_append(remote->name, list)->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++)
+	{
+		utilp = &(string_list_append(remote->name, list)->util);
+		*utilp = malloc(strlen(url[i])+strlen(" (push)")+1);
+		strcpy((char *) *utilp, url[i]);
+		strcat((char *) *utilp, " (push)");
+	}
 
 	return 0;
 }
@@ -1291,6 +1308,7 @@ static int get_one_entry(struct remote *remote, void *priv)
 static int show_all(void)
 {
 	struct string_list list = { NULL, 0, 0 };
+	list.strdup_strings = 1;
 	int result = for_each_remote(get_one_entry, &list);
 
 	if (!result) {
@@ -1309,6 +1327,7 @@ static int show_all(void)
 			}
 		}
 	}
+	string_list_clear(&list, 1);
 	return result;
 }
 
-- 
1.6.3.2.367.gf0de
Previous: Michael J GruberNext: Junio C Hamano
Message 12 of 15 in “Allow push and fetch urls to be different”
  1. 0/5 Allow push and fetch urls to be differentMichael J Gruber, Jun 9, 2009
  2. 1/5 Allow push and fetch urls to be differentMichael J Gruber, Jun 9, 2009
  3. 2/5 t5516: Check pushurl config settingMichael J Gruber, Jun 9, 2009
  4. 3/5 technical/api-remote: Describe new struct remote member pushurlMichael J Gruber, Jun 9, 2009
  5. 4/5 builtin-remote: Show push urls as wellMichael J Gruber, Jun 9, 2009
  6. 5/5 builtin-remote: Make "remote -v" display push urlsMichael J Gruber, Jun 9, 2009
  7. Junio C HamanoJun 9, 2009
  8. Michael J GruberJun 9, 2009
  9. Junio C HamanoJun 9, 2009
  10. 0/5 builtin-remote: Make "remote -v" display push urlsMichael J Gruber, Jun 13, 2009
  11. 4/5 builtin-remote: Show push urls as wellMichael J Gruber, Jun 13, 2009
  12. 5/5 builtin-remote: Make "remote -v" display push urlsMichael J Gruber, Jun 13, 2009
  13. Junio C HamanoJun 14, 2009
  14. Bert WesargJun 9, 2009
  15. Michael J GruberJun 9, 2009

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.