All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bastien Traverse <bt@esrevart.net>
To: git@vger.kernel.org
Subject: [BUG] "git commit --date" format parsing
Date: Fri, 22 May 2015 15:18:53 +0200	[thread overview]
Message-ID: <555F2CBD.8050501@esrevart.net> (raw)

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

             reply	other threads:[~2015-05-22 13:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 13:18 Bastien Traverse [this message]
2015-05-22 22:06 ` [BUG] "git commit --date" format parsing Jeff King
2015-05-23 23:24   ` [RESOLVED NOTABUG] " Bastien Traverse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555F2CBD.8050501@esrevart.net \
    --to=bt@esrevart.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.