GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+ # Usage: check_post_checkout <file> <old-ref> <new-ref> <flag>
+ #
+ # Verify that the post-checkout hook arguments in <file> match the expected
+ # values: <old-ref> for the previous HEAD, <new-ref> for the new HEAD, and
+ # <flag> indicating whether this was a branch checkout (1) or file checkout (0).
+ check_post_checkout () {
+ test "$#" = 4 || BUG "check_post_checkout takes 4 args"
+ echo "old=$2 new=$3 flag=$4" >expect &&
+ test_cmp expect "$1"
+ }
+
test_expect_success setup '
test_hook --setup post-checkout <<-\EOF &&
- echo "$@" >.git/post-checkout.args
+ echo "old=$1 new=$2 flag=$3" >.git/post-checkout.args
EOF
test_commit one &&
test_commit two &&