git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] show-ref: make --head always show the HEAD ref
@ 2013-05-30  6:08 Doug Bell
  2013-07-11 15:41 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Doug Bell @ 2013-05-30  6:08 UTC (permalink / raw)
  To: git; +Cc: Doug Bell

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-17  0:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30  6:08 [PATCH] show-ref: make --head always show the HEAD ref Doug Bell
2013-07-11 15:41 ` 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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).