[BUG] "git commit --date" format parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]