{"thread":{"id":"19405","subject":"Pretty date option for git tag?","startedAt":"2009-05-18T15:14:40Z","lastAt":"2009-05-18T21:27:31Z","messageCount":7,"participants":["dloewenherz@gmail.com","Michael J Gruber","Linus Torvalds","Jeff King","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114185","messageId":"20090518151440.GA10536@andros.its.yale.edu","threadId":"19405","inReplyTo":null,"subject":"Pretty date option for git tag?","fromName":"","fromEmail":"dloewenherz@gmail.com","sentAt":"2009-05-18T15:14:40Z","receivedAt":"2009-05-18T15:14:40Z","isPatch":false,"sender":{"key":"dloewenherz@gmail.com","avatar":"https://gravatar.com/avatar/69134b10dc6663fd8a4ac95edc0e556662c43c3acb226cec9f697cb8848198b2?d=mp&s=160"},"body":"It is relatively hard to verify the date a tag was created unless it was been\ngpg/pgp-signed at the time of creation, no? I suppose that the Unix timestamp\nincluded in each tag file is useful for sorting, but it's not very easy for\npeople to digest.  Additionally, we have our `log.date` config, why not use it\nhere for some sort of option, like `--pretty=date` to make it easy to see when\na tag was created?\n\nI.e.\n\n$ git tag -l --pretty=date\n...\nMon, 13 Apr 2009 00:06:25: v1.6.3-rc0\nSat, 18 Apr 2009 22:11:00: v1.6.3-rc1 \nSat, 25 Apr 2009 06:01:13: v1.6.3-rc2 \nSun, 26 Apr 2009 23:43:48: v1.6.3-rc3 \nSat, 02 May 2009 06:32:21: v1.6.3-rc4 \nWed, 13 May 2009 05:30:37: v1.6.3.1\n\nI don't know if this is feasible. Perhaps there already exists a feature for\nthis that I'm unaware of. Or maybe this would be a waste of time.\n\nDan\n"},{"id":"114190","messageId":"4A118696.80902@drmicha.warpmail.net","threadId":"19405","inReplyTo":"20090518151440.GA10536@andros.its.yale.edu","subject":"Re: Pretty date option for git tag?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-18T16:02:30Z","receivedAt":"2009-05-18T16:02:30Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"dloewenherz@gmail.com venit, vidit, dixit 18.05.2009 17:14:\n> It is relatively hard to verify the date a tag was created unless it was been\n> gpg/pgp-signed at the time of creation, no? I suppose that the Unix timestamp\n> included in each tag file is useful for sorting, but it's not very easy for\n> people to digest.  Additionally, we have our `log.date` config, why not use it\n> here for some sort of option, like `--pretty=date` to make it easy to see when\n> a tag was created?\n> \n> I.e.\n> \n> $ git tag -l --pretty=date\n> ...\n> Mon, 13 Apr 2009 00:06:25: v1.6.3-rc0\n> Sat, 18 Apr 2009 22:11:00: v1.6.3-rc1 \n> Sat, 25 Apr 2009 06:01:13: v1.6.3-rc2 \n> Sun, 26 Apr 2009 23:43:48: v1.6.3-rc3 \n> Sat, 02 May 2009 06:32:21: v1.6.3-rc4 \n> Wed, 13 May 2009 05:30:37: v1.6.3.1\n> \n> I don't know if this is feasible. Perhaps there already exists a feature for\n> this that I'm unaware of. Or maybe this would be a waste of time.\n\nYou might want to experiment with\n\ngit log --tags --simplify-by-decoration --pretty=\"format:%ai %s\"\n\nwhich may show a few more commits than just the tags but comes close to\nthe output you envisage.\n\nMichael\n"},{"id":"114195","messageId":"alpine.LFD.2.01.0905181015080.3301@localhost.localdomain","threadId":"19405","inReplyTo":"4A118696.80902@drmicha.warpmail.net","subject":"Re: Pretty date option for git tag?","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-05-18T17:20:49Z","receivedAt":"2009-05-18T17:20:49Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 18 May 2009, Michael J Gruber wrote:\n> \n> You might want to experiment with\n> \n> git log --tags --simplify-by-decoration --pretty=\"format:%ai %s\"\n> \n> which may show a few more commits than just the tags but comes close to\n> the output you envisage.\n\nOoh, evil. I like it.\n\nIt's a rather expensive operation, but it does have the really nice \nproperty that it will show the date of the commit the tag is pointing to, \nrather than necessarily the date of the tag itself (which is not \nwell-defined unless the tag is signed).\n\nAs you mention, \"--simplify-by-decoration\" will show merges too (unless it \ncan linearize the tag history), but you can work around that by making the \nformat be \"format:%ai %d\" where that '%d' shows the decoration of the \ncommit, rather than the commit summary. Now the merges that aren't tagged \nstand out very clearly.\n\nOf course, the above will just work for commit tags. If you've tagged a \ntree or a blob, the above gives you bubkis.\n\n\t\t\tLinus\n"},{"id":"114196","messageId":"20090518174547.GA14509@sigill.intra.peff.net","threadId":"19405","inReplyTo":"alpine.LFD.2.01.0905181015080.3301@localhost.localdomain","subject":"Re: Pretty date option for git tag?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-18T17:45:47Z","receivedAt":"2009-05-18T17:45:47Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 18, 2009 at 10:20:49AM -0700, Linus Torvalds wrote:\n\n> It's a rather expensive operation, but it does have the really nice \n> property that it will show the date of the commit the tag is pointing to, \n> rather than necessarily the date of the tag itself (which is not \n> well-defined unless the tag is signed).\n\nIt seems like you should be able to script around for-each-ref and\nremain efficient, but I don't think there is a way to convince it to\ndereference tags. Something like:\n\n  git for-each-ref --format='%(refname)\n  Tag: %(taggername) %(taggeremail) %(taggerdate)\n  Commit: %(authorname) %(authoremail) %(authordate)\n  ' refs/tags\n\nalmost works, but the commit fields are always empty. So I think you\nwould have to parse and manually rev-parse each one.\n\n-Peff\n\nPS The for-each-ref command above caused a segfault when run in git.git.\n   Patch to follow.\n"},{"id":"114197","messageId":"20090518175811.GB14509@sigill.intra.peff.net","threadId":"19405","inReplyTo":"20090518174547.GA14509@sigill.intra.peff.net","subject":"[PATCH] for-each-ref: fix segfault in copy_email","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-18T17:58:11Z","receivedAt":"2009-05-18T17:58:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"You can trigger a segfault in git.git by doing:\n\n  git for-each-ref --format='%(taggeremail)' refs/tags/v0.99\n\nThe v0.99 tag is special in that it contains no \"tagger\"\nheader.\n\nThe bug is obvious in copy_email, which carefully checks to\nmake sure the result of a strchr is non-NULL, but only after\nalready having used it to perform other work. The fix is to\nmove the check up.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-for-each-ref.c |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex 91e8f95..d091e04 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -339,8 +339,11 @@ static const char *copy_name(const char *buf)\n static const char *copy_email(const char *buf)\n {\n \tconst char *email = strchr(buf, '<');\n-\tconst char *eoemail = strchr(email, '>');\n-\tif (!email || !eoemail)\n+\tconst char *eoemail;\n+\tif (!email)\n+\t\treturn \"\";\n+\teoemail = strchr(email, '>');\n+\tif (!eoemail)\n \t\treturn \"\";\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n-- \n1.6.3.1.137.g9019.dirty\n"},{"id":"114200","messageId":"200905182311.41876.trast@student.ethz.ch","threadId":"19405","inReplyTo":"20090518174547.GA14509@sigill.intra.peff.net","subject":"Re: Pretty date option for git tag?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-05-18T21:11:37Z","receivedAt":"2009-05-18T21:11:37Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jeff King wrote:\n> It seems like you should be able to script around for-each-ref and\n> remain efficient, but I don't think there is a way to convince it to\n> dereference tags.\n\nActually there's the * operator.  For example\n\n  git$ git for-each-ref --format=\"%(objecttype) %(*objecttype)\" refs/tags/v1.6.0\n  tag commit\n\nDoes that solve the problem at hand?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"114201","messageId":"20090518212731.GA14050@coredump.intra.peff.net","threadId":"19405","inReplyTo":"200905182311.41876.trast@student.ethz.ch","subject":"Re: Pretty date option for git tag?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-18T21:27:31Z","receivedAt":"2009-05-18T21:27:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 18, 2009 at 11:11:37PM +0200, Thomas Rast wrote:\n\n> Jeff King wrote:\n> > It seems like you should be able to script around for-each-ref and\n> > remain efficient, but I don't think there is a way to convince it to\n> > dereference tags.\n> \n> Actually there's the * operator.  For example\n> \n>   git$ git for-each-ref --format=\"%(objecttype) %(*objecttype)\" refs/tags/v1.6.0\n>   tag commit\n> \n> Does that solve the problem at hand?\n\nOh, right, thanks. I missed that when reading the manual (I was looking\nfor \"dereference\" or \"peel\", but those words are never used). So you can\ndo:\n\n  git for-each-ref --format='%(refname)\n  Tag: %(taggername) %(taggeremail) %(taggerdate)\n  Commit: %(*authorname) %(*authoremail) %(*authordate)\n  ' refs/tags\n\nto show both.\n\nThat could go in an alias, though it isn't exactly what the original\nposter asked for. Besides not being a one-line format, it has refs/tags/\ncruft at the beginning of each ref. I think what the OP asked for\nexactly is:\n\n  eval \"`git for-each-ref --shell --format='\n    r=%(refname)\n    d=%(taggerdate)\n    T=${r#refs/tags/}\n    echo \"$T $d\"\n    ' refs/tags`\"\n\nThough as Linus said, I think the actual commit date is also interesting\n(and you could expand that shell snippet to show it instead, in addition\nto, or whatever).\n\nAnd before anyone says anything, yes, I think building a shell script\nand eval'ing it is a little ugly compared to a \"--show-date\" option to\n\"git tag\". If this is something a lot of people want to do, it wouldn't\nbe that hard an option to add (in fact, it would be really nice to unify\nthe show-ref and pretty=format substitutions, and extend them into \"git\ntag --format='%r %td'\" or whatever).\n\n-Peff\n"}]}