From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff King Subject: Re: More formatting with 'git tag -l' Date: Mon, 29 Aug 2011 15:36:58 -0400 Message-ID: <20110829193658.GG756@sigill.intra.peff.net> References: <20110829211018.2ce4ebab@pomiocik.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: git@vger.kernel.org To: =?utf-8?B?TWljaGHFgiBHw7Nybnk=?= X-From: git-owner@vger.kernel.org Mon Aug 29 21:37:16 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qy7dv-0008LY-0L for gcvg-git-2@lo.gmane.org; Mon, 29 Aug 2011 21:37:11 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754924Ab1H2ThF convert rfc822-to-quoted-printable (ORCPT ); Mon, 29 Aug 2011 15:37:05 -0400 Received: from 99-108-226-0.lightspeed.iplsin.sbcglobal.net ([99.108.226.0]:60112 "EHLO peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754895Ab1H2ThC (ORCPT ); Mon, 29 Aug 2011 15:37:02 -0400 Received: (qmail 19602 invoked by uid 107); 29 Aug 2011 19:37:45 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) (smtp-auth username relayok, mechanism cram-md5) by peff.net (qpsmtpd/0.84) with ESMTPA; Mon, 29 Aug 2011 15:37:45 -0400 Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Mon, 29 Aug 2011 15:36:58 -0400 Content-Disposition: inline In-Reply-To: <20110829211018.2ce4ebab@pomiocik.lan> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Mon, Aug 29, 2011 at 09:10:18PM +0200, Micha=C5=82 G=C3=B3rny 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. >=20 > 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=3D'%(refname:short) %(taggerdate) %(subject)' git for-each-ref --format=3D"$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=3D' REF=3D%(refname:short) TDATE=3D%(taggerdate) CDATE=3D%(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=3D"$FORMAT" refs/tags/ | sh See "git help for-each-ref" for more discussion and examples. -Peff