receive-pack: support push-to-checkout hook
commit0855331941b723b227e93b33955bbe0b45025659
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Dec 2014 23:29:54 +0000 (1 15:29 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Jan 2015 22:28:43 +0000 (8 14:28 -0800)
tree70c84e087db0451e9b439c094c809b33fc268535
parent21b138d0f64d99b55e901f90d4211e036b881e64
receive-pack: support push-to-checkout hook

When receive.denyCurrentBranch is set to updateInstead, a push that
tries to update the branch that is currently checked out is accepted
only when the index and the working tree exactly matches the
currently checked out commit, in which case the index and the
working tree are updated to match the pushed commit.  Otherwise the
push is refused.

This hook can be used to customize this "push-to-deploy" logic.  The
hook receives the commit with which the tip of the current branch is
going to be updated, and can decide what kind of local changes are
acceptable and how to update the index and the working tree to match
the updated tip of the current branch.

For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
in order to emulate 'git fetch' that is run in the reverse direction
with `git push`, as the two-tree form of `read-tree -u -m` is
essentially the same as `git checkout` that switches branches while
keeping the local changes in the working tree that do not interfere
with the difference between the branches.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
Documentation/githooks.txt
builtin/receive-pack.c
t/t5516-fetch-push.sh