git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Lea Wiemann <lewiemann@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [Bug] for-each-ref: %(object) and %(type) unimplemented
Date: Wed, 25 Jun 2008 12:08:15 -0400	[thread overview]
Message-ID: <20080625160814.GA3321@sigill.intra.peff.net> (raw)
In-Reply-To: <48625DAD.5040404@gmail.com>

On Wed, Jun 25, 2008 at 05:01:01PM +0200, Lea Wiemann wrote:

> Try the following on a repository with tag objects in it:
>
> git for-each-ref --format='%(object)'
> git for-each-ref --format='%(type)'
>
> Each command prints only newlines.  The %(type) and %(object) options are 
> not rejected with an error message (like "%(doesnotexist)"), but they 
> don't seem to be implemented.  "%(tag)" works though.
>
> Anyone care to implement the missing options?  Or should they rather be  
> removed from the documentation?

Looks like they were part of the original set of atoms, but they just
never ended up implemented. Clearly nobody has actually cared in the
intervening time, but it is easy enough to add them. See below.

Since you seem to be testing for-each-ref, maybe it would make sense to
put together a test script that exercises each of the atoms?

-- >8 --
for-each-ref: implement missing tag values

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.

Noticed by Lea Wiemann.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-for-each-ref.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 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;
+		}
 	}
 }
 
-- 
1.5.6.129.g8dea5.dirty

  reply	other threads:[~2008-06-25 16:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 15:01 [Bug] for-each-ref: %(object) and %(type) unimplemented Lea Wiemann
2008-06-25 16:08 ` Jeff King [this message]
2008-06-25 16:14   ` Jeff King
2008-06-25 19:08     ` Mikael Magnusson
2008-06-25 19:38       ` Junio C Hamano
2008-06-25 20:36         ` Mikael Magnusson
2008-06-26  5:35     ` Jeff King
2008-06-26  5:37       ` [PATCH 1/2] improve for-each-ref test script Jeff King
2008-06-26  5:38       ` [PATCH 2/2] for-each-ref: implement missing tag values Jeff King
2008-06-26  8:08       ` [Bug] for-each-ref: %(object) and %(type) unimplemented Jeff King
2008-06-26  8:21         ` Junio C Hamano

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=20080625160814.GA3321@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lewiemann@gmail.com \
    /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).