Subject: Re: Feature Request: Passing a number as an option to git tags for displaying latest tags

From: Junio C Hamano <[email-masked]>
Date: Thu, 23 Jul 2015 11:01:32 -0700

Jacob Keller <[email-masked]> writes:

> Yep, that's pretty much how a build system I've had to use does it.
> Sadly, this is quite slow, and I'm not sure if doing it built into the
> tag via for-each-ref would be faster?

Is the description in "git for-each-ref --help" somehow unreadable?

       An example directly producing formatted text. Show the most
       recent 3 tagged commits:

           #!/bin/sh

           git for-each-ref --count=3 --sort='-*authordate' \
           --format='From: %(*authorname) %(*authoremail)
           Subject: %(*subject)
           Date: %(*authordate)
           Ref: %(*refname)

           %(*body)
           ' 'refs/tags'

If you only need the name of the ref, you can use a lot simpler
format string, e.g.

    git for-each-ref --count=3 --sort='-*authordate' \
      --format='%(refname:short)' refs/tags

    git for-each-ref --count=3 --sort='-taggerdate' \
      --format='%(refname:short)' refs/tags