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

Re: obsolete index in wt_status_print after pre-commit hook runs

From
Andrew Keller <andrew@kellerfarm.com>
Date
Jul 16, 2016, 02:39 UTC
Message-ID
<06EA5AA7-3E0B-4C2E-B5C3-89399F9890D1@kellerfarm.com>
In-Reply-To
<xmqqh9bqlfto.fsf@gitster.mtv.corp.google.com>
Am 15.07.2016 um 6:03 nachm. schrieb Junio C Hamano <gitster@pobox.com>:
Show 20 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>> On Fri, Jul 15, 2016 at 1:30 PM, Andrew Keller <andrew@kellerfarm.com> wrote:
>>> Am 15.07.2016 um 12:34 nachm. schrieb Andrew Keller <andrew@kellerfarm.com>:
>>> 
>>>> I pulled out the source for version 2.9.1 and briefly skimmed how run_commit and
>>>> prepare_to_commit work.  It seems that Git already understands that a pre-commit
>>>> hook can change the index, and it rereads the index before running the
>>>> prepare-commit-msg hook: https://github.com/git/git/blob/v2.9.1/builtin/commit.c#L941-L951
>>> 
>>> Quick question: Why does Git reread the index after the pre-commit hook runs?
>> 
>> Offhand I do not think of a good reason to do so; does something break
>> if you took it out?
> 
> Ahh, I misremembered.  2888605c (builtin-commit: fix partial-commit
> support, 2007-11-18) does consider the possibility that pre-commit
> may have modified the index contents after we take control back from
> that hook, so that is probably a good place to enumerate what got
> changed.  Getting the list before running the hook can give an
> out-of-date list, as you said.

Interesting. So, the implication is that disallowing the pre-commit hook to change the index may cause some problems (491 problems, if my run of the tests was accurate).

Does that mean it would be desirable to update the index before the commit message template is rendered?

Thanks,
 - Andrew Keller
Previous: Junio C HamanoNext: Andrew Keller
Message 9 of 13 in “obsolete index in wt_status_print after pre-commit hook runs”
  1. Andrew KellerJul 15, 2016
  2. Junio C HamanoJul 15, 2016
  3. Andrew KellerJul 15, 2016
  4. Junio C HamanoJul 15, 2016
  5. Andrew KellerJul 15, 2016
  6. Andrew KellerJul 15, 2016
  7. Junio C HamanoJul 15, 2016
  8. Junio C HamanoJul 15, 2016
  9. Andrew KellerJul 16, 2016
  10. Andrew KellerAug 3, 2016
  11. Junio C HamanoAug 4, 2016
  12. Andrew KellerAug 5, 2016
  13. Andrew KellerJul 16, 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.