Re: [PATCH] git-commit: add a prepare-commit-msg hook

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Paolo Bonzini <bonzini@...>
Cc: Git Mailing List <git@...>
Date: Friday, January 18, 2008 - 6:05 pm

I do not particularly like hooks that act before or after an
operation is initiated locally, act solely on local data.  This
is maybe because I still consider git tools building blocks
suitable for higher level scripting more than other people do.

There are five valid reasons you might want a hook to a git
operation:

 (1) A hook that countermands the normal decision made by the
     underlying command.  Examples of this class are the update
     hook and the pre-commit hook.

 (2) A hook that operates on data generated after the command
     starts to run.  The ability to munge the commit log message
     by the commit-msg hook is an example.

 (3) A hook that operates on the remote end of the connection
     that you may not otherwise have access to other than over
     the git protocol.  An example is the post-update hook.

 (4) A hook that runs under a lock that is acquired by the
     command for mutual exclusion.  Currently there is no
     example, but if we allowed the update hook to modify the
     commit that was pushed through send-pack => receive-pack
     pair, which was discussed on the list a while ago, it would
     be a good example of this.

 (5) A hook that is run differently depending on the outcome of
     the command.  The post-merge hook conditionally run by
     git-pull is an example of this (it is not even run if no
     merge takes place).  Another example is the post-checkout
     hook that gets information that is otherwise harder to get
     (namely, if it was a branch checkout or file checkout --
     you can figure it out by examining the command line but
     that already is part of the processing git-checkout does
     anyway, so no need to force duplicating that code in the
     userland).

You cannot do an equivalent operation from outside the git
command for the above classes of operations.  You need hooks
for them.

On the other hand, if you want to always cause an action before
running a git opeation locally, you do not have to have a hook.
You can just prepare such a message based on GNU ChangeLog and
then run git-commit with -F, both inside your wrapper.

Of course there can be a very valid exception to the above
policy.  If it is common enough so that the policy means
effectively everybody has to reinvent the same wrapper.  But for
this particular case I still do not see that is the case.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 10:51 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Junio C Hamano, (Fri Jan 18, 6:05 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Sat Jan 19, 5:32 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Sat Jan 19, 7:20 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Sat Jan 19, 12:04 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Benoit Sigoure, (Sat Jan 19, 11:41 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Alex Riesen, (Fri Jan 18, 3:05 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 3:46 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Alex Riesen, (Fri Jan 18, 5:08 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 11:47 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 11:51 am)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 12:06 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 12:37 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Johannes Schindelin, (Fri Jan 18, 2:06 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Benoit Sigoure, (Fri Jan 18, 3:01 pm)
Re: [PATCH] git-commit: add a prepare-commit-msg hook, Paolo Bonzini, (Fri Jan 18, 2:51 pm)