emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Git hooks for checking file names in commit messages


From: Jim Porter
Subject: Re: New Git hooks for checking file names in commit messages
Date: Fri, 21 Apr 2023 09:39:57 -0700

On 4/21/2023 6:57 AM, Alan Mackenzie wrote:
How is this helpful?  Telling somebody they've made a mistake is only
helpful if they can correct it.  If "it's too late to error out", it
will just create annoyance.  Immediately after such a commit it is
possible to use $ git commit --amend, but not later.

This is why I added a post-commit hook that informs the committer of the problem immediately after committing. However, since this is a *post*-commit hook, it's too late to abort the commit. So there is a message, but it's purely advisory at that stage. Sorry if my wording was unclear originally.

[1] It's hard to do this during the commit-msg hook since there's no
cross-platform way I know of to handle amending commits properly.

I don't understand this bit.  Why does the lack of a way of amending
commits make it difficult to error out from the commit-msg hook?  What
am I missing?

It's impossible (as far as I'm aware) to reliably get a list of changed files from Git during the commit-msg hook. Since you can't tell whether the commit is being amended without platform-specific hacks, you have no way of knowing whether you should compute your diff against HEAD or HEAD^.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]