]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'dd/t5403-modernise' into jch
authorJunio C Hamano <gitster@pobox.com>
Fri, 16 Jan 2026 23:45:56 +0000 (15:45 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Jan 2026 23:45:57 +0000 (15:45 -0800)
Test clean-up.

* dd/t5403-modernise:
  t5403: use test_cmp for post-checkout argument checks
  t5403: introduce check_post_checkout helper function

1  2 
t/t5403-post-checkout-hook.sh

index 1462e3365b95c2c9fa28323ac946cc1e7694bfa5,53d97df070ffc1c284cb961677b47869349971a7..cb0300b2d2b2f0fa0865609c5793638562b60bdc
@@@ -7,11 -7,23 +7,22 @@@ test_description='Test the post-checkou
  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 &&