{"thread":{"id":"21832","subject":"[PATCH 2/2] Document date formats accepted by parse_date()","startedAt":"2009-12-02T22:16:18Z","lastAt":"2009-12-02T23:49:19Z","messageCount":6,"participants":["Miklos Vajna","Nanako Shiraishi","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"129075","messageId":"3d547f4e32c026efc76a7dfe1572da617714f8c9.1259791789.git.vmiklos@frugalware.org","threadId":"21832","inReplyTo":"7vpr6xcgki.fsf@alter.siamese.dyndns.org","subject":"[PATCH 1/2] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T22:16:18Z","receivedAt":"2009-12-02T22:16:18Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"This is like --author: allow a user to specify a given date without\nusing the GIT_AUTHOR_DATE environment variable.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nOn Wed, Dec 02, 2009 at 11:38:05AM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n> So I do not think --date is something we urgently need, even though it\n> might be nice to have it to be consistent with --author.\n\nChanges from the previous version:\n\n* updated the commit message\n\n* rebased on top of current master that has --reset-author\n\n Documentation/git-commit.txt |    5 ++++-\n builtin-commit.c             |    6 +++++-\n t/t7501-commit.sh            |   15 +++++++++++++++\n 3 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex d227cec..cbbbeeb 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -11,7 +11,7 @@ SYNOPSIS\n 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]\n \t   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--reset-author]\n \t   [--allow-empty] [--no-verify] [-e] [--author=<author>]\n-\t   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n+\t   [--date=<date>] [--cleanup=<mode>] [--] [[-i | -o ]<file>...]\n \n DESCRIPTION\n -----------\n@@ -85,6 +85,9 @@ OPTIONS\n \tan existing commit that matches the given string and its author\n \tname is used.\n \n+--date=<date>::\n+\tOverride the date used in the commit.\n+\n -m <msg>::\n --message=<msg>::\n \tUse the given <msg> as the commit message.\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex e93a647..9a1264a 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -52,7 +52,7 @@ static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n-static char *untracked_files_arg;\n+static char *untracked_files_arg, *force_date;\n /*\n  * The default commit message cleanup mode will remove the lines\n  * beginning with # (shell comments) and leading and trailing\n@@ -90,6 +90,7 @@ static struct option builtin_commit_options[] = {\n \n \tOPT_FILENAME('F', \"file\", &logfile, \"read log from file\"),\n \tOPT_STRING(0, \"author\", &force_author, \"AUTHOR\", \"override author for commit\"),\n+\tOPT_STRING(0, \"date\", &force_date, \"DATE\", \"override date for commit\"),\n \tOPT_CALLBACK('m', \"message\", &message, \"MESSAGE\", \"specify commit message\", opt_parse_m),\n \tOPT_STRING('c', \"reedit-message\", &edit_message, \"COMMIT\", \"reuse and edit message from specified commit\"),\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n@@ -410,6 +411,9 @@ static void determine_author_info(void)\n \t\temail = xstrndup(lb + 2, rb - (lb + 2));\n \t}\n \n+\tif (force_date)\n+\t\tdate = force_date;\n+\n \tauthor_name = name;\n \tauthor_email = email;\n \tauthor_date = date;\ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex a603f6d..a529701 100755\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -211,6 +211,21 @@ test_expect_success 'amend commit to fix author' '\n \n '\n \n+test_expect_success 'amend commit to fix date' '\n+\n+\ttest_tick &&\n+\tnewtick=$GIT_AUTHOR_DATE &&\n+\tgit reset --hard &&\n+\tgit cat-file -p HEAD |\n+\tsed -e \"s/author.*/author $author $newtick/\" \\\n+\t\t-e \"s/^\\(committer.*> \\).*$/\\1$GIT_COMMITTER_DATE/\" > \\\n+\t\texpected &&\n+\tgit commit --amend --date=\"$newtick\" &&\n+\tgit cat-file -p HEAD > current &&\n+\ttest_cmp expected current\n+\n+'\n+\n test_expect_success 'sign off (1)' '\n \n \techo 1 >positive &&\n-- \n1.6.5.2\n"},{"id":"129074","messageId":"831fc8f48429d5a21e29d04760b46b2ddfcb7d80.1259791789.git.vmiklos@frugalware.org","threadId":"21832","inReplyTo":"3d547f4e32c026efc76a7dfe1572da617714f8c9.1259791789.git.vmiklos@frugalware.org","subject":"[PATCH 2/2] Document date formats accepted by parse_date()","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T22:16:19Z","receivedAt":"2009-12-02T22:16:19Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"---\n Documentation/date-formats.txt    |   23 +++++++++++++++++++++++\n Documentation/git-commit-tree.txt |    1 +\n Documentation/git-commit.txt      |    2 ++\n 3 files changed, 26 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/date-formats.txt\n\ndiff --git a/Documentation/date-formats.txt b/Documentation/date-formats.txt\nnew file mode 100644\nindex 0000000..626c887\n--- /dev/null\n+++ b/Documentation/date-formats.txt\n@@ -0,0 +1,23 @@\n+DATE FORMATS\n+------------\n+\n+The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables\n+ifdef::git-commit[]\n+and the `--date` option\n+endif::git-commit[]\n+support the following date formats:\n+\n+Git native format::\n+\tIt is `<unix timestamp> <timezone offset>`, where `<unix\n+\ttimestamp>` is the number of seconds since the UNIX epoch.\n+\t`<timezone offset>` is a positive or negative offset from UTC.\n+\tFor example CET (which is 2 hours ahead UTC) is `+0200`.\n+\n+RFC 2822::\n+\tThe standard email format as described by RFC 2822, for example\n+\t`Thu, 07 Apr 2005 22:13:13 +0200`.\n+\n+ISO 8601::\n+\tTime and date specified by the ISO 8601 standard, for example\n+\t`2005-04-07T22:13:13`. The parser accepts a space instead of the\n+\t`T` character as well.\ndiff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt\nindex b8834ba..4fec5d5 100644\n--- a/Documentation/git-commit-tree.txt\n+++ b/Documentation/git-commit-tree.txt\n@@ -73,6 +73,7 @@ A commit comment is read from stdin. If a changelog\n entry is not provided via \"<\" redirection, 'git-commit-tree' will just wait\n for one to be entered and terminated with ^D.\n \n+include::date-formats.txt[]\n \n Diagnostics\n -----------\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex cbbbeeb..17783b4 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -220,6 +220,8 @@ specified.\n \tthese files are also staged for the next commit on top\n \tof what have been staged before.\n \n+:git-commit: 1\n+include::date-formats.txt[]\n \n EXAMPLES\n --------\n-- \n1.6.5.2\n"},{"id":"129078","messageId":"20091203073313.6117@nanako3.lavabit.com","threadId":"21832","inReplyTo":"831fc8f48429d5a21e29d04760b46b2ddfcb7d80.1259791789.git.vmiklos@frugalware.org","subject":"Re: [PATCH 2/2] Document date formats accepted by parse_date()","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-02T22:33:13Z","receivedAt":"2009-12-02T22:33:13Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Miklos Vajna <vmiklos@frugalware.org>\n\n> ---\n\nI don't think any message needs to be there, but a Signed-Off-By: \nline should be.\n\n> +The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables\n> +ifdef::git-commit[]\n> +and the `--date` option\n> +endif::git-commit[]\n> +support the following date formats:\n> +\n> +Git native format::\n> +\tIt is `<unix timestamp> <timezone offset>`, where `<unix\n> +\ttimestamp>` is the number of seconds since the UNIX epoch.\n> +\t`<timezone offset>` is a positive or negative offset from UTC.\n> +\tFor example CET (which is 2 hours ahead UTC) is `+0200`.\n\nIt is better to call it 'internal' format, instead of 'native'. \nI think 'native' means the most natural way to Git, and users \nview what 'git show' outputs as 'native'.\n\n  nana.git% git show -s v1.6.5^0 | grep Date\n  Date:   Sat Oct 10 00:05:19 2009 -0700\n  nana.git% ./test-date parse 'Sat Oct 10 00:05:19 2009 -0700'\n  Sat Oct 10 00:05:19 2009 -0700 -> 2009-10-10 07:05:19 +0000\n\nAnd 'Git native' format is also supported, I think.\n\n> +RFC 2822::\n> +\tThe standard email format as described by RFC 2822, for example\n> +\t`Thu, 07 Apr 2005 22:13:13 +0200`.\n> +\n> +ISO 8601::\n> +\tTime and date specified by the ISO 8601 standard, for example\n> +\t`2005-04-07T22:13:13`. The parser accepts a space instead of the\n> +\t`T` character as well.\n\nI didn't know about \"T\", but it works (^_^).\n\n  nana.git% ./test-date parse '2005-04-07T22:13:13'\n  2005-04-07T22:13:13 -> 2005-04-07 13:13:13 +0000\n\nIs there something wrong with 'show'?\n\n  nana.git% ./test-date show '2005-04-07T22:13:13'\n  2005-04-07T22:13:13 -> 40 years ago\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"129081","messageId":"20091202224206.GC9691@coredump.intra.peff.net","threadId":"21832","inReplyTo":"20091203073313.6117@nanako3.lavabit.com","subject":"Re: [PATCH 2/2] Document date formats accepted by parse_date()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-02T22:42:06Z","receivedAt":"2009-12-02T22:42:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 03, 2009 at 07:33:13AM +0900, Nanako Shiraishi wrote:\n\n> Is there something wrong with 'show'?\n> \n>   nana.git% ./test-date show '2005-04-07T22:13:13'\n>   2005-04-07T22:13:13 -> 40 years ago\n\nNo. It doesn't call parse_date, but instead accepts a time_t-like\n\"seconds since epoch\". I intentionally didn't use parse_date because I\ndidn't want bugs in parse_date to affect 'show' output, to keep testing\nsimple.\n\n-Peff\n"},{"id":"129082","messageId":"7v638p9ebz.fsf@alter.siamese.dyndns.org","threadId":"21832","inReplyTo":"20091203073313.6117@nanako3.lavabit.com","subject":"Re: [PATCH 2/2] Document date formats accepted by parse_date()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-02T22:54:40Z","receivedAt":"2009-12-02T22:54:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> Is there something wrong with 'show'?\n>\n>   nana.git% ./test-date show '2005-04-07T22:13:13'\n>   2005-04-07T22:13:13 -> 40 years ago\n\nHeh, you fooled me, and Peff is right.  \"test-date show\" does not\ninterpret its input any way other than as seconds-since-epoch.\n\nI agree with the \"native->internal\" part of the suggestion.  What see by\ndefault in \"git show\" output is merely the ctime(3) format followed by\ntimezone.  I don't mind if we call that \"git native\", even though I\nsuspect we do _not have to_ invent new word for that.\n\nAlso \"test-date parse\" seems to accept things like these:\n\n    '2009.04.07 20:21:22 -0000'\n    '04/07/2009 20:21:22 -0000'\n    '07.04.2009 20:21:22 -0000'\n"},{"id":"129087","messageId":"465359e7bb6f00b622a1a5df5bc178eee019f4a2.1259797598.git.vmiklos@frugalware.org","threadId":"21832","inReplyTo":"7v638p9ebz.fsf@alter.siamese.dyndns.org","subject":"[PATCH 2/2 v2] Document date formats accepted by parse_date()","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T23:49:19Z","receivedAt":"2009-12-02T23:49:19Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"---\n\nOn Wed, Dec 02, 2009 at 02:54:40PM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n> I agree with the \"native->internal\" part of the suggestion.\n\nChanged.\n\n> Also \"test-date parse\" seems to accept things like these:\n>\n>     '2009.04.07 20:21:22 -0000'\n>     '04/07/2009 20:21:22 -0000'\n>     '07.04.2009 20:21:22 -0000'\n\nAh OK, I just tried 2009.04.07 (without the time part) and thought it\nwas about approxidate() as well. I added them.\n\n Documentation/date-formats.txt    |   26 ++++++++++++++++++++++++++\n Documentation/git-commit-tree.txt |    1 +\n Documentation/git-commit.txt      |    2 ++\n 3 files changed, 29 insertions(+), 0 deletions(-)\n create mode 100644 Documentation/date-formats.txt\n\ndiff --git a/Documentation/date-formats.txt b/Documentation/date-formats.txt\nnew file mode 100644\nindex 0000000..c000f08\n--- /dev/null\n+++ b/Documentation/date-formats.txt\n@@ -0,0 +1,26 @@\n+DATE FORMATS\n+------------\n+\n+The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables\n+ifdef::git-commit[]\n+and the `--date` option\n+endif::git-commit[]\n+support the following date formats:\n+\n+Git internal format::\n+\tIt is `<unix timestamp> <timezone offset>`, where `<unix\n+\ttimestamp>` is the number of seconds since the UNIX epoch.\n+\t`<timezone offset>` is a positive or negative offset from UTC.\n+\tFor example CET (which is 2 hours ahead UTC) is `+0200`.\n+\n+RFC 2822::\n+\tThe standard email format as described by RFC 2822, for example\n+\t`Thu, 07 Apr 2005 22:13:13 +0200`.\n+\n+ISO 8601::\n+\tTime and date specified by the ISO 8601 standard, for example\n+\t`2005-04-07T22:13:13`. The parser accepts a space instead of the\n+\t`T` character as well.\n++\n+NOTE: In addition, the date part is accepted in the following formats:\n+`YYYY.MM.DD`, `MM/DD/YYYY` and `DD.MM.YYYY`.\ndiff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt\nindex b8834ba..4fec5d5 100644\n--- a/Documentation/git-commit-tree.txt\n+++ b/Documentation/git-commit-tree.txt\n@@ -73,6 +73,7 @@ A commit comment is read from stdin. If a changelog\n entry is not provided via \"<\" redirection, 'git-commit-tree' will just wait\n for one to be entered and terminated with ^D.\n \n+include::date-formats.txt[]\n \n Diagnostics\n -----------\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex cbbbeeb..17783b4 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -220,6 +220,8 @@ specified.\n \tthese files are also staged for the next commit on top\n \tof what have been staged before.\n \n+:git-commit: 1\n+include::date-formats.txt[]\n \n EXAMPLES\n --------\n-- \n1.6.5.2\n"}]}