{"thread":{"id":"26671","subject":"Q about the date format in \"git commit --date=...\" and such","startedAt":"2011-03-06T16:07:52Z","lastAt":"2011-03-08T19:20:57Z","messageCount":6,"participants":["Dirk Süsserott","Jeff King","Junio C Hamano","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162848","messageId":"4D73B158.5040409@dirk.my1.cc","threadId":"26671","inReplyTo":null,"subject":"Q about the date format in \"git commit --date=...\" and such","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2011-03-06T16:07:52Z","receivedAt":"2011-03-06T16:07:52Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Hello,\n\nI frequently change a file in my repo and commit it with\n\"git commit -a -C deadbeef\", i.e. using an older commit message. The\n\"-C\" switch also re-uses the author timestamp of the given SHA1, which\nis not what I want. So I tried the \"--date=...\" switch in addition,\nwhich works fine.\n\nInstead of giving an exact timestamp (like \"--date='06.03.2011 16:50'\")\nI'd prefer to just say \"--date=now\". Is that somehow possible? If not:\nwould the community appreciate it, if I would try to implement this?\n\nI imagine to translate \"now\" to \"localtime(time(0))\". Would that be good?\n\nDirk\n"},{"id":"162923","messageId":"20110307165448.GD11934@sigill.intra.peff.net","threadId":"26671","inReplyTo":"4D73B158.5040409@dirk.my1.cc","subject":"Re: Q about the date format in \"git commit --date=...\" and such","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-07T16:54:48Z","receivedAt":"2011-03-07T16:54:48Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Mar 06, 2011 at 05:07:52PM +0100, Dirk Süsserott wrote:\n\n> I frequently change a file in my repo and commit it with\n> \"git commit -a -C deadbeef\", i.e. using an older commit message. The\n> \"-C\" switch also re-uses the author timestamp of the given SHA1, which\n> is not what I want. So I tried the \"--date=...\" switch in addition,\n> which works fine.\n\nI also do something like this; I have a repository which gets a weekly\nupdate, and I tend to reuse last week's commit message as a template\nwith \"git commit -c HEAD --reset-author\".\n\nNote that it will _also_ reset the author to you if you were not the\noriginal author. But that is probably what you want if you are resetting\nthe timestamp; it is semantically \"take ownership of this commit\".\n\n> Instead of giving an exact timestamp (like \"--date='06.03.2011 16:50'\")\n> I'd prefer to just say \"--date=now\". Is that somehow possible? If not:\n> would the community appreciate it, if I would try to implement this?\n\nI mentioned --reset-author above, which I think solves your problem. As\nfar as --date=now goes, it doesn't sound like a terrible idea. But there\nis some question of how far we should take it. We basically have two\ndate-parsing interfaces: parse_date and approxidate.\n\nThe former is reasonably strict and accepts what you showed above. We\nuse it for \"commit --date=\" as well as parsing $GIT_AUTHOR_DATE.\n\nApproxidate, on the other hand, will try to turn any nonsense into a\ndate. So you can say \"3 weeks ago\" or \"tea.time.on.january.1.2011\", or\neven \"bogus\" (the last of which turns into \"now\"). So it's flexible, but\nit may not do what you want. We use this for \"log --since\",\n\"branch@{date}\", and other places.\n\nI think the original rationale was that it's OK for us to allow some\nsloppiness when _viewing_ commits, since you will generally notice the\nproblem. But when making commits, it's better to be careful, since you\nmay be setting the sha1 in stone.\n\nThese days we have two tools that could help:\n\n  1. approxidate_careful will do a regular approxidate, but keep track\n     of whether we found anything even remotely useful. That doesn't\n     mean you can't still get unexpected results, but at least some\n     truly useless cases return errors.\n\n  2. For commits with a different author and committer, we mention the\n     author name in the post-commit summary. We could do the same with a\n     timestamp that was given (i.e., mentioning it in a standard format)\n     to give the user another opportunity to double-check what we\n     parsed.\n\nThat being said, with --reset-author I have never needed --date, so I\ndon't personally care if it gets done or not.\n\n-Peff\n"},{"id":"162950","messageId":"7vzkp6zclw.fsf@alter.siamese.dyndns.org","threadId":"26671","inReplyTo":"20110307165448.GD11934@sigill.intra.peff.net","subject":"Re: Q about the date format in \"git commit --date=...\" and such","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-08T00:20:59Z","receivedAt":"2011-03-08T00:20:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> That being said, with --reset-author I have never needed --date, so I\n> don't personally care if it gets done or not.\n\nIn short, should I take that the resolution of this issue is \"I didn't\nknow about --reset-author and asking for --date=loose was an X-Y problem\"?\n\nI agree with you that we would not want to loosen the specification side\n(i.e. \"commit --date=\" as opposed to the selector side \"log --since=\")\nunless we absolutely have to.\n"},{"id":"162954","messageId":"20110308011646.GA21278@sigill.intra.peff.net","threadId":"26671","inReplyTo":"7vzkp6zclw.fsf@alter.siamese.dyndns.org","subject":"Re: Q about the date format in \"git commit --date=...\" and such","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-08T01:16:46Z","receivedAt":"2011-03-08T01:16:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 07, 2011 at 04:20:59PM -0800, Junio C Hamano wrote:\n\n> > That being said, with --reset-author I have never needed --date, so I\n> > don't personally care if it gets done or not.\n> \n> In short, should I take that the resolution of this issue is \"I didn't\n> know about --reset-author and asking for --date=loose was an X-Y problem\"?\n> \n> I agree with you that we would not want to loosen the specification side\n> (i.e. \"commit --date=\" as opposed to the selector side \"log --since=\")\n> unless we absolutely have to.\n\nIt is up to Dirk to say whether it solves his particular problem or not.\nBut thinking on it more, --date=now does encourage a bit of a wrong\nworkflow. Why would you be resetting the date but _not_ taking\nownership? Maybe a reasonable situation for that exists, but I couldn't\nthink of one.\n\n-Peff\n"},{"id":"162999","messageId":"m2vcztqwcr.fsf@igel.home","threadId":"26671","inReplyTo":"20110308011646.GA21278@sigill.intra.peff.net","subject":"Re: Q about the date format in \"git commit --date=...\" and such","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-03-08T18:51:32Z","receivedAt":"2011-03-08T18:51:32Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Why would you be resetting the date but _not_ taking ownership? Maybe\n> a reasonable situation for that exists, but I couldn't think of one.\n\nIf you are already the author it's not so obvious that you have to reset\nauthorship in order to reset the date.  Also, if you are the author, but\nunder a different email you may not want to change that.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"163005","messageId":"4D768199.80204@dirk.my1.cc","threadId":"26671","inReplyTo":"m2vcztqwcr.fsf@igel.home","subject":"Re: Q about the date format in \"git commit --date=...\" and such","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2011-03-08T19:20:57Z","receivedAt":"2011-03-08T19:20:57Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 08.03.2011 19:51 schrieb Andreas Schwab:\n> Jeff King<peff@peff.net>  writes:\n>\n>> Why would you be resetting the date but _not_ taking ownership? Maybe\n>> a reasonable situation for that exists, but I couldn't think of one.\n>\n> If you are already the author it's not so obvious that you have to reset\n> authorship in order to reset the date.  Also, if you are the author, but\n> under a different email you may not want to change that.\n>\n> Andreas.\n>\n\nThank you, Peff and Andreas. Indeed I never tried --reset-author before \nbut it works fine for my problem, as the authorship/email didn't change \nbetween the commits. However, I personally think --date=now should work \neverywhere but if you don't like it I will definitely not insist on it. :-)\n\nIn case I _really_ need it, I could use sth. like\n--date=$(perl -e 'print localtime').\n\nDirk\n"}]}