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>
Subject: [PATCHv2 4/5] builtin-remote: Show push urls as well
Date: Sat, 13 Jun 2009 18:29:10 +0200	[thread overview]
Message-ID: <1244910551-4420-2-git-send-email-git@drmicha.warpmail.net> (raw)
In-Reply-To: <1244910551-4420-1-git-send-email-git@drmicha.warpmail.net>

Teach builtin remote to show push urls also when asked to
"show" a specific remote.

This improves upon the standard display mode: multiple specified "url"s
mean that the first one is for fetching, all are used for pushing. We
make this clearer now by displaying the first one prefixed with "Fetch
URL", and all "url"s (or, if present, all "pushurl"s) prefixed with
"Push  URL".

Example with "one" having one url, "two" two urls, "three" one url and
one pushurl (URL part only):

* remote one
  Fetch URL: hostone.com:/somepath/repoone.git
  Push  URL: hostone.com:/somepath/repoone.git
* remote two
  Fetch URL: hosttwo.com:/somepath/repotwo.git
  Push  URL: hosttwo.com:/somepath/repotwo.git
  Push  URL: hosttwobackup.com:/somewheresafe/repotwo.git
* remote three
  Fetch URL: http://hostthree.com/otherpath/repothree.git
  Push  URL: hostthree.com:/pathforpushes/repothree.git

Also, adjust t5505 accordingly and make it test for the new output.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin-remote.c  |   20 +++++++++++++++-----
 t/t5505-remote.sh |   10 +++++++---
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index dfc0b9e..b350b18 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -999,15 +999,25 @@ static int show(int argc, const char **argv)
 	info.list = &info_list;
 	for (; argc; argc--, argv++) {
 		int i;
+		const char **url;
+		int url_nr;
 
 		get_remote_ref_states(*argv, &states, query_flag);
 
 		printf("* remote %s\n", *argv);
-		if (states.remote->url_nr) {
-			for (i=0; i < states.remote->url_nr; i++)
-				printf("  URL: %s\n", states.remote->url[i]);
-		} else
-			printf("  URL: %s\n", "(no URL)");
+		printf("  Fetch URL: %s\n", states.remote->url_nr > 0 ?
+			states.remote->url[0] : "(no URL)");
+		if (states.remote->pushurl_nr) {
+			url = states.remote->pushurl;
+			url_nr = states.remote->pushurl_nr;
+		} else {
+			url = states.remote->url;
+			url_nr = states.remote->url_nr;
+		}
+		for (i=0; i < url_nr; i++)
+			printf("  Push  URL: %s\n", url[i]);
+		if (!i)
+			printf("  Push  URL: %s\n", "(no URL)");
 		if (no_query)
 			printf("  HEAD branch: (not queried)\n");
 		else if (!states.heads.nr)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index e70246b..852ccb5 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -135,7 +135,8 @@ EOF
 
 cat > test/expect << EOF
 * remote origin
-  URL: $(pwd)/one
+  Fetch URL: $(pwd)/one
+  Push  URL: $(pwd)/one
   HEAD branch: master
   Remote branches:
     master new (next fetch will store in remotes/origin)
@@ -151,7 +152,8 @@ cat > test/expect << EOF
     master pushes to master   (local out of date)
     master pushes to upstream (create)
 * remote two
-  URL: ../two
+  Fetch URL: ../two
+  Push  URL: ../three
   HEAD branch (remote HEAD is ambiguous, may be one of the following):
     another
     master
@@ -173,6 +175,7 @@ test_expect_success 'show' '
 	 git branch --track rebase origin/master &&
 	 git branch -d -r origin/master &&
 	 git config --add remote.two.url ../two &&
+	 git config --add remote.two.pushurl ../three &&
 	 git config branch.rebase.rebase true &&
 	 git config branch.octopus.merge "topic-a topic-b topic-c" &&
 	 (cd ../one &&
@@ -191,7 +194,8 @@ test_expect_success 'show' '
 
 cat > test/expect << EOF
 * remote origin
-  URL: $(pwd)/one
+  Fetch URL: $(pwd)/one
+  Push  URL: $(pwd)/one
   HEAD branch: (not queried)
   Remote branches: (status not queried)
     master
-- 
1.6.3.2.367.gf0de

  reply	other threads:[~2009-06-13 16:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09 16:01 [PATCH 0/5] Allow push and fetch urls to be different Michael J Gruber
2009-06-09 16:01 ` [PATCH 1/5] " Michael J Gruber
2009-06-09 16:01   ` [PATCH 2/5] t5516: Check pushurl config setting Michael J Gruber
2009-06-09 16:01     ` [PATCH 3/5] technical/api-remote: Describe new struct remote member pushurl Michael J Gruber
2009-06-09 16:01       ` [PATCH 4/5] builtin-remote: Show push urls as well Michael J Gruber
2009-06-09 16:01         ` [PATCH 5/5] builtin-remote: Make "remote -v" display push urls Michael J Gruber
2009-06-09 16:25           ` Junio C Hamano
2009-06-09 17:47             ` Michael J Gruber
2009-06-09 18:30               ` Junio C Hamano
2009-06-13 16:29                 ` [PATCHv2 0/5] " Michael J Gruber
2009-06-13 16:29                   ` Michael J Gruber [this message]
2009-06-13 16:29                     ` [PATCHv2 5/5] " Michael J Gruber
2009-06-14  5:54                       ` Junio C Hamano
2009-06-09 16:25           ` [PATCH " Bert Wesarg
2009-06-09 18:07             ` 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=1244910551-4420-2-git-send-email-git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).