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

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

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Apr 19, 2018, 09:15 UTC
Message-ID
<65ca9629-46b1-2963-9b6b-99f12a18689d@talktalk.net>
In-Reply-To
<d4aee85d-956f-ac93-b909-6dfeb5ea8fd7@kdbg.org>
On 18/04/18 19:15, Johannes Sixt wrote:
Show 38 quoted lines
> Am 18.04.2018 um 19:47 schrieb Phillip Wood:
>> On 18/04/18 12:27, Ævar Arnfjörð Bjarmason wrote:
>>> On Wed, Apr 18 2018, Phillip Wood wrote:
>>>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>>> 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().
> 
> While I like the basic theme of your patch, I think we should fix this
> case in a much simpler way, namely, use the infrastructure that was
> introduced for git-am.
> 
> I've shamelessly lifted the commit message from your patch.

Thanks, that is a better way (I'm annoyed with myself for not having noticed reset_ident_date() when I edited the function above it)

Best Wishes
Phillip
Show 32 quoted lines
> ---- 8< ----
> Subject: [PATCH] sequencer: reset the committer date before commits
> 
> 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
> 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. Reset the cached date before a commit is generated
> in-process.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  sequencer.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sequencer.c b/sequencer.c
> index f9d1001dee..f0bac903a0 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1148,6 +1148,8 @@ static int try_to_commit(struct strbuf *msg, const char *author,
>  		goto out;
>  	}
>  
> +	reset_ident_date();
> +
>  	if (commit_tree_extended(msg->buf, msg->len, &tree, parents,
>  				 oid, author, opts->gpg_sign, extra)) {
>  		res = error(_("failed to write commit object"));
> 
Previous: Junio C HamanoNext: Johannes Schindelin
Message 15 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.