]> Pileus Git - ~andy/git/commit
Teach receive-pack to run pre-receive/post-receive hooks
authorShawn O. Pearce <spearce@spearce.org>
Wed, 7 Mar 2007 21:52:05 +0000 (16:52 -0500)
committerJunio C Hamano <junkio@cox.net>
Wed, 7 Mar 2007 23:03:33 +0000 (15:03 -0800)
commit05ef58ec1f2fb69d6e7ae7fca84163f75bd95050
tree82e444216aef4ce945e8b5d6dac4b5adfedb4f39
parent8aaf7d6410119ee221f5d3ebdc4fc5a57f862665
Teach receive-pack to run pre-receive/post-receive hooks

Bill Lear pointed out that it is easy to send out notifications of
changes with the update hook, but successful execution of the update
hook does not necessarily mean that the ref was actually updated.
Lock contention on the ref or being unable to append to the reflog
may prevent the ref from being changed.  Sending out notifications
prior to the ref actually changing is very misleading.

To help this situation I am introducing two new hooks to the
receive-pack flow: pre-receive and post-receive.  These new hooks
are invoked only once per receive-pack execution and are passed
three arguments per ref (refname, old-sha1, new-sha1).

The new post-receive hook is ideal for sending out notifications,
as it has the complete list of all refnames that were successfully
updated as well as the old and new SHA-1 values.  This allows more
interesting notifications to be sent.  Multiple ref updates could
be easily summarized into one email, for example.

The new pre-receive hook is ideal for logging update attempts, as it
is run only once for the entire receive-pack operation.  It can also
be used to verify multiple updates happen at once, e.g. an update
to the `maint` head must also be accompained by a new annotated tag.

Lots of documentation improvements for receive-pack are included
in this change, as we want to make sure the new hooks are clearly
explained.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-receive-pack.txt
receive-pack.c
t/t5401-update-hooks.sh