Re: obsolete index in wt_status_print after pre-commit hook runs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 15, 2016, 22:03 UTC
- Message-ID
- <xmqqh9bqlfto.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAPc5daWZofdZnE0VQyFX2sBQyEDvAPmU+4rmHe5rvh7eH001ZA@mail.gmail.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> 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.
Thanks.