All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: peff@peff.net
Cc: bturner@atlassian.com, gitster@pobox.com, pedrorijo91@gmail.com,
	git@vger.kernel.org
Subject: Re: [PATCH 4/4] builtin/ls-remote: add support for showing symrefs
Date: Sun, 17 Jan 2016 12:16:21 +0100	[thread overview]
Message-ID: <20160117111621.GB7100@hank> (raw)
In-Reply-To: <1453028643-13978-5-git-send-email-t.gummerer@gmail.com>

On 01/17, Thomas Gummerer wrote:
> Sometimes it's useful to know the main branch of a git repository
> without actually downloading the repository.  This can be done by
> looking at the symrefs stored in the remote repository.  Currently git
> doesn't provide a simple way to show the symrefs stored on the remote
> repository, even though the information is available.  Add a --symrefs
> command line argument to the ls-remote command, which shows the symrefs
> on the remote repository.
>
> Suggested-by: pedro rijo <pedrorijo91@gmail.com>
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> ---

I meant to delete this, the other 4/4 has the re-worded commit
message.  Please ignore this one.

>  Documentation/git-ls-remote.txt |  8 +++++++-
>  builtin/ls-remote.c             |  9 ++++++++-
>  t/t5512-ls-remote.sh            | 20 ++++++++++++++++++++
>  3 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
> index 31c1427..5efef9e 100644
> --- a/Documentation/git-ls-remote.txt
> +++ b/Documentation/git-ls-remote.txt
> @@ -10,7 +10,8 @@ SYNOPSIS
>  --------
>  [verse]
>  'git ls-remote' [--heads] [--tags]  [--upload-pack=<exec>]
> -	      [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]
> +	      [-q | --quiet] [--exit-code]
> +	      [--symrefs] [--get-url] [<repository> [<refs>...]]
>
>  DESCRIPTION
>  -----------
> @@ -50,6 +51,11 @@ OPTIONS
>  	"url.<base>.insteadOf" config setting (See linkgit:git-config[1]) and
>  	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.
> +
>  <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 6ee7b0e..f33ada9 100644
> --- a/builtin/ls-remote.c
> +++ b/builtin/ls-remote.c
> @@ -5,7 +5,8 @@
>
>  static const char * const ls_remote_usage[] = {
>  	N_("git ls-remote [--heads] [--tags]  [--upload-pack=<exec>]\n"
> -	   "                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]"),
> +	   "                     [-q | --quiet] [--exit-code] [--get-url]\n"
> +	   "                     [--symrefs] [<repository> [<refs>...]]"),
>  	NULL
>  };
>
> @@ -38,6 +39,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
>  	int quiet = 0;
>  	int status = 0;
>  	int tags = 0, heads = 0, refs = 0;
> +	int symrefs = 0;
>  	const char *uploadpack = NULL;
>  	const char **pattern = NULL;
>
> @@ -58,6 +60,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
>  			    N_("take url.<base>.insteadOf into account"), 1),
>  		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")),
>  		OPT_END()
>  	};
>
> @@ -98,6 +101,10 @@ 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))
> diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
> index aadaac5..68a1429 100755
> --- a/t/t5512-ls-remote.sh
> +++ b/t/t5512-ls-remote.sh
> @@ -163,4 +163,24 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs'
>  	grep refs/tags/magic actual
>  '
>
> +test_expect_success 'ls-remote --symrefs' '
> +	cat >expect <<-EOF &&
> +	symref: refs/heads/master	HEAD
> +	EOF
> +	git ls-remote --symrefs >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'ls-remote with symrefs and refs combined' '
> +	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
> +	EOF
> +	git ls-remote --symrefs --refs >actual &&
> +	test_cmp expect actual
> +'
> +
>  test_done
> --
> 2.7.0.14.g2b6d3d6
>

--
Thomas Gummerer

  reply	other threads:[~2016-01-17 11:15 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 [this message]
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 ` [PATCH v2 0/5] ls-remote: introduce symrefs argument Thomas Gummerer
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=20160117111621.GB7100@hank \
    --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 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.