All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Boeckel <mathstuf@gmail.com>
To: gitster@pobox.com
Cc: Ben Boeckel <mathstuf@gmail.com>, git@vger.kernel.org
Subject: [PATCH] ls-remote: add --get-push-url option
Date: Fri, 31 Jul 2015 13:38:41 -0400	[thread overview]
Message-ID: <1438364321-14646-2-git-send-email-mathstuf@gmail.com> (raw)
In-Reply-To: <1438364321-14646-1-git-send-email-mathstuf@gmail.com>

With pushInsteadOf and triangle workflows, a flag to have git fully
expand the push URL is also useful since it can be very different from
the --get-url output.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
---
 Documentation/git-ls-remote.txt |  7 ++++++-
 builtin/ls-remote.c             | 15 +++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index 2e22915..66cda0e 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git ls-remote' [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]
-	      [--exit-code] <repository> [<refs>...]
+	      [--exit-code] [--get-url | --get-push-url] <repository> [<refs>...]
 
 DESCRIPTION
 -----------
@@ -47,6 +47,11 @@ OPTIONS
 	"url.<base>.insteadOf" config setting (See linkgit:git-config[1]) and
 	exit without talking to the remote.
 
+--get-push-url::
+	Expand the URL of the given remote repository taking into account any
+	"url.<base>.pushInsteadOf" config setting (See linkgit:git-config[1])
+	and exit without talking to the remote.
+
 <repository>::
 	The "remote" repository to query.  This parameter can be
 	either a URL or the name of a remote (see the GIT URLS and
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 4554dbc..25c6f79 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -5,7 +5,7 @@
 
 static const char ls_remote_usage[] =
 "git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\n"
-"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]";
+"                     [-q | --quiet] [--exit-code] [--get-url | --get-push-url] [<repository> [<refs>...]]";
 
 /*
  * Is there one among the list of patterns that match the tail part
@@ -40,6 +40,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	const char **pattern = NULL;
 
 	struct remote *remote;
+	struct remote *pushremote;
 	struct transport *transport;
 	const struct ref *ref;
 
@@ -78,6 +79,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 				get_url = 1;
 				continue;
 			}
+			if (!strcmp("--get-push-url", arg)) {
+				get_url = 2;
+				continue;
+			}
 			if (!strcmp("--exit-code", arg)) {
 				/* return this code if no refs are reported */
 				status = 2;
@@ -109,9 +114,15 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	if (!remote->url_nr)
 		die("remote %s has no configured URL", dest);
 
-	if (get_url) {
+	if (get_url == 1) {
 		printf("%s\n", *remote->url);
 		return 0;
+	} else if (get_url == 2) {
+		pushremote = pushremote_get(dest);
+		if (!pushremote->url_nr)
+			die("remote %s has no configured push URL", dest);
+		printf("%s\n", *pushremote->url);
+		return 0;
 	}
 
 	transport = transport_get(remote, NULL);
-- 
2.1.0

  reply	other threads:[~2015-07-31 17:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 17:38 [PATCH] add ls-remote --get-push-url option Ben Boeckel
2015-07-31 17:38 ` Ben Boeckel [this message]
2015-07-31 18:40 ` Junio C Hamano
2015-07-31 18:56   ` Ben Boeckel
2015-07-31 19:02     ` Junio C Hamano
2015-07-31 19:04       ` Ben Boeckel
2015-07-31 19:16         ` Junio C Hamano
2015-07-31 20:51           ` Ben Boeckel
2015-08-03 21:00 ` [PATCH v2] add git-url subcommand Ben Boeckel
2015-08-03 21:00 ` [PATCH v2] remote: add get-url subcommand Ben Boeckel
2015-08-03 23:38   ` Eric Sunshine
2015-08-04  0:16     ` Ben Boeckel
2015-08-04  0:45       ` Eric Sunshine
2015-08-04 14:56 ` [PATCH v3] " Ben Boeckel
2015-08-05 20:34   ` Junio C Hamano
2015-08-05 21:33     ` Ben Boeckel
2015-08-05 21:39       ` Junio C Hamano
2015-09-04 14:30 ` [PATCH v4] " Ben Boeckel
2015-09-04 22:40   ` Junio C Hamano
2015-09-16  1:53 ` [PATCH v5] " Ben Boeckel
2015-09-16 22:51   ` Junio C Hamano
2015-09-17  0:19 ` [PATCH v6] " Ben Boeckel

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

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

  git send-email \
    --in-reply-to=1438364321-14646-2-git-send-email-mathstuf@gmail.com \
    --to=mathstuf@gmail.com \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.