public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Vladimir Panteleev <thecybershadow@gmail•com>
Cc: Vladimir Panteleev <git@thecybershadow•net>, git@vger•kernel.org
Subject: Re: [PATCH] show-ref: Allow --head to work with --verify
Date: Fri, 20 Jan 2017 15:20:00 -0800	[thread overview]
Message-ID: <xmqqshoduxnj.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <3b1d2717-dd7f-2add-b935-3ace6063b258@gmail.com> (Vladimir Panteleev's message of "Fri, 20 Jan 2017 22:55:12 +0000")

Vladimir Panteleev <thecybershadow@gmail•com> writes:

> --quiet will still work correctly with the current patch, because
> show_ref already checks quiet. Granted, the original --verify code
> used show_one and not show_ref; however, I don't see a meaningful
> difference between calling show_ref and show_one for HEAD, other than
> a bit of overhead, so adding a new function may not be worthwhile. I
> will still add tests for this; however, in light of this, would you
> still like me to perform the change you requested?

If two codepaths are called "I don't see a meaningful difference",
then it is really better to share the same code.  Today, they may
happen to behave identically.  When we need to update the behaviour
of one, we'd be forced to update the other one to match.

IOW, something along this line, perhaps (not even compile tested so
take it with grain of salt).

Thanks.

 builtin/show-ref.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 6d4e669002..57491152b7 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -202,7 +202,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
 		while (*pattern) {
 			struct object_id oid;
 
-			if (starts_with(*pattern, "refs/") &&
+			if (((show_head && !strcmp(*pattern, "HEAD")) ||
+			     starts_with(*pattern, "refs/")) &&
 			    !read_ref(*pattern, oid.hash)) {
 				if (!quiet)
 					show_one(*pattern, &oid);




  reply	other threads:[~2017-01-20 23:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 15:50 [PATCH] show-ref: Allow --head to work with --verify Vladimir Panteleev
2017-01-20 19:03 ` Junio C Hamano
2017-01-20 20:26   ` Vladimir Panteleev
2017-01-20 20:51     ` Vladimir Panteleev
2017-01-20 22:22     ` Junio C Hamano
2017-01-20 22:31       ` Junio C Hamano
2017-01-20 23:15       ` Junio C Hamano
2017-01-20 22:55   ` Vladimir Panteleev
2017-01-20 23:20     ` Junio C Hamano [this message]
2017-01-20 23:29       ` Junio C Hamano
2017-01-21  0:25         ` Vladimir Panteleev

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=xmqqshoduxnj.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@thecybershadow$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=thecybershadow@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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