git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Jardel Weyrich <jweyrich@gmail.com>,
	Sascha Cunz <sascha-ml@babbelbox.org>
Subject: [PATCH] git-remote: distinguish between default and configured URLs
Date: Wed, 16 Jan 2013 11:14:48 +0100	[thread overview]
Message-ID: <a5bf3511b3ecf4e9243d550d11ab977f95ecea30.1358331096.git.git@drmicha.warpmail.net> (raw)
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

  parent reply	other threads:[~2013-01-16 10:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-12  5:44 [BUG] Possible bug in `remote set-url --add --push` Jardel Weyrich
2013-01-12  7:10 ` Junio C Hamano
2013-01-12  8:09   ` Jardel Weyrich
2013-01-12  8:23     ` Junio C Hamano
2013-01-12  8:44   ` Sascha Cunz
2013-01-12  9:33     ` Jardel Weyrich
2013-01-14 13:07       ` Michael J Gruber
2013-01-14 16:41         ` Jonathan Nieder
2013-01-14 19:09         ` Junio C Hamano
2013-01-15  5:20           ` Jardel Weyrich
2013-01-15  6:22             ` Junio C Hamano
2013-01-15  6:39               ` Junio C Hamano
2013-01-15  9:44                 ` Michael J Gruber
2013-01-15 15:53                   ` Junio C Hamano
2013-01-16  8:46                     ` Michael J Gruber
2013-01-16 15:50                       ` Junio C Hamano
2013-01-16 16:19                         ` Michael J Gruber
2013-01-16 19:30                         ` Andreas Schwab
2013-01-16 20:01                           ` Junio C Hamano
2013-01-16 10:14                     ` Michael J Gruber [this message]
2013-01-16 10:27                       ` [PATCH] git-remote: distinguish between default and configured URLs Michael J Gruber
2013-01-16 10:42                       ` John Keeping
2013-01-16 12:45                         ` Michael J Gruber
2013-01-16 13:04                           ` John Keeping
2013-01-16 19:19                           ` Junio C Hamano
2013-01-16 16:15                     ` [BUG] Possible bug in `remote set-url --add --push` Phil Hord
2013-01-16 16:24                       ` Michael J Gruber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5bf3511b3ecf4e9243d550d11ab977f95ecea30.1358331096.git.git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jweyrich@gmail.com \
    --cc=sascha-ml@babbelbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).