pr-git-1127/SamuelYvon/maint-v2
tagged this
11 Nov 17:55
From: Samuel Yvon <samuelyvon9@gmail.com> Changes made within a pre-commit hook are not reflected within the editor (for instance, with `git commit --verbose`) because the index is re-read after the status has been written. This has the consequence of not displaying the actual changes made by the pre-commit hook, but committing them anyways. While it is often argued that the hook's purpose is not to automatically write content to the repository, it is acknowledged that using the pre-commit to apply mechanical fixes on top of the existing changes is a supported use case, along with verifying the content. I think not seeing these mechanical fixes before commiting is incorrect. A developer might expect the commit to look a certain way but if the pre-commit goes wrong the invalid changes will go unnoticed until committed. The comment suggesting that the cache must be reset after run_status and before the editor being launched was added in ec84bd00, (git-commit: Refactor creation of log message., 2008-02-05). It is unclear why the run_status must be called *after* the cache reset. However, calling run_status after the cache reset does not update the status line to state of the current index in the case a pre-commit hook is ran and changes files in the staging area. Signed-off-by: Samuel Yvon <samuelyvon9@gmail.com> Submitted-As: https://lore.kernel.org/git/pull.1127.v2.git.git.1636653331034.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.1127.git.git.1636423586620.gitgitgadget@gmail.com
Assets 2
-
2021-11-11T17:55:31Z -
2021-11-11T17:55:31Z -