Chris@14: #!/bin/sh Chris@14: Chris@14: # An example hook script to verify what is about to be pushed. Called by "git Chris@14: # push" after it has checked the remote status, but before anything has been Chris@14: # pushed. If this script exits with a non-zero status nothing will be pushed. Chris@14: # Chris@14: # This hook is called with the following parameters: Chris@14: # Chris@14: # $1 -- Name of the remote to which the push is being done Chris@14: # $2 -- URL to which the push is being done Chris@14: # Chris@14: # If pushing without using a named remote those arguments will be equal. Chris@14: # Chris@14: # Information about the commits which are being pushed is supplied as lines to Chris@14: # the standard input in the form: Chris@14: # Chris@14: # Chris@14: # Chris@14: # This sample shows how to prevent push of commits where the log message starts Chris@14: # with "WIP" (work in progress). Chris@14: Chris@14: remote="$1" Chris@14: url="$2" Chris@14: Chris@14: z40=0000000000000000000000000000000000000000 Chris@14: Chris@14: while read local_ref local_sha remote_ref remote_sha Chris@14: do Chris@14: if [ "$local_sha" = $z40 ] Chris@14: then Chris@14: # Handle delete Chris@14: : Chris@14: else Chris@14: if [ "$remote_sha" = $z40 ] Chris@14: then Chris@14: # New branch, examine all commits Chris@14: range="$local_sha" Chris@14: else Chris@14: # Update to existing branch, examine new commits Chris@14: range="$remote_sha..$local_sha" Chris@14: fi Chris@14: Chris@14: # Check for WIP commit Chris@14: commit=`git rev-list -n 1 --grep '^WIP' "$range"` Chris@14: if [ -n "$commit" ] Chris@14: then Chris@14: echo >&2 "Found WIP commit in $local_ref, not pushing" Chris@14: exit 1 Chris@14: fi Chris@14: fi Chris@14: done Chris@14: Chris@14: exit 0