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

Re: [PATCH] reset cached ident date before creating objects

From
Jeff King <peff@peff.net>
Date
Jul 30, 2016, 02:41 UTC
Message-ID
<20160730024135.oaqtjpo5l2e3dam2@sigill.intra.peff.net>
In-Reply-To
<CACRoPnS2kDRLiY8KX3K4Havh7d1GWy3mUXSiYCzw45BznuwYeA@mail.gmail.com>
On Sat, Jul 30, 2016 at 10:11:56AM +0800, Paul Tan wrote:
Show 17 quoted lines
> > diff --git a/commit.c b/commit.c
> > index 71a360d..7ddbffe 100644
> > --- a/commit.c
> > +++ b/commit.c
> > @@ -1548,6 +1548,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
> >         }
> >
> >         /* Person/date information */
> > +       reset_ident_date();
> >         if (!author)
> >                 author = git_author_info(IDENT_STRICT);
> >         strbuf_addf(&buffer, "author %s\n", author);
> 
> But since builtin/commit.c constructs its author ident string before
> calling the editor and then commit_tree_extended(), this would cause
> the resulting commits to have committer timestamps which differ from
> their author timestamps.

Hrm, yeah. I assumed it would only pass in the author string for things like "-c" or "--amend". But it looks like it unconditionally passes in the author. And it would be slightly difficult to have it pass NULL, because it may actually have _part_ of an author (e.g., "--author" will come up with name and email but not the date), so it has to sometimes combine those bits with things like ident_default_date() itself.

I guess one option would be to commit_tree_extended() to take the broken-down author bits and call fmt_ident() itself. That's what all of the callers are doing (that, or just passing NULL). It would make the interface a bit clunkier, but I think the end result would be more flexible.

I suppose that would be tricky for git-commit, because in addition to passing the result of fmt_ident() to commit_tree_extended(), it wants to take the pieces and put them in the environment for hooks to see. And if the data is available only inside commit_tree_extended(), we don't have it for the hooks.

> So maybe we would have to put reset_ident_date() at the end of the
> function instead, at least after git_committer_info() is called.
Yes, although "reset and end" still feels a bit weird to me.

I'd almost prefer to just have long-running programs insert resets at strategic points.

-Peff
Previous: Paul TanNext: Junio C Hamano
Message 12 of 26 in “Small trivial annoyance with the nice new builtin "git am"”
  1. Linus TorvaldsJul 28, 2016
  2. Junio C HamanoJul 28, 2016
  3. Jeff KingJul 29, 2016
  4. Linus TorvaldsJul 29, 2016
  5. Jeff KingJul 29, 2016
  6. Junio C HamanoJul 29, 2016
  7. reset cached ident date before creating objectsJeff King, Jul 29, 2016
  8. Linus TorvaldsJul 29, 2016
  9. Junio C HamanoJul 29, 2016
  10. Jeff KingJul 29, 2016
  11. Paul TanJul 30, 2016
  12. Jeff KingJul 30, 2016
  13. Junio C HamanoAug 1, 2016
  14. Junio C HamanoAug 1, 2016
  15. Jeff KingAug 1, 2016
  16. Jeff KingAug 1, 2016
  17. Jeff KingAug 1, 2016
  18. Jeff KingAug 1, 2016
  19. Junio C HamanoAug 1, 2016
  20. Jeff KingAug 1, 2016
  21. Junio C HamanoJul 29, 2016
  22. Junio C HamanoJul 29, 2016
  23. Jeff KingJul 29, 2016
  24. Linus TorvaldsJul 29, 2016
  25. Christian CouderJul 29, 2016
  26. Junio C HamanoJul 29, 2016

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.