From: Junio C Hamano <gitster@pobox.com>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] git-commit: add a prepare-commit-msg hook
Date: Fri, 18 Jan 2008 14:05:46 -0800 [thread overview]
Message-ID: <7vbq7ibxhh.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <4790BCED.4050207@gnu.org> (Paolo Bonzini's message of "Fri, 18 Jan 2008 15:51:25 +0100")
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.
next prev parent reply other threads:[~2008-01-18 22:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-18 14:51 [PATCH] git-commit: add a prepare-commit-msg hook Paolo Bonzini
2008-01-18 15:47 ` Johannes Schindelin
2008-01-18 15:51 ` Paolo Bonzini
2008-01-18 16:06 ` Johannes Schindelin
2008-01-18 16:37 ` Paolo Bonzini
2008-01-18 18:06 ` Johannes Schindelin
2008-01-18 18:51 ` Paolo Bonzini
2008-01-18 19:01 ` Benoit Sigoure
2008-01-18 19:05 ` Alex Riesen
2008-01-18 19:46 ` Paolo Bonzini
2008-01-18 21:08 ` Alex Riesen
2008-01-18 22:05 ` Junio C Hamano [this message]
2008-01-19 9:32 ` Paolo Bonzini
2008-01-19 11:20 ` Johannes Schindelin
2008-01-19 15:41 ` Benoit Sigoure
2008-01-19 16:04 ` Paolo Bonzini
2008-01-20 22:28 ` Junio C Hamano
2008-01-21 6:16 ` Paolo Bonzini
2008-01-21 11:04 ` Johannes Schindelin
2008-01-21 12:14 ` Paolo Bonzini
2008-01-21 12:46 ` Johannes Schindelin
2008-01-21 12:59 ` Paolo Bonzini
2008-01-21 22:44 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2008-01-21 14:27 Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vbq7ibxhh.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=bonzini@gnu.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).