git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] "git commit --date" format parsing
@ 2015-05-22 13:18 Bastien Traverse
  2015-05-22 22:06 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Bastien Traverse @ 2015-05-22 13:18 UTC (permalink / raw)
  To: git

Hi *

Trying to specify a commit (author) date using `--date` option yields
unpredictable results that are incoherent with man git-commit:

$ git --version
git version 2.4.1

$ uname -a
Linux arch-clevo 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST
2015 x86_64 GNU/Linux

$ mkdir test && cd test/
$ git init
$ touch test
$ git add test

1. ISO 8601 (strict)

$ git commit --date="2015-05-21T16∶31+02:00" -m "Test commit to check
date format parsing"
[master (root commit) fed9ae6] Test commit to check date format parsing
 Date: Thu May 21 02:00:00 2015 +0200
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test

  --> gets the date right but confuses the timezone for the time

2. git-log --date=iso8601 format:

$ git commit --amend --date="2015-05-21 16∶31 +0200" -m "Test commit to
check date format parsing"
[master d2cdbf2] Test commit to check date format parsing
 Date: Thu May 21 14:37:37 2015 +0200
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test

  --> gets the date right but uses current time, not specified one

3. date format git uses in output of commit command:

$ git commit --amend --date="Thu May 21 16∶31 2015 +0200"
...
Date: Sat May 21 14:40:08 2016 +0200

  --> get the day and month right but not the year, uses current time

4. RFC 2822

$ git commit --amend --date="Thu, 21 May 2015 16∶31 +0200"
...
Date: Thu May 21 15:01:03 2015 +0200

  --> gets the date right but uses current time

5. Environment variable with ISO 8601 (strict)

$ GIT_AUTHOR_DATE="2015-05-21T16∶31+02:00" git commit --amend
...
Date: Thu May 21 15:04:30 2015 +0200

  --> using the env var we get something better than 1. (not confusing
timezone for time) but still not the specified date.


Seeing the discussions there have been here around date parsing and ISO
8601 [1][2], I suggest only supporting the W3C’s suggested profile of
ISO 8601 [3] to cut in the complexity.

My use case for using the --date option to git-commit is to reconstruct
the revision history of a set of files that were timestamped with YAML
`date:` metadata, so as to see which files were added after which others
etc.

I was hoping to use a script to parse the YAML datetime metadata in git
commit, but right now the time information would be lost, which is
problematic.

Besides this, documentation for git-commit is currently uncorrect since
it suggests we can use RFC 2822 and ISO 8601 while this seems not to be
the case.

Thanks for your feedback,
Bastien

[1] http://thread.gmane.org/gmane.comp.version-control.git/256109
[2] http://thread.gmane.org/gmane.comp.version-control.git/52414/focus=52597
[3] http://www.w3.org/TR/NOTE-datetime

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] "git commit --date" format parsing
  2015-05-22 13:18 [BUG] "git commit --date" format parsing Bastien Traverse
@ 2015-05-22 22:06 ` Jeff King
  2015-05-23 23:24   ` [RESOLVED NOTABUG] " Bastien Traverse
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2015-05-22 22:06 UTC (permalink / raw)
  To: Bastien Traverse; +Cc: git

On Fri, May 22, 2015 at 03:18:53PM +0200, Bastien Traverse wrote:

> $ git --version
> git version 2.4.1
> 
> $ uname -a
> Linux arch-clevo 4.0.4-1-ARCH #1 SMP PREEMPT Mon May 18 06:43:19 CEST
> 2015 x86_64 GNU/Linux
> 
> $ mkdir test && cd test/
> $ git init
> $ touch test
> $ git add test
> 
> 1. ISO 8601 (strict)
> 
> $ git commit --date="2015-05-21T16∶31+02:00" -m "Test commit to check
> date format parsing"
> [master (root commit) fed9ae6] Test commit to check date format parsing
>  Date: Thu May 21 02:00:00 2015 +0200
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 test
> 
>   --> gets the date right but confuses the timezone for the time

OK, this is weird. When I tried to reproduce, I couldn't. But I had
typed in the date string myself while reading your email in another
window.  And though I was sure that I had typed it correctly, just to be
double-plus-sure I copied and pasted your string. And it failed!

The date string in your email looks like this (using cut and paste):

  $ echo 2015-05-21T16∶31+02:00 | xxd
  00000000: 3230 3135 2d30 352d 3231 5431 36e2 88b6  2015-05-21T16...
  00000010: 3331 2b30 323a 3030 0a                   31+02:00.

Your "colon" is actually UTF-8 for code point U+2236 ("RATIO"). So git's
date parser does not recognize it, and punts to approxidate(), which
does all manner of crazy guessing trying to figure out what you meant.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESOLVED NOTABUG] "git commit --date" format parsing
  2015-05-22 22:06 ` Jeff King
@ 2015-05-23 23:24   ` Bastien Traverse
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien Traverse @ 2015-05-23 23:24 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Le 23/05/2015 00:06, Jeff King a écrit :
> OK, this is weird. When I tried to reproduce, I couldn't. But I had
> typed in the date string myself while reading your email in another
> window.  And though I was sure that I had typed it correctly, just to be
> double-plus-sure I copied and pasted your string. And it failed!
> 
> The date string in your email looks like this (using cut and paste):
> 
>   $ echo 2015-05-21T16∶31+02:00 | xxd
>   00000000: 3230 3135 2d30 352d 3231 5431 36e2 88b6  2015-05-21T16...
>   00000010: 3331 2b30 323a 3030 0a                   31+02:00.
> 
> Your "colon" is actually UTF-8 for code point 	. So git's
> date parser does not recognize it, and punts to approxidate(), which
> does all manner of crazy guessing trying to figure out what you meant.

Okay, this is crazy. Now I can't reproduce it myself either: I just
repeated the procedure and date parsing works as expected. The only
difference with my last email is that I upgraded and rebooted my system
(there was a kernel update for 4.0.4 on Arch... Among other things). I
guess that would have reset my keyboard layout, but I swear I tested it
multiple times over a few days before posting here.

Anyway, thanks for your insight I would have never figured this myself.
I'll be wary of silent unicode character substitution :)

Just for the record:
$ localectl
   System Locale: LANG=fr_FR.UTF8
       VC Keymap: fr
      X11 Layout: fr
     X11 Variant: oss

And I am using the default monospace font in gnome-terminal and gedit.
Pretty basic stuff, really.

Thanks again,
Bastien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-23 23:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-22 13:18 [BUG] "git commit --date" format parsing Bastien Traverse
2015-05-22 22:06 ` Jeff King
2015-05-23 23:24   ` [RESOLVED NOTABUG] " Bastien Traverse

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).