All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, bturner@atlassian.com, gitster@pobox.com,
	pedrorijo91@gmail.com
Subject: Re: [PATCH v2 5/5] ls-remote: add support for showing symrefs
Date: Mon, 18 Jan 2016 23:09:13 +0100	[thread overview]
Message-ID: <20160118220913.GI7100@hank> (raw)
In-Reply-To: <20160118195159.GD1009@sigill.intra.peff.net>

On 01/18, Jeff King wrote:
> On Mon, Jan 18, 2016 at 05:57:18PM +0100, Thomas Gummerer wrote:
>
> > While there, replace a literal tab in the format string with \t to make
> > it more obvious to the reader.
>
> Heh, I didn't notice in the first review that you actually inherited
> that from the original. Definitely worth doing, IMHO.
>
> > @@ -101,7 +104,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
> >  			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 */
>
> Yeah, this looks like the right logic to me.
>
> > +test_expect_success 'ls-remote --symrefs' '
> > +	cat >expect <<-EOF &&
>
> Please use "<<-\EOF" here (and in the test below) to prevent
> interpolation. It's not wrong in your case, but it's easier for a reader
> (or somebody who later modifies the test) to not have to wonder what you
> were expecting to be expanded. So as a general style, we quote our
> here-doc markers.

Will do, thanks!

> > +	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
> > +'
>
> This test covers "symrefs, along with everything". And this one:
>
> > +test_expect_success 'ls-remote with filtered symrefs' '
> > +	cat >expect <<-EOF &&
> > +	ref: refs/heads/master	HEAD
> > +	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	HEAD
> > +	EOF
> > +	git ls-remote --symrefs . HEAD >actual &&
> > +	test_cmp expect actual
> > +'
>
> covers symrefs plus a refname filter. It would be nice to also test that
> "git ls-remote --symrefs --heads" shows "refs/heads/foo" as a symref.
> But that cannot work with the current code, because upload-pack only
> tells us about the symref HEAD, and not any others.
>
> This may change in the future, though. I'm not sure if it's worth
> squashing in the expect_failure test below. The "negative" one below
> that does tell us something, though it is somewhat redundant (it does
> catch the "always show symrefs" logic from your original version, but
> it seems unlikely that would pop up as a regression).
>
> ---
> diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
> index 3edbc9e..92fc7e9 100755
> --- a/t/t5512-ls-remote.sh
> +++ b/t/t5512-ls-remote.sh
> @@ -176,7 +176,7 @@ test_expect_success 'ls-remote --symrefs' '
>  	test_cmp expect actual
>  '
>
> -test_expect_success 'ls-remote with filtered symrefs' '
> +test_expect_success 'ls-remote with filtered symrefs (refname)' '
>  	cat >expect <<-EOF &&
>  	ref: refs/heads/master	HEAD
>  	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	HEAD
> @@ -185,4 +185,27 @@ test_expect_success 'ls-remote with filtered symrefs' '
>  	test_cmp expect actual
>  '
>
> +test_expect_failure 'ls-remote with filtered symrefs (--heads)' '
> +	git symbolic-ref refs/heads/foo refs/tags/mark &&
> +	cat >expect <<-\EOF &&
> +	ref: refs/heads/bar	refs/tags/mark
> +	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/foo
> +	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/master
> +	EOF
> +	git ls-remote --symrefs --heads . >actual &&
> +	test_cmp expect actual
> +'

I'm a bit confused by this.  Shouldn't the "ref: refs/heads/bar
refs/tags/mark" line only show up when we use --tags, not --heads?
Also should refs/heads/bar be refs/heads/foo?

> +
> +test_expect_success 'ls-remote --symrefs omits filtered-out matches' '
> +	cat >expect <<-\EOF &&
> +	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/foo
> +	1bd44cb9d13204b0fe1958db0082f5028a16eb3a	refs/heads/master
> +	EOF
> +	git ls-remote --symrefs --heads . >actual &&
> +	test_cmp expect actual &&
> +	git ls-remote --symrefs . "refs/heads/*" >actual &&
> +	test_cmp expect actual
> +'
> +
> +
>  test_done
>

--
Thomas

  parent reply	other threads:[~2016-01-18 22:08 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 ` [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 [this message]
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=20160118220913.GI7100@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.