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

Re: Pretty date option for git tag?

From
Jeff King <peff@peff.net>
Date
May 18, 2009, 21:27 UTC
Message-ID
<20090518212731.GA14050@coredump.intra.peff.net>
In-Reply-To
<200905182311.41876.trast@student.ethz.ch>
On Mon, May 18, 2009 at 11:11:37PM +0200, Thomas Rast wrote:
Show 11 quoted lines
> Jeff King wrote:
> > It seems like you should be able to script around for-each-ref and
> > remain efficient, but I don't think there is a way to convince it to
> > dereference tags.
> 
> Actually there's the * operator.  For example
> 
>   git$ git for-each-ref --format="%(objecttype) %(*objecttype)" refs/tags/v1.6.0
>   tag commit
> 
> Does that solve the problem at hand?

Oh, right, thanks. I missed that when reading the manual (I was looking for "dereference" or "peel", but those words are never used). So you can do:

  git for-each-ref --format='%(refname)
  Tag: %(taggername) %(taggeremail) %(taggerdate)
  Commit: %(*authorname) %(*authoremail) %(*authordate)
  ' refs/tags
to show both.

That could go in an alias, though it isn't exactly what the original poster asked for. Besides not being a one-line format, it has refs/tags/ cruft at the beginning of each ref. I think what the OP asked for exactly is:

  eval "`git for-each-ref --shell --format='
    r=%(refname)
    d=%(taggerdate)
    T=${r#refs/tags/}
    echo "$T $d"
    ' refs/tags`"

Though as Linus said, I think the actual commit date is also interesting (and you could expand that shell snippet to show it instead, in addition to, or whatever).

And before anyone says anything, yes, I think building a shell script and eval'ing it is a little ugly compared to a "--show-date" option to "git tag". If this is something a lot of people want to do, it wouldn't be that hard an option to add (in fact, it would be really nice to unify the show-ref and pretty=format substitutions, and extend them into "git tag --format='%r %td'" or whatever).

-Peff
Previous: Thomas Rast
Message 7 of 7 in “Pretty date option for git tag?”
  1. dloewenherz@gmail.comMay 18, 2009
  2. Michael J GruberMay 18, 2009
  3. Linus TorvaldsMay 18, 2009
  4. Jeff KingMay 18, 2009
  5. for-each-ref: fix segfault in copy_emailJeff King, May 18, 2009
  6. Thomas RastMay 18, 2009
  7. Jeff KingMay 18, 2009

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.