#!/bin/sh test_description='check pre-push hooks' . ./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 <expected nr=1000 while test $nr -lt 2000 do nr=$(( $nr + 1 )) git branch b/$nr $COMMIT3 echo "refs/heads/b/$nr $COMMIT3 refs/heads/b/$nr $_z40" >>expected done test_expect_success 'push many refs' ' git push parent1 "refs/heads/b/*:refs/heads/b/*" && diff expected actual ' fi test_done