{"thread":{"id":"49840","subject":"approxidate woes","startedAt":"2018-11-15T14:17:12Z","lastAt":"2018-11-15T14:54:11Z","messageCount":3,"participants":["Andreas Krey","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"363434","messageId":"20181115134528.GA21242@inner.h.apk.li","threadId":"49840","inReplyTo":null,"subject":"approxidate woes","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2018-11-15T13:45:28Z","receivedAt":"2018-11-15T14:17:12Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"Hi everybody,\n\nI've now located why our backup repo shrinks every month:\n\n  git gc --prune=2d\n\ndoesn't do what I expected, and differs a lot from --prune=48h.\n\nThe latter actually means 'older than two days', while the\nformer is 'since the second day of this month, same time as now'.\n\nEven '2d ago' does not help - '2 days ago' does.\n\nMildly irritating, and worse, hard to find in the documentation.\nI failed at the latter and fell back to the sources, finding\n'./bin-wrappers/test-date approxidate' for trying.\n\nWhere would I look?\n\n- Andreas\n\n-- \n\"Totally trivial. Famous last words.\"\nFrom: Linus Torvalds <torvalds@*.org>\nDate: Fri, 22 Jan 2010 07:29:21 -0800\n"},{"id":"363436","messageId":"20181115144854.GB16450@sigill.intra.peff.net","threadId":"49840","inReplyTo":"20181115134528.GA21242@inner.h.apk.li","subject":"Re: approxidate woes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-11-15T14:48:54Z","receivedAt":"2018-11-15T14:48:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 15, 2018 at 02:45:28PM +0100, Andreas Krey wrote:\n\n> I've now located why our backup repo shrinks every month:\n> \n>   git gc --prune=2d\n> \n> doesn't do what I expected, and differs a lot from --prune=48h.\n\nYeah, it understands \"2 days\", but not \"d\" as a unit.\n\nI don't think \"48h\" does what you expect either:\n\n  $ t/helper/test-date approxidate now\n  now -> 2018-11-15 14:43:32 +0000\n\n  $ t/helper/test-date approxidate 48h\n  48h -> 2018-11-15 14:43:34 +0000\n\n  $ t/helper/test-date approxidate 48.hours\n  48.hours -> 2018-11-13 14:43:38 +0000\n\nIt might be reasonable to teach approxidate these obvious shorthands\n(one tricky one is \"m\"; normally I'd say \"minute\", but in Git timescales\n\"month\" is more likely).\n\n> Mildly irritating, and worse, hard to find in the documentation.\n> I failed at the latter and fell back to the sources, finding\n> './bin-wrappers/test-date approxidate' for trying.\n> \n> Where would I look?\n\nI don't think approxidate is really documented at all. It started as\nLinus's idea of \"handle what people would probably say\", and the fixes\nover the years have mostly been \"eh, that's crazy, let's do better with\nthis input\".\n\nYou'd have to reverse engineer it a bit from the source, unfortunately.\n\n-Peff\n"},{"id":"363437","messageId":"20181115145407.GC16450@sigill.intra.peff.net","threadId":"49840","inReplyTo":"20181115144854.GB16450@sigill.intra.peff.net","subject":"Re: approxidate woes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-11-15T14:54:07Z","receivedAt":"2018-11-15T14:54:11Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 15, 2018 at 09:48:54AM -0500, Jeff King wrote:\n\n> I don't think \"48h\" does what you expect either:\n> \n>   $ t/helper/test-date approxidate now\n>   now -> 2018-11-15 14:43:32 +0000\n> \n>   $ t/helper/test-date approxidate 48h\n>   48h -> 2018-11-15 14:43:34 +0000\n> \n>   $ t/helper/test-date approxidate 48.hours\n>   48.hours -> 2018-11-13 14:43:38 +0000\n\nWhoops, those should all be:\n\n  t/helper/test-tool date approxidate ...\n\nin recent versions of Git (I was bisecting something earlier, and has a\ncrufty test-date left over from an old version!).\n\nAdding new unit aliases would be something like:\n\ndiff --git a/date.c b/date.c\nindex 9bc15df6f9..eb477d1601 100644\n--- a/date.c\n+++ b/date.c\n@@ -1016,6 +1016,7 @@ static const struct typelen {\n \t{ \"minutes\", 60 },\n \t{ \"hours\", 60*60 },\n \t{ \"days\", 24*60*60 },\n+\t{ \"d\", 24*60*60 },\n \t{ \"weeks\", 7*24*60*60 },\n \t{ NULL }\n };\n\nbut I suspect we need to tighten up the string matching a bit. I think\nthat would allow \"2 dogs\" to be parsed as \"days\".\n\n-Peff\n"}]}