Re: [RFC PATCH] ident: don't cache default date
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 18, 2018, 21:15 UTC
- Message-ID
- <xmqqvacogqs4.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <d4aee85d-956f-ac93-b909-6dfeb5ea8fd7@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
> 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.
Yup. reset_ident_date() was introduced by 4d9c7e6f ("am: reset cached ident date for each patch", 2016-08-01) and the commit explains very well why it is a good idea to have both the caching and also the strategic resetting it introduces.
Thanks, all.
Show 33 quoted lines
> I've shamelessly lifted the commit message from your patch.
>
> ---- 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"));