{"thread":{"id":"39408","subject":"[BUG] \"git commit --date\" format parsing","startedAt":"2015-05-22T13:18:53Z","lastAt":"2015-05-23T23:24:03Z","messageCount":3,"participants":["Bastien Traverse","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"261900","messageId":"555F2CBD.8050501@esrevart.net","threadId":"39408","inReplyTo":null,"subject":"[BUG] \"git commit --date\" format parsing","fromName":"Bastien Traverse","fromEmail":"bt@esrevart.net","sentAt":"2015-05-22T13:18:53Z","receivedAt":"2015-05-22T13:18:53Z","isPatch":false,"sender":{"key":"bt@esrevart.net","avatar":null},"body":"Hi *\n\nTrying to specify a commit (author) date using `--date` option yields\nunpredictable results that are incoherent with man git-commit:\n\n$ git --version\ngit version 2.4.1\n\n$ uname -a\nLinux arch-clevo 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST\n2015 x86_64 GNU/Linux\n\n$ mkdir test && cd test/\n$ git init\n$ touch test\n$ git add test\n\n1. ISO 8601 (strict)\n\n$ git commit --date=\"2015-05-21T16∶31+02:00\" -m \"Test commit to check\ndate format parsing\"\n[master (root commit) fed9ae6] Test commit to check date format parsing\n Date: Thu May 21 02:00:00 2015 +0200\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test\n\n  --> gets the date right but confuses the timezone for the time\n\n2. git-log --date=iso8601 format:\n\n$ git commit --amend --date=\"2015-05-21 16∶31 +0200\" -m \"Test commit to\ncheck date format parsing\"\n[master d2cdbf2] Test commit to check date format parsing\n Date: Thu May 21 14:37:37 2015 +0200\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 test\n\n  --> gets the date right but uses current time, not specified one\n\n3. date format git uses in output of commit command:\n\n$ git commit --amend --date=\"Thu May 21 16∶31 2015 +0200\"\n...\nDate: Sat May 21 14:40:08 2016 +0200\n\n  --> get the day and month right but not the year, uses current time\n\n4. RFC 2822\n\n$ git commit --amend --date=\"Thu, 21 May 2015 16∶31 +0200\"\n...\nDate: Thu May 21 15:01:03 2015 +0200\n\n  --> gets the date right but uses current time\n\n5. Environment variable with ISO 8601 (strict)\n\n$ GIT_AUTHOR_DATE=\"2015-05-21T16∶31+02:00\" git commit --amend\n...\nDate: Thu May 21 15:04:30 2015 +0200\n\n  --> using the env var we get something better than 1. (not confusing\ntimezone for time) but still not the specified date.\n\n\nSeeing the discussions there have been here around date parsing and ISO\n8601 [1][2], I suggest only supporting the W3C’s suggested profile of\nISO 8601 [3] to cut in the complexity.\n\nMy use case for using the --date option to git-commit is to reconstruct\nthe revision history of a set of files that were timestamped with YAML\n`date:` metadata, so as to see which files were added after which others\netc.\n\nI was hoping to use a script to parse the YAML datetime metadata in git\ncommit, but right now the time information would be lost, which is\nproblematic.\n\nBesides this, documentation for git-commit is currently uncorrect since\nit suggests we can use RFC 2822 and ISO 8601 while this seems not to be\nthe case.\n\nThanks for your feedback,\nBastien\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/256109\n[2] http://thread.gmane.org/gmane.comp.version-control.git/52414/focus=52597\n[3] http://www.w3.org/TR/NOTE-datetime\n"},{"id":"261955","messageId":"20150522220610.GA21848@peff.net","threadId":"39408","inReplyTo":"555F2CBD.8050501@esrevart.net","subject":"Re: [BUG] \"git commit --date\" format parsing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-22T22:06:10Z","receivedAt":"2015-05-22T22:06:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 22, 2015 at 03:18:53PM +0200, Bastien Traverse wrote:\n\n> $ git --version\n> git version 2.4.1\n> \n> $ uname -a\n> Linux arch-clevo 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST\n> 2015 x86_64 GNU/Linux\n> \n> $ mkdir test && cd test/\n> $ git init\n> $ touch test\n> $ git add test\n> \n> 1. ISO 8601 (strict)\n> \n> $ git commit --date=\"2015-05-21T16∶31+02:00\" -m \"Test commit to check\n> date format parsing\"\n> [master (root commit) fed9ae6] Test commit to check date format parsing\n>  Date: Thu May 21 02:00:00 2015 +0200\n>  1 file changed, 0 insertions(+), 0 deletions(-)\n>  create mode 100644 test\n> \n>   --> gets the date right but confuses the timezone for the time\n\nOK, this is weird. When I tried to reproduce, I couldn't. But I had\ntyped in the date string myself while reading your email in another\nwindow.  And though I was sure that I had typed it correctly, just to be\ndouble-plus-sure I copied and pasted your string. And it failed!\n\nThe date string in your email looks like this (using cut and paste):\n\n  $ echo 2015-05-21T16∶31+02:00 | xxd\n  00000000: 3230 3135 2d30 352d 3231 5431 36e2 88b6  2015-05-21T16...\n  00000010: 3331 2b30 323a 3030 0a                   31+02:00.\n\nYour \"colon\" is actually UTF-8 for code point U+2236 (\"RATIO\"). So git's\ndate parser does not recognize it, and punts to approxidate(), which\ndoes all manner of crazy guessing trying to figure out what you meant.\n\n-Peff\n"},{"id":"262009","messageId":"55610C13.4090802@esrevart.net","threadId":"39408","inReplyTo":"20150522220610.GA21848@peff.net","subject":"Re: [RESOLVED NOTABUG] \"git commit --date\" format parsing","fromName":"Bastien Traverse","fromEmail":"bt@esrevart.net","sentAt":"2015-05-23T23:24:03Z","receivedAt":"2015-05-23T23:24:03Z","isPatch":false,"sender":{"key":"bt@esrevart.net","avatar":null},"body":"Le 23/05/2015 00:06, Jeff King a écrit :\n> OK, this is weird. When I tried to reproduce, I couldn't. But I had\n> typed in the date string myself while reading your email in another\n> window.  And though I was sure that I had typed it correctly, just to be\n> double-plus-sure I copied and pasted your string. And it failed!\n> \n> The date string in your email looks like this (using cut and paste):\n> \n>   $ echo 2015-05-21T16∶31+02:00 | xxd\n>   00000000: 3230 3135 2d30 352d 3231 5431 36e2 88b6  2015-05-21T16...\n>   00000010: 3331 2b30 323a 3030 0a                   31+02:00.\n> \n> Your \"colon\" is actually UTF-8 for code point \t. So git's\n> date parser does not recognize it, and punts to approxidate(), which\n> does all manner of crazy guessing trying to figure out what you meant.\n\nOkay, this is crazy. Now I can't reproduce it myself either: I just\nrepeated the procedure and date parsing works as expected. The only\ndifference with my last email is that I upgraded and rebooted my system\n(there was a kernel update for 4.0.4 on Arch... Among other things). I\nguess that would have reset my keyboard layout, but I swear I tested it\nmultiple times over a few days before posting here.\n\nAnyway, thanks for your insight I would have never figured this myself.\nI'll be wary of silent unicode character substitution :)\n\nJust for the record:\n$ localectl\n   System Locale: LANG=fr_FR.UTF8\n       VC Keymap: fr\n      X11 Layout: fr\n     X11 Variant: oss\n\nAnd I am using the default monospace font in gnome-terminal and gedit.\nPretty basic stuff, really.\n\nThanks again,\nBastien\n"}]}