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: Arsen Arsenović
Subject: Re: New Git hooks for checking file names in commit messages
Date: Fri, 21 Apr 2023 17:38:19 +0200

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Fri, 21 Apr 2023 13:57:22 +0000
>> Cc: emacs-devel@gnu.org
>> From: Alan Mackenzie <acm@muc.de>
>> 
>> > There's one part that might be surprising, at least initially though:
>> > while this is a hook to check commit messages, it actually runs in the
>> > post-commit and pre-push phases. This is because we want to examine
>> > the full diff of the commit in order to compare against the file
>> > entries in the message.[1] As a result, you'll just get an advisory
>> > message when you make the commit (it's too late to error out), and the
>> > pre-push hook will prevent you from pushing a badly-formatted commit
>> > message upstream.
>> 
>> 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.  And preventing
>> people from pushing these erroneous commits is, again, not helpful.
>
> It is still helpful, because as long as you didn't push, you can still
> do
>
>    $ git reset HEAD^

You can also reword during a rebase, which has the advantage of not
chucking any work away.  See [1].

Everything can be changed at any point in Git, until you push, and even
then if the server agrees, so there's never a time that is too late to
error out.

Have a great day.

[1] https://git-scm.com/docs/git-rebase#_interactive_mode
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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