git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Bell <madcityzen@gmail.com>
To: git@vger.kernel.org
Cc: Doug Bell <madcityzen@gmail.com>
Subject: [PATCH] show-ref: make --head always show the HEAD ref
Date: Thu, 30 May 2013 01:08:25 -0500	[thread overview]
Message-ID: <1369894105-48434-1-git-send-email-madcityzen@gmail.com> (raw)

The docs seem to say that doing

	git show-ref --head --tags

would show both the HEAD ref and all the tag refs. However, doing
both --head and either of --tags or --heads would filter out the HEAD
ref.

Signed-off-by: Doug Bell <madcityzen@gmail.com>
---
I think this patch could be done better if I refactor the show_ref() sub
a bit...

This commit passes the current test suite. Where would I put new
tests for this? I can't find an existing show-ref test to append to.
I would be happy to write show-ref tests if there aren't any already.

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

diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 8d9b76a..5954e9b 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -31,6 +31,9 @@ static int show_ref(const char *refname, const unsigned char *sha1, int flag, vo
 	const char *hex;
 	unsigned char peeled[20];
 
+	if (show_head && !strncmp(refname, "HEAD\0", 5))
+		goto match;
+
 	if (tags_only || heads_only) {
 		int match;
 
-- 
1.8.3.101.g727a46b.dirty

             reply	other threads:[~2013-05-30  6:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30  6:08 Doug Bell [this message]
2013-07-11 15:41 ` [PATCH] show-ref: make --head always show the HEAD ref Junio C Hamano
2013-07-13  2:01   ` Doug Bell
2013-07-13  2:03   ` [PATCH v2] " Doug Bell
2013-07-13  2:03     ` [PATCH] " Doug Bell
2013-07-15 16:37       ` Junio C Hamano
2013-07-17  0:05         ` [PATCH v3] " Doug Bell
2013-07-17  0:05           ` [PATCH] " Doug Bell

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=1369894105-48434-1-git-send-email-madcityzen@gmail.com \
    --to=madcityzen@gmail.com \
    --cc=git@vger.kernel.org \
    /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).