git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH] ident: don't cache default date

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 18, 2018, 11:27 UTC
Message-ID
<87vacoeovh.fsf@evledraar.gmail.com>
In-Reply-To
<20180418102236.7183-1-phillip.wood@talktalk.net>
On Wed, Apr 18 2018, Phillip Wood wrote:
Show 5 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Now that the sequencer commits without forking when the commit message
> isn't edited all the commits that are picked have the same committer
> date. If a commit is reworded it's committer date will be a later time
s/it's/its/
Show 41 quoted lines
> as it is created by running an separate instance of 'git commit'.  If
> the reworded commit is follow by further picks, those later commits
> will have an earlier committer date than the reworded one. This is
> caused by git caching the default date used when GIT_COMMITTER_DATE is
> not set. Fix this by not caching the date.
>
> Users expect commits to have the same author and committer dates when
> the don't explicitly set them. As the date is now updated each time
> git_author_info() or git_committer_info() is run it is possible to end
> up with different author and committer dates. Fix this for
> 'commit-tree', 'notes' and 'merge' by using a single date in
> commit_tree_extended() and passing it explicitly to the new functions
> git_author_info_with_date() and git_committer_info_with_date() when
> neither the author date nor the committer date are explicitly
> set. 'commit' always passes the author date to commit_tree_extended()
> and relied on the date caching to have the same committer and author
> dates when neither was specified. Fix this by setting
> GIT_COMMITTER_DATE to be the same as the author date passed to
> commit_tree_extended().
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> Reported-by: Johannes Sixt <j6t@kdbg.org>
> ---
>
> I'm slightly nervous that setting GIT_COMMITTER_DATE in
> builtin/commit.c will break someone's hook script. Maybe it would be
> better to add a committer parameter to commit_tree() and
> commit_tree_extended().
>
> This needs some tests. I think we could test that the sequencer gives
> each commit a new date with 'git rebase -i --exec="sleep 2"
> --force-rebase @~2' and test the committer dates of the rebased
> commits. I'm not sure if test -gt can cope with numbers that big
> though, maybe we'll have to be content with test !=. For 'git commit'
> I think doing GIT_EDITOR='sleep 2; echo message >"$1"' and checking
> the committer date and author date will work as the author date is set
> before the user edits the commit message. I'm not sure how to test
> callers of commit_tree() though (that's commit-tree, notes and merge)
> as I've not been able to come up with anything that will guarantee the
> author and committer dates are different if the code in
> commit_tree_extended() that ensures they are the same gets broken.

The behavior you're describing where we end up with later commits in the rebase with earlier CommitDate's definitely sounds like a minor regression, and yeah we should have tests for this.

My mental model of this is that we shouldn't be trying at all to adjust the CommitDate in a sequence to be the same, and just make it be whatever time() returns, except in the case where a date is passed explicitly.

My cursory reading of this RFC patch is that it's definitely an improvement because we don't end up with things out of order, but is there any reason for why we should be trying to aim to keep this "consistent" within a single "git rebase" command by default, as opposed to always just writing the current CommitDate at the time we make the commit, that sounds like the most intuitive thing to me, and I can't see any downsides with that.

It leaks info about how long it took someone to do the rebase, but so what?

Previous: Phillip WoodNext: Phillip Wood
Message 11 of 17 in “Bug: rebase -i creates committer time inversions on 'reword'”
  1. Johannes SixtApr 13, 2018
  2. Phillip WoodApr 14, 2018
  3. Johannes SchindelinApr 14, 2018
  4. Phillip WoodApr 16, 2018
  5. Phillip WoodApr 19, 2018
  6. Junio C HamanoApr 15, 2018
  7. Johannes SixtApr 16, 2018
  8. Junio C HamanoApr 17, 2018
  9. Phillip WoodApr 18, 2018
  10. ident: don't cache default datePhillip Wood, Apr 18, 2018
  11. Ævar Arnfjörð BjarmasonApr 18, 2018
  12. Phillip WoodApr 18, 2018
  13. Johannes SixtApr 18, 2018
  14. Junio C HamanoApr 18, 2018
  15. Phillip WoodApr 19, 2018
  16. Johannes SchindelinApr 20, 2018
  17. Phillip WoodApr 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.