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

Re: [PATCH] builtin-commit: re-read file index before launching editor

From
SYSamuel Yvon <samuelyvon9@gmail.com>
Date
Nov 9, 2021, 15:22 UTC
Message-ID
<20211109152219.11037-1-samuelyvon9@gmail.com>
In-Reply-To
<211109.868rxxvgdi.gmgdl@evledraar.gmail.com>
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> *nod*, the implicit suggestion here being: Let's put more of that
> summary into the commit message. It helps when looking up/discovering
> older behavior.

Sorry! I will prepare an amended patch later. Exploring the linked commits has raised more questions on my end.

Show 5 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> The comment was first added in 2888605c649 (builtin-commit: fix
>         partial-commit support, 2007-11-18), and quite suspicuous in timing is
> f5bbc3225c4 (Port git commit to C., 2007-11-08) where we moved from
> git-commit.sh.

Exploring these commits, I fear I might have been confused; the editor was always launched after the reset (still today). The problem, as noted earlier, is the fact that the run_status is ran before the cache reset, which creates the outdated diff. I can't speculate to the intent of the author, but exploring the code makes this comment:

Show 5 quoted lines
> +    /*
> +     * Re-read the index as pre-commit hook could have updated it,
> +     * and write it out as a tree.  We must do this before we invoke
> +     * the editor and after we invoke run_status above.
> +     */

more confusing, because there is no point of invoking the editor after the reset if the status is written before, since the editor won't show anything different.

On one hand, flushing then showing the editor seems to indicate that we want the editor to be up-to-date, but because the status is prepared before the flushing, maybe not?

While it seems the current behaviour has been the behaviour since the start, I am inclined to continue pushing for this change. Unless I am missing something, the comment is contradictory and we should be coherent with the idea of accepting changes made within the pre-commit hook, as noted in https://lore.kernel.org/git/xmqqk0yripca.fsf@gitster.c.googlers.com/t/#u:

>> Junio C Hamano <gitster@pobox.com> writes:
>> Even before ec84bd00 (git-commit: Refactor creation of log message.,
>> 2008-02-05), the code anticipated that pre-commit may touch the index
>> and tried to cope with it.
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 5 of 18 in “builtin-commit: re-read file index before launching editor”
  1. builtin-commit: re-read file index before launching editorSamuel Yvon via GitGitGadget, Nov 9, 2021
  2. Ævar Arnfjörð BjarmasonNov 9, 2021
  3. samuelyvon9@gmail.comNov 9, 2021
  4. Ævar Arnfjörð BjarmasonNov 9, 2021
  5. Samuel YvonNov 9, 2021
  6. Junio C HamanoNov 9, 2021
  7. Samuel YvonNov 9, 2021
  8. Junio C HamanoNov 11, 2021
  9. Description of github.com/git/git, was Re: [PATCH] builtin-commit: re-read file index before launching editorJohannes Schindelin, Nov 9, 2021
  10. Samuel YvonNov 9, 2021
  11. Junio C HamanoNov 9, 2021
  12. Taylor BlauNov 9, 2021
  13. Samuel YvonNov 9, 2021
  14. Johannes SchindelinNov 10, 2021
  15. builtin-commit: re-read file index before run_statusSamuel Yvon via GitGitGadget, Nov 11, 2021
  16. Junio C HamanoNov 12, 2021
  17. Samuel YvonNov 17, 2021
  18. Junio C HamanoNov 18, 2021

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.