Re: More formatting with 'git tag -l'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 29, 2011 at 09:10:18PM +0200, Michał Górny wrote:

> Would it be feasible to add more formatting options to 'git tag -l'.
> Right now, it's just '-n' but if more formatting options were added,
> I think I could use annotated tags as a nice source for autogenerated
> 'NEWS' file.
> 
> What I am most concerned about is the date of last commit contained
> in the tag. Having an option to format each printed tag and use that
> information along with tag details in a format string (like the one
> used by 'git log') would be great.

You can do something similar with 'git for-each-ref', which is probably
what you should be using if you are scripting, anyway (as it is
"plumbing" and guaranteed not to change in future releases). Something
like:

  FORMAT='%(refname:short)
  %(taggerdate)
  %(subject)'
  git for-each-ref --format="$FORMAT" refs/tags/

If you want to do more complex things, try the "--shell" option (or
--perl, --python, etc), which makes it easy to write little scriptlets
in your format, like:

  FORMAT='
    REF=%(refname:short)
    TDATE=%(taggerdate)
    CDATE=%(committerdate)
    if test -z "$TDATE"; then
      echo "$REF: unannotated tag, commit date is $CDATE"
    else
      echo "$REF: annotated tag, tag date is $TDATE"
    fi
  '
  git for-each-ref --shell --format="$FORMAT" refs/tags/ | sh

See "git help for-each-ref" for more discussion and examples.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]