{"thread":{"id":"42030","subject":"[Bug?] \"git commit --amend\" always gives author-date to summary?","startedAt":"2016-04-14T21:07:50Z","lastAt":"2016-04-15T02:13:00Z","messageCount":3,"participants":["Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"283489","messageId":"xmqqh9f3gaqh.fsf@gitster.mtv.corp.google.com","threadId":"42030","inReplyTo":null,"subject":"[Bug?] \"git commit --amend\" always gives author-date to summary?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-14T21:07:50Z","receivedAt":"2016-04-14T21:07:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A simple reproduction.  Doing one of these\n\n    $ git commit --amend --no-edit\n    $ echo >MSG frotz; git commit --amend -F MSG\n\non any commit, whether it is your own commit or somebody else's,\nseems to always show the \"Date:\" of the original commit, e.g.\n\n    $ git checkout v2.8.0^0\n    $ git commit --amend --no-edit\n    [detached HEAD a6f2a14] Git 2.8\n     Date: Mon Mar 28 12:19:45 2016 -0700\n     3 files changed, 14 insertions(+), 9 deletions(-)\n    $ git checkout v2.8.0^^2\n    $ git commit --amend --no-edit\n    [detached HEAD df9f57e] Documentation: fix git-p4 AsciiDoc formatting\n     Author: Lars Schneider <larsxschneider@gmail.com>\n     Date: Wed Mar 23 11:59:01 2016 +0100\n     1 file changed, 3 insertions(+), 5 deletions(-)\n\nI can understand the latter, but I am not sure if it makes sense to\ndo the former.  The output is coming from b7242b8c (commit: print\n\"Date\" line when the user has set date, 2014-05-01), whose objective\nI can agree with, but does not seem to match the use case.\n\n    commit: print \"Date\" line when the user has set date\n    \n    When we make a commit and the author is not the same as the\n    committer (e.g., because you used \"-c $commit\" or\n    \"--author=$somebody\"), we print the author's name and email\n    in both the commit-message template and as part of the\n    commit summary. This is a safety check to give the user a\n    chance to confirm that we are doing what they expect.\n    \n    This patch brings the same safety for the \"date\" field,\n    which may be set by \"-c\" or by using \"--date\".  Note that we\n    explicitly do not set it for $GIT_AUTHOR_DATE, as it is\n    probably not of interest when \"git commit\" is being fed its\n    parameters by a script.\n\nWhen doing \"--amend\", not updating the author-date is the norm.\nAlso, I think the output is meant to accompany with the reminder to\nsay \"You are committing somebody else's change\", but in the first\ncase of amending v2.8.0^0, \"the author is not the same as the\ncommitter\" does not apply, either.\n\nThe commit in question, b7242b8c, brings in a test for amend to\n7501, like this:\n \n    test_expect_success 'commit mentions forced date in output' '\n            git commit --amend --date=2010-01-02T03:04:05 >output &&\n            grep \"Date: *Sat Jan 2 03:04:05 2010\" output\n    '\n\nBut if I change it like this:\n\n    test_expect_success 'amend always mentions date in output' '\n            git commit --amend >output &&\n            grep \"Date: \" output\n    '\n\nthe test still passes.\n\nI suspect that there are people who are already depending on this\nbehaviour, so it may not be worth fixing, but I found it somewhat\nirritating (especially after wasting about an hour or so doing wild\ngoose chase trying to find a stray invocation of \"date\" somewhere in\nmy script that eventually uses \"git commit --amend\").\n\nThoughts?\n"},{"id":"283512","messageId":"20160415020300.GA22112@sigill.intra.peff.net","threadId":"42030","inReplyTo":"xmqqh9f3gaqh.fsf@gitster.mtv.corp.google.com","subject":"Re: [Bug?] \"git commit --amend\" always gives author-date to summary?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-04-15T02:03:01Z","receivedAt":"2016-04-15T02:03:01Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Apr 14, 2016 at 02:07:50PM -0700, Junio C Hamano wrote:\n\n> A simple reproduction.  Doing one of these\n> \n>     $ git commit --amend --no-edit\n>     $ echo >MSG frotz; git commit --amend -F MSG\n> \n> on any commit, whether it is your own commit or somebody else's,\n> seems to always show the \"Date:\" of the original commit, e.g.\n> \n>     $ git checkout v2.8.0^0\n>     $ git commit --amend --no-edit\n>     [detached HEAD a6f2a14] Git 2.8\n>      Date: Mon Mar 28 12:19:45 2016 -0700\n>      3 files changed, 14 insertions(+), 9 deletions(-)\n>     $ git checkout v2.8.0^^2\n>     $ git commit --amend --no-edit\n>     [detached HEAD df9f57e] Documentation: fix git-p4 AsciiDoc formatting\n>      Author: Lars Schneider <larsxschneider@gmail.com>\n>      Date: Wed Mar 23 11:59:01 2016 +0100\n>      1 file changed, 3 insertions(+), 5 deletions(-)\n> \n> I can understand the latter, but I am not sure if it makes sense to\n> do the former.  The output is coming from b7242b8c (commit: print\n> \"Date\" line when the user has set date, 2014-05-01), whose objective\n> I can agree with, but does not seem to match the use case.\n\nThat's working as I intended it in both cases. The point is to show\nextra information whenever we have picked an ident or date that is not\nthe \"normal\" one. As you noted later, leaving the old author date is the\nnormal thing for \"--amend\", but it's still different from a normal\ncommit that uses the current user and the current date. So I guess it\ndepends on how you define normal.\n\nIMHO, we are better off generally erring on the side of printing extra\ninformation. The command is already quite chatty, and we are more likely\nto remind somebody that they wanted \"--reset-author\" than to bother\nthing.\n\n> [...]\n> I suspect that there are people who are already depending on this\n> behaviour, so it may not be worth fixing, but I found it somewhat\n> irritating (especially after wasting about an hour or so doing wild\n> goose chase trying to find a stray invocation of \"date\" somewhere in\n> my script that eventually uses \"git commit --amend\").\n> \n> Thoughts?\n\nSo I don't agree that is a \"fix\" to change it. But if it bothers you, I\ndon't mind a knob to suppress it in certain cases.\n\n-Peff\n"},{"id":"283516","messageId":"xmqq7ffzei1f.fsf@gitster.mtv.corp.google.com","threadId":"42030","inReplyTo":"20160415020300.GA22112@sigill.intra.peff.net","subject":"Re: [Bug?] \"git commit --amend\" always gives author-date to summary?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-15T02:13:00Z","receivedAt":"2016-04-15T02:13:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> That's working as I intended it in both cases. The point is to show\n> extra information whenever we have picked an ident or date that is not\n> the \"normal\" one.\n\nOK.\n"}]}