README: adjust for final Azure Pipeline ID
[git/raj.git] / t / t5403-post-checkout-hook.sh
bloba39b3b5c78bc900ae4e9c629598381f915d291de
1 #!/bin/sh
3 # Copyright (c) 2006 Josh England
6 test_description='Test the post-checkout hook.'
7 . ./test-lib.sh
9 test_expect_success setup '
10 mkdir -p .git/hooks &&
11 write_script .git/hooks/post-checkout <<-\EOF &&
12 echo "$@" >.git/post-checkout.args
13 EOF
14 test_commit one &&
15 test_commit two &&
16 test_commit rebase-on-me &&
17 git reset --hard HEAD^ &&
18 test_commit three
21 test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' '
22 test_when_finished "rm -f .git/post-checkout.args" &&
23 git checkout master &&
24 read old new flag <.git/post-checkout.args &&
25 test $old = $new && test $flag = 1
28 test_expect_success 'post-checkout args are correct with git checkout -b ' '
29 test_when_finished "rm -f .git/post-checkout.args" &&
30 git checkout -b new1 &&
31 read old new flag <.git/post-checkout.args &&
32 test $old = $new && test $flag = 1
35 test_expect_success 'post-checkout receives the right args with HEAD changed ' '
36 test_when_finished "rm -f .git/post-checkout.args" &&
37 git checkout two &&
38 read old new flag <.git/post-checkout.args &&
39 test $old != $new && test $flag = 1
42 test_expect_success 'post-checkout receives the right args when not switching branches ' '
43 test_when_finished "rm -f .git/post-checkout.args" &&
44 git checkout master -- three.t &&
45 read old new flag <.git/post-checkout.args &&
46 test $old = $new && test $flag = 0
49 test_expect_success 'post-checkout is triggered on rebase' '
50 test_when_finished "rm -f .git/post-checkout.args" &&
51 git checkout -b rebase-test master &&
52 rm -f .git/post-checkout.args &&
53 git rebase rebase-on-me &&
54 read old new flag <.git/post-checkout.args &&
55 test $old != $new && test $flag = 1
58 test_expect_success 'post-checkout is triggered on rebase with fast-forward' '
59 test_when_finished "rm -f .git/post-checkout.args" &&
60 git checkout -b ff-rebase-test rebase-on-me^ &&
61 rm -f .git/post-checkout.args &&
62 git rebase rebase-on-me &&
63 read old new flag <.git/post-checkout.args &&
64 test $old != $new && test $flag = 1
67 test_expect_success 'post-checkout hook is triggered by clone' '
68 mkdir -p templates/hooks &&
69 write_script templates/hooks/post-checkout <<-\EOF &&
70 echo "$@" >"$GIT_DIR/post-checkout.args"
71 EOF
72 git clone --template=templates . clone3 &&
73 test -f clone3/.git/post-checkout.args
76 test_done