Skip to content
  • Shawn O. Pearce's avatar
    Teach receive-pack to run pre-receive/post-receive hooks · 05ef58ec
    Shawn O. Pearce authored
    
    
    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: default avatarShawn O. Pearce <spearce@spearce.org>
    Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
    05ef58ec