#!/bin/sh test_description='check pre-push hooks' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh # Setup hook that always succeeds HOOKDIR="$(git rev-parse --git-dir)/hooks" HOOK="$HOOKDIR/pre-push" mkdir -p "$HOOKDIR" write_script "$HOOK" </dev/null exit 0 EOF test_expect_success 'setup' ' git config push.default upstream && git init --bare repo1 && git remote add parent1 repo1 && test_commit one && git push parent1 HEAD:foreign ' write_script "$HOOK" </dev/null exit 1 EOF COMMIT1="$(git rev-parse HEAD)" export COMMIT1 test_expect_success 'push with failing hook' ' test_commit two && test_must_fail git push parent1 HEAD ' test_expect_success '--no-verify bypasses hook' ' git push --no-verify parent1 HEAD ' COMMIT2="$(git rev-parse HEAD)" export COMMIT2 write_script "$HOOK" <<'EOF' echo "$1" >actual echo "$2" >>actual cat >>actual EOF cat >expected <expected <expected <expected <expected <