{"thread":{"id":"21802","subject":"[PATCH] builtin-commit: add --date option","startedAt":"2009-12-01T00:27:32Z","lastAt":"2009-12-02T22:22:57Z","messageCount":12,"participants":["Miklos Vajna","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128827","messageId":"1259627252-21615-1-git-send-email-vmiklos@frugalware.org","threadId":"21802","inReplyTo":null,"subject":"[PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-01T00:27:32Z","receivedAt":"2009-12-01T00:27:32Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"This is useful in case git commit --amend is used but the user wants to\nset the date of the new commit to a specified one, since GIT_AUTHOR_DATE\nis ignored in such a situation.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\n Documentation/git-commit.txt |    6 +++++-\n builtin-commit.c             |    6 +++++-\n t/t7501-commit.sh            |   15 +++++++++++++++\n 3 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 3ea80c8..3b9a7c3 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>]\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@@ -80,6 +80,10 @@ 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.  The format is the Git\n+\tnative one and is `<time> SP <offutc>`.\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 09d2840..594328e 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;\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@@ -409,6 +410,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":"129020","messageId":"20091202171117.GY31763@genesis.frugalware.org","threadId":"21802","inReplyTo":"1259627252-21615-1-git-send-email-vmiklos@frugalware.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T17:11:18Z","receivedAt":"2009-12-02T17:11:18Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Dec 01, 2009 at 01:27:32AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> +--date=<date>::\n> +\tOverride the date used in the commit.  The format is the Git\n> +\tnative one and is `<time> SP <offutc>`.\n\nI just noticed that fmt_ident() calls parse_date(), so other formats are\nsupported as well.\n\nIs there any documentation describing what does parse_date() accept?\n\nBased on t0006-date.sh and the comments in the source, I see 3 supported\nformats:\n\n1) <unix timestamp> <timezone>\n\n2) A format like 2008-12-02 18:04:00\n\n3) RFC 2822 (Thu, 21 Dec 2000 16:01:07 +0200)\n\nThanks.\n"},{"id":"129027","messageId":"7vpr6xgtxn.fsf@alter.siamese.dyndns.org","threadId":"21802","inReplyTo":"20091202171117.GY31763@genesis.frugalware.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-02T17:35:48Z","receivedAt":"2009-12-02T17:35:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> On Tue, Dec 01, 2009 at 01:27:32AM +0100, Miklos Vajna <vmiklos@frugalware.org> wrote:\n>> +--date=<date>::\n>> +\tOverride the date used in the commit.  The format is the Git\n>> +\tnative one and is `<time> SP <offutc>`.\n>\n> I just noticed that fmt_ident() calls parse_date(), so other formats are\n> supported as well.\n>\n> Is there any documentation describing what does parse_date() accept?\n>\n> Based on t0006-date.sh and the comments in the source, I see 3 supported\n> formats:\n>\n> 1) <unix timestamp> <timezone>\n>\n> 2) A format like 2008-12-02 18:04:00\n>\n> 3) RFC 2822 (Thu, 21 Dec 2000 16:01:07 +0200)\n\nThe above are all supported (you can label 2 as ISO even though the\nofficial ISO8601 wants \"T\" instead of \" \" between date and time).\n\nFor more amusing ones, see\n\n    http://article.gmane.org/gmane.comp.version-control.git/12241\n\nand follow the discussion there ;-)\n"},{"id":"129030","messageId":"7vaay1gt0z.fsf@alter.siamese.dyndns.org","threadId":"21802","inReplyTo":"7vpr6xgtxn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-02T17:55:24Z","receivedAt":"2009-12-02T17:55:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Miklos Vajna <vmiklos@frugalware.org> writes:\n> ...\n>> Is there any documentation describing what does parse_date() accept?\n>>\n>> Based on t0006-date.sh and the comments in the source, I see 3 supported\n>> formats:\n>>\n>> 1) <unix timestamp> <timezone>\n>>\n>> 2) A format like 2008-12-02 18:04:00\n>>\n>> 3) RFC 2822 (Thu, 21 Dec 2000 16:01:07 +0200)\n>\n> The above are all supported (you can label 2 as ISO even though the\n> official ISO8601 wants \"T\" instead of \" \" between date and time).\n>\n> For more amusing ones, see\n>\n>     http://article.gmane.org/gmane.comp.version-control.git/12241\n>\n> and follow the discussion there ;-)\n\nI should have mentioned ones with more importance in real-life before\nreferring you to the amusing ones: US and European dates.\n\ndate.c::match_multi_number() groks these:\n\n    mm/dd/yy[yy] (US)\n    dd.mm.yy[yy] (European)\n"},{"id":"129043","messageId":"20091202192425.GC30778@coredump.intra.peff.net","threadId":"21802","inReplyTo":"7vpr6xgtxn.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-02T19:24:25Z","receivedAt":"2009-12-02T19:24:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 02, 2009 at 09:35:48AM -0800, Junio C Hamano wrote:\n\n> > Is there any documentation describing what does parse_date() accept?\n> [...]\n> The above are all supported (you can label 2 as ISO even though the\n> official ISO8601 wants \"T\" instead of \" \" between date and time).\n> \n> For more amusing ones, see\n> \n>     http://article.gmane.org/gmane.comp.version-control.git/12241\n> \n> and follow the discussion there ;-)\n\nAren't the amusing ones the result of approxidate, and not parse_date?\nAt least that is my recollection from working on the date code when I\nate 30 hot dogs last August.\n\n-Peff\n"},{"id":"129045","messageId":"20091202192614.GD30778@coredump.intra.peff.net","threadId":"21802","inReplyTo":"1259627252-21615-1-git-send-email-vmiklos@frugalware.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-02T19:26:14Z","receivedAt":"2009-12-02T19:26:14Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 01, 2009 at 01:27:32AM +0100, Miklos Vajna wrote:\n\n> This is useful in case git commit --amend is used but the user wants to\n> set the date of the new commit to a specified one, since GIT_AUTHOR_DATE\n> is ignored in such a situation.\n\nDo you really want to set the date to something arbitrary, or do you\njust want to set it to \"now\"? If the latter case, do you really just\nwant the recently discussed --reset-author?\n\nAlso, is there a good reason why GIT_AUTHOR_DATE is not respected in\nthis case?  If not, should we simply be fixing that bug instead?\n\n-Peff\n"},{"id":"129055","messageId":"7vpr6xcgki.fsf@alter.siamese.dyndns.org","threadId":"21802","inReplyTo":"20091202192614.GD30778@coredump.intra.peff.net","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-02T19:38:05Z","receivedAt":"2009-12-02T19:38:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Do you really want to set the date to something arbitrary, or do you\n> just want to set it to \"now\"? If the latter case, do you really just\n> want the recently discussed --reset-author?\n>\n> Also, is there a good reason why GIT_AUTHOR_DATE is not respected in\n> this case?  If not, should we simply be fixing that bug instead?\n\nI expect I won't be on the list for the rest of the day (I've started the\npreparation to tag -rc1), but I have two-and-half points before this\ndiscussion goes too far:\n\n - The \"--reset-author\" patch will be in 1.6.6 (it is already in 'master'\n   yesterday, I think);\n\n - We should honor GIT_AUTHOR_DATE if --reset-author is given.\n\n - I _think_ we should ignore GIT_AUTHOR_DATE if --reset-author is not\n   given, as --amend/-c/-C is stronger for being command line options than\n   an environment variable.\n\nSo I do not think --date is something we urgently need, even though it\nmight be nice to have it to be consistent with --author.\n"},{"id":"129062","messageId":"20091202203351.GB31763@genesis.frugalware.org","threadId":"21802","inReplyTo":"20091202192425.GC30778@coredump.intra.peff.net","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T20:33:51Z","receivedAt":"2009-12-02T20:33:51Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 02:24:25PM -0500, Jeff King <peff@peff.net> wrote:\n> On Wed, Dec 02, 2009 at 09:35:48AM -0800, Junio C Hamano wrote:\n> \n> > > Is there any documentation describing what does parse_date() accept?\n> > [...]\n> > The above are all supported (you can label 2 as ISO even though the\n> > official ISO8601 wants \"T\" instead of \" \" between date and time).\n> > \n> > For more amusing ones, see\n> > \n> >     http://article.gmane.org/gmane.comp.version-control.git/12241\n> > \n> > and follow the discussion there ;-)\n> \n> Aren't the amusing ones the result of approxidate, and not parse_date?\n> At least that is my recollection from working on the date code when I\n> ate 30 hot dogs last August.\n\nI think you are right, at least --date=\"2008-12-02 18:04:00\" works here,\nbut not --date=\"teatime\".\n"},{"id":"129067","messageId":"20091202210751.GC31763@genesis.frugalware.org","threadId":"21802","inReplyTo":"7vpr6xcgki.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T21:07:51Z","receivedAt":"2009-12-02T21:07:51Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 11:38:05AM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n>  - We should honor GIT_AUTHOR_DATE if --reset-author is given.\n\nThis is already a situation, as far as I see.\n\n>  - I _think_ we should ignore GIT_AUTHOR_DATE if --reset-author is not\n>    given, as --amend/-c/-C is stronger for being command line options than\n>    an environment variable.\n\nWe already ignore GIT_AUTHOR_DATE if --reset-author is not given, also\nwhen I change it like this:\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex e93a647..7234c7d 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -397,7 +397,8 @@ static void determine_author_info(void)\n\n                name = xstrndup(a + 8, lb - (a + 8));\n                email = xstrndup(lb + 2, rb - (lb + 2));\n-               date = xstrndup(rb + 2, eol - (rb + 2));\n+               if (!date)\n+                       date = xstrndup(rb + 2, eol - (rb + 2));\n        }\n\n        if (force_author) {\n\ntests 27, 33, 38 and 39 fail in t7501-commit.sh.\n"},{"id":"129072","messageId":"20091202214034.GD31763@genesis.frugalware.org","threadId":"21802","inReplyTo":"7vaay1gt0z.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T21:40:34Z","receivedAt":"2009-12-02T21:40:34Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 09:55:24AM -0800, Junio C Hamano <gitster@pobox.com> wrote:\n> I should have mentioned ones with more importance in real-life before\n> referring you to the amusing ones: US and European dates.\n> \n> date.c::match_multi_number() groks these:\n> \n>     mm/dd/yy[yy] (US)\n>     dd.mm.yy[yy] (European)\n\nAs far as I see these are also about approxidate() as well. But thanks\nfor the ISO number, now I have enough info to add documentation about\nit. Patch is coming soon... ;)\n"},{"id":"129073","messageId":"20091202221232.GF31763@genesis.frugalware.org","threadId":"21802","inReplyTo":"20091202192614.GD30778@coredump.intra.peff.net","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2009-12-02T22:12:32Z","receivedAt":"2009-12-02T22:12:32Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Dec 02, 2009 at 02:26:14PM -0500, Jeff King <peff@peff.net> wrote:\n> Do you really want to set the date to something arbitrary, or do you\n> just want to set it to \"now\"? If the latter case, do you really just\n> want the recently discussed --reset-author?\n\nNo, I want to set it to two days ago, for example when I forgot to\ncommit at the end of the day and I notice it two days later before I\nstart to work on something again.\n\n> Also, is there a good reason why GIT_AUTHOR_DATE is not respected in\n> this case?  If not, should we simply be fixing that bug instead?\n\nGIT_AUTHOR_DATE is respected by --reset-author, just given that we have\n--author already, using environment variables for a user can be\nuncomfortable.\n"},{"id":"129076","messageId":"20091202222257.GA9691@coredump.intra.peff.net","threadId":"21802","inReplyTo":"20091202221232.GF31763@genesis.frugalware.org","subject":"Re: [PATCH] builtin-commit: add --date option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-02T22:22:57Z","receivedAt":"2009-12-02T22:22:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 02, 2009 at 11:12:32PM +0100, Miklos Vajna wrote:\n\n> No, I want to set it to two days ago, for example when I forgot to\n> commit at the end of the day and I notice it two days later before I\n> start to work on something again.\n\nOK. I think you are being overly meticulous about your commit date, but\nthat is your right. ;)\n\n> > Also, is there a good reason why GIT_AUTHOR_DATE is not respected in\n> > this case?  If not, should we simply be fixing that bug instead?\n> \n> GIT_AUTHOR_DATE is respected by --reset-author, just given that we have\n> --author already, using environment variables for a user can be\n> uncomfortable.\n\nOK, I can agree with that reasoning.\n\n-Peff\n"}]}