git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, bturner@atlassian.com, gitster@pobox.com,
	pedrorijo91@gmail.com, Thomas Gummerer <t.gummerer@gmail.com>
Subject: [PATCH v2 0/5] ls-remote: introduce symrefs argument
Date: Mon, 18 Jan 2016 17:57:13 +0100	[thread overview]
Message-ID: <1453136238-19448-1-git-send-email-t.gummerer@gmail.com> (raw)
In-Reply-To: <1453028643-13978-1-git-send-email-t.gummerer@gmail.com>

The previous round is at $gmane/284248.  Thanks to Peff an Junio for
comments on the previous round.

Changes from the previous round:
 - added patch documenting the --refs option
 - addressed peffs comments on the parse-option patch
 - the symrefs format now uses only ref: as an indicator for a symref
 - symrefs are now shown in addition to the other refs, instead of
   replacing them in the output.
 - symrefs are now filtered by the same rules as other refs.

Interdiff below:

diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index 5b606dd..9356df2 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -9,7 +9,7 @@ git-ls-remote - List references in a remote repository
 SYNOPSIS
 --------
 [verse]
-'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]
+'git ls-remote' [--heads] [--tags] [--refs] [--upload-pack=<exec>]
 	      [-q | --quiet] [--exit-code] [--get-url]
 	      [--symrefs] [<repository> [<refs>...]]
 
@@ -30,6 +30,10 @@ OPTIONS
 	both, references stored in refs/heads and refs/tags are
 	displayed.
 
+--refs::
+	Do not show peeled tags or pseudo-refs like HEAD or MERGE_HEAD
+	in the output.
+
 -q::
 --quiet::
 	Do not print remote URL to stderr.
@@ -52,9 +56,7 @@ OPTIONS
 	exit without talking to the remote.
 
 --symrefs::
-	Show the symrefs on the server.  Shows only the symrefs by
-	default, and can be combined with --tags and --heads to show
-	refs/heads and refs/tags as well.
+	Show the symrefs in addition to the other refs.
 
 <repository>::
 	The "remote" repository to query.  This parameter can be
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index f33ada9..ea73d53 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -4,7 +4,7 @@
 #include "remote.h"
 
 static const char * const ls_remote_usage[] = {
-	N_("git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\n"
+	N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
 	   "                     [-q | --quiet] [--exit-code] [--get-url]\n"
 	   "                     [--symrefs] [<repository> [<refs>...]]"),
 	NULL
@@ -38,7 +38,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	int get_url = 0;
 	int quiet = 0;
 	int status = 0;
-	int tags = 0, heads = 0, refs = 0;
 	int symrefs = 0;
 	const char *uploadpack = NULL;
 	const char **pattern = NULL;
@@ -51,13 +50,14 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 		OPT__QUIET(&quiet, N_("do not print remote URL")),
 		OPT_STRING(0, "upload-pack", &uploadpack, N_("exec"),
 			   N_("path of git-upload-pack on the remote host")),
-		OPT_STRING(0, "exec", &uploadpack, N_("exec"),
-			   N_("path of git-upload-pack on the remote host")),
-		OPT_SET_INT('t', "tags", &tags, N_("limit to tags"), REF_TAGS),
-		OPT_SET_INT('h', "heads", &heads, N_("limit to heads"), REF_HEADS),
-		OPT_SET_INT(0, "refs", &refs, N_("no magic fake tag refs"), REF_NORMAL),
-		OPT_SET_INT(0, "get-url", &get_url,
-			    N_("take url.<base>.insteadOf into account"), 1),
+		{ OPTION_STRING, 0, "exec", &uploadpack, N_("exec"),
+			   N_("path of git-upload-pack on the remote host"),
+			   PARSE_OPT_HIDDEN },
+		OPT_BIT('t', "tags", &flags, N_("limit to tags"), REF_TAGS),
+		OPT_BIT('h', "heads", &flags, N_("limit to heads"), REF_HEADS),
+		OPT_BIT(0, "refs", &flags, N_("do not show peeled tags"), REF_NORMAL),
+		OPT_BOOL(0, "get-url", &get_url,
+			 N_("take url.<base>.insteadOf into account")),
 		OPT_SET_INT(0, "exit-code", &status,
 			    N_("exit with exit code 2 if no matching refs are found"), 2),
 		OPT_BOOL(0, "symrefs", &symrefs, N_("show symrefs")),
@@ -66,7 +66,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 
 	argc = parse_options(argc, argv, prefix, options, ls_remote_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
-	flags = tags | heads | refs;
 	dest = argv[0];
 
 	if (argc > 1) {
@@ -101,15 +100,13 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	if (!dest && !quiet)
 		fprintf(stderr, "From %s\n", *remote->url);
 	for ( ; ref; ref = ref->next) {
-		if (symrefs && ref->symref)
-			printf("symref: %s	%s\n", ref->symref, ref->name);
-		if (symrefs && !flags)
-			continue;
 		if (!check_ref_type(ref, flags))
 			continue;
 		if (!tail_match(pattern, ref->name))
 			continue;
-		printf("%s	%s\n", oid_to_hex(&ref->old_oid), ref->name);
+		if (symrefs && ref->symref)
+			printf("ref: %s\t%s\n", ref->symref, ref->name);
+		printf("%s\t%s\n", oid_to_hex(&ref->old_oid), ref->name);
 		status = 0; /* we found something */
 	}
 	return status;
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 68a1429..3edbc9e 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -165,21 +165,23 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'
 
 test_expect_success 'ls-remote --symrefs' '
 	cat >expect <<-EOF &&
-	symref: refs/heads/master	HEAD
+	ref: refs/heads/master	HEAD
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	HEAD
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/master
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/remotes/origin/HEAD
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/remotes/origin/master
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/tags/mark
 	EOF
 	git ls-remote --symrefs >actual &&
 	test_cmp expect actual
 '
 
-test_expect_success 'ls-remote with symrefs and refs combined' '
+test_expect_success 'ls-remote with filtered symrefs' '
 	cat >expect <<-EOF &&
-	symref: refs/heads/master	HEAD
-	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/master
-	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/remotes/origin/HEAD
-	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/remotes/origin/master
-	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/tags/mark
+	ref: refs/heads/master	HEAD
+	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	HEAD
 	EOF
-	git ls-remote --symrefs --refs >actual &&
+	git ls-remote --symrefs . HEAD >actual &&
 	test_cmp expect actual
 '
 
Thomas Gummerer (5):
  ls-remote: document --quiet option
  ls-remote: document --refs option
  ls-remote: fix synopsis
  ls-remote: use parse-options api
  ls-remote: add support for showing symrefs

 Documentation/git-ls-remote.txt | 16 +++++++-
 builtin/ls-remote.c             | 89 ++++++++++++++++-------------------------
 t/t5512-ls-remote.sh            | 22 ++++++++++
 3 files changed, 71 insertions(+), 56 deletions(-)

-- 
2.7.0.30.gd0a78e9.dirty

  parent reply	other threads:[~2016-01-18 16:57 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17 11:03 [PATCH 0/4] ls-remote: introduce symref argument Thomas Gummerer
2016-01-17 11:03 ` [PATCH 1/4] ls-remote: document --quiet option Thomas Gummerer
2016-01-17 14:47   ` Jeff King
2016-01-17 17:13     ` Thomas Gummerer
2016-01-17 11:04 ` [PATCH 2/4] ls-remote: fix synopsis Thomas Gummerer
2016-01-17 11:04 ` [PATCH 3/4] ls-remote: use parse-options api Thomas Gummerer
2016-01-17 14:44   ` Jeff King
2016-01-17 17:27     ` Thomas Gummerer
2016-01-17 11:04 ` [PATCH 4/4] builtin/ls-remote: add support for showing symrefs Thomas Gummerer
2016-01-17 11:16   ` Thomas Gummerer
2016-01-17 11:04 ` [PATCH 4/4] ls-remote: " Thomas Gummerer
2016-01-17 15:15   ` Jeff King
2016-01-17 17:38     ` Thomas Gummerer
2016-01-17 22:14     ` Junio C Hamano
2016-01-17 11:14 ` [PATCH 0/4] ls-remote: introduce symref argument Thomas Gummerer
2016-01-17 15:16 ` Jeff King
2016-01-17 17:39   ` Thomas Gummerer
2016-01-17 22:15   ` Junio C Hamano
2016-01-18 16:57 ` Thomas Gummerer [this message]
2016-01-18 16:57   ` [PATCH v2 1/5] ls-remote: document --quiet option Thomas Gummerer
2016-01-18 16:57   ` [PATCH v2 2/5] ls-remote: document --refs option Thomas Gummerer
2016-01-18 19:31     ` Jeff King
2016-01-18 20:01       ` Junio C Hamano
2016-01-18 21:39         ` Thomas Gummerer
2016-01-18 16:57   ` [PATCH v2 3/5] ls-remote: fix synopsis Thomas Gummerer
2016-01-18 16:57   ` [PATCH v2 4/5] ls-remote: use parse-options api Thomas Gummerer
2016-01-18 19:33     ` Jeff King
2016-01-18 16:57   ` [PATCH v2 5/5] ls-remote: add support for showing symrefs Thomas Gummerer
2016-01-18 19:52     ` Jeff King
2016-01-18 19:53       ` Jeff King
2016-01-18 22:09         ` Thomas Gummerer
2016-01-18 22:09       ` Thomas Gummerer
2016-01-18 22:20         ` Jeff King
2016-01-18 22:35           ` Thomas Gummerer
2016-01-18 20:09     ` Junio C Hamano
2016-01-18 21:48       ` Thomas Gummerer
2016-01-18 19:53   ` [PATCH v2 0/5] ls-remote: introduce symrefs argument Jeff King
2016-01-18 23:20   ` [PATCH v3 0/5] ls-remote: introduce symref argument Thomas Gummerer
2016-01-18 23:20     ` [PATCH v3 1/5] ls-remote: document --quiet option Thomas Gummerer
2016-01-18 23:20     ` [PATCH v3 2/5] ls-remote: document --refs option Thomas Gummerer
2016-01-18 23:20     ` [PATCH v3 3/5] ls-remote: fix synopsis Thomas Gummerer
2016-01-18 23:20     ` [PATCH v3 4/5] ls-remote: use parse-options api Thomas Gummerer
2016-01-18 23:20     ` [PATCH v3 5/5] ls-remote: add support for showing symrefs Thomas Gummerer
2016-01-19 18:14     ` [PATCH v3 0/5] ls-remote: introduce symref argument Junio C Hamano

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=1453136238-19448-1-git-send-email-t.gummerer@gmail.com \
    --to=t.gummerer@gmail.com \
    --cc=bturner@atlassian.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pedrorijo91@gmail.com \
    --cc=peff@peff.net \
    /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 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 NNTP newsgroup(s).