From: Jeff King Date: Mon, 29 Aug 2011 19:36:58 GMT Subject: Re: More formatting with 'git tag -l' Message-ID: <20110829193658.GG756@sigill.intra.peff.net> In-Reply-To: <20110829211018.2ce4ebab@pomiocik.lan> 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