aboutsummaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-01-23 21:19:25 -0800
committerJunio C Hamano <gitster@pobox.com>2013-01-23 21:19:25 -0800
commitbb9a69694f27aa299777c679979f75bdef75735d (patch)
treef00e9f412cd91c4f2b5aa355d68bc0b501ff8ee3 /Documentation
parent86db7464496ca82488071c7a9e7e57eff07cd900 (diff)
parent87c86dd14abe8db7d00b0df5661ef8cf147a72a3 (diff)
downloadgit-bb9a69694f27aa299777c679979f75bdef75735d.tar.gz
git-bb9a69694f27aa299777c679979f75bdef75735d.tar.xz
Merge branch 'as/pre-push-hook'
Add an extra hook so that "git push" that is run without making sure what is being pushed is sane can be checked and rejected (as opposed to the user deciding not pushing). * as/pre-push-hook: Add sample pre-push hook script push: Add support for pre-push hooks hooks: Add function to check if a hook exists
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/githooks.txt29
1 files changed, 29 insertions, 0 deletions
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index b9003fed2..d839233df 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -176,6 +176,35 @@ save and restore any form of metadata associated with the working tree
(eg: permissions/ownership, ACLS, etc). See contrib/hooks/setgitperms.perl
for an example of how to do this.
+pre-push
+~~~~~~~~
+
+This hook is called by 'git push' and can be used to prevent a push from taking
+place. The hook is called with two parameters which provide the name and
+location of the destination remote, if a named remote is not being used both
+values will be the same.
+
+Information about what is to be pushed is provided on the hook's standard
+input with lines of the form:
+
+ <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
+
+For instance, if the command +git push origin master:foreign+ were run the
+hook would receive a line like the following:
+
+ refs/heads/master 67890 refs/heads/foreign 12345
+
+although the full, 40-character SHA1s would be supplied. If the foreign ref
+does not yet exist the `<remote SHA1>` will be 40 `0`. If a ref is to be
+deleted, the `<local ref>` will be supplied as `(delete)` and the `<local
+SHA1>` will be 40 `0`. If the local commit was specified by something other
+than a name which could be expanded (such as `HEAD~`, or a SHA1) it will be
+supplied as it was originally given.
+
+If this hook exits with a non-zero status, 'git push' will abort without
+pushing anything. Information about why the push is rejected may be sent
+to the user by writing to standard error.
+
[[pre-receive]]
pre-receive
~~~~~~~~~~~