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
Ssamuelyvon9@gmail.com <samuelyvon9@gmail.com>
Date
Nov 9, 2021, 03:08 UTC
Message-ID
<20211109030804.261493-1-samuelyvon9@gmail.com>
In-Reply-To
<211109.86wnlicaur.gmgdl@evledraar.gmail.com>
From: Samuel Yvon <samuelyvon9@gmail.com>
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> The code you're moving around has a comment which seems to suggest that
> what you want *is* the desired behavior, i.e. we re-read it before
> invoking the editor, so we should have the updated diff, but just don't?

My understanding is that it was once the behaviour and has changed over time. I am saying this based on https://lore.kernel.org/git/xmqqk0yripca.fsf@gitster.c.googlers.com/t/#u

Specifically,
Show 21 quoted lines
> 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.
> However, ec84bd00 moved the place where we re-read the on-disk index
> in the sequence, and updated a message that used to read:
> 
> -    /*
> -     * Re-read the index as pre-commit hook could have updated it,
> -     * and write it out as a tree.
> -     */
> 
> to:
> 
> +    /*
> +     * 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.
> +     */
> 
> Unfortunately there is no mention of the reason why we "must" here.

Looking at ec84bd00 (git-commit: Refactor creation of log message., 2008-02-05), we can see that the editor is launched after the cache has been reset. The only part that troubles me is the line in the comment that specifies that "we must do this ... after we invoke run_status above". I have tested (with my limited knowledge of the internals of git) and it seems to be of no consequence of flushing before the call to run_status, but I might be missing something.

> The code you're moving around has a comment which seems to suggest that
> what you want *is* the desired behavior, i.e. we re-read it before
> invoking the editor, so we should have the updated diff, but just don't?
I think this is the case (based on the previously linked conversation).
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 3 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.