git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] show-ref: make --head always show the HEAD ref

From
Doug Bell <madcityzen@gmail.com>
Date
May 30, 2013, 06:08 UTC
Message-ID
<1369894105-48434-1-git-send-email-madcityzen@gmail.com>
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
Next: Junio C Hamano
Message 1 of 8 in “show-ref: make --head always show the HEAD ref”
  1. show-ref: make --head always show the HEAD refDoug Bell, May 30, 2013
  2. Junio C HamanoJul 11, 2013
  3. Doug BellJul 13, 2013
  4. show-ref: make --head always show the HEAD refDoug Bell, Jul 13, 2013
  5. show-ref: make --head always show the HEAD refDoug Bell, Jul 13, 2013
  6. Junio C HamanoJul 15, 2013
  7. show-ref: make --head always show the HEAD refDoug Bell, Jul 17, 2013
  8. show-ref: make --head always show the HEAD refDoug Bell, Jul 17, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.