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

[PATCH 2/2] for-each-ref: implement missing tag values

From
Jeff King <peff@peff.net>
Date
Jun 26, 2008, 05:38 UTC
Message-ID
<20080626053804.GB20824@sigill.intra.peff.net>
In-Reply-To
<20080626053551.GA20767@sigill.intra.peff.net>

The "type" and "object" fields for tags were accepted as valid atoms, but never implemented. Consequently, they simply returned the empty string, even for valid tags.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-for-each-ref.c  |    7 +++++++
 t/t6300-for-each-ref.sh |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 07d9c57..fef93d7 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -234,6 +234,13 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
 			name++;
 		if (!strcmp(name, "tag"))
 			v->s = tag->tag;
+		else if (!strcmp(name, "type") && tag->tagged)
+			v->s = typename(tag->tagged->type);
+		else if (!strcmp(name, "object") && tag->tagged) {
+			char *s = xmalloc(41);
+			strcpy(s, sha1_to_hex(tag->tagged->sha1));
+			v->s = s;
+		}
 	}
 }
 
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 415e1d1..a3c8941 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -74,8 +74,8 @@ test_atom tag objectname 98b46b1d36e5b07909de1b3886224e3e81e87322
 test_atom tag tree ''
 test_atom tag parent ''
 test_atom tag numparent ''
-test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581' failure
-test_atom tag type 'commit' failure
+test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581'
+test_atom tag type 'commit'
 test_atom tag author ''
 test_atom tag authorname ''
 test_atom tag authoremail ''
-- 
1.5.6
Previous: Jeff KingNext: Jeff King
Message 9 of 11 in “[Bug] for-each-ref: %(object) and %(type) unimplemented”
  1. Lea WiemannJun 25, 2008
  2. Jeff KingJun 25, 2008
  3. Jeff KingJun 25, 2008
  4. Mikael MagnussonJun 25, 2008
  5. Junio C HamanoJun 25, 2008
  6. Mikael MagnussonJun 25, 2008
  7. Jeff KingJun 26, 2008
  8. 1/2 improve for-each-ref test scriptJeff King, Jun 26, 2008
  9. 2/2 for-each-ref: implement missing tag valuesJeff King, Jun 26, 2008
  10. Jeff KingJun 26, 2008
  11. Junio C HamanoJun 26, 2008

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.