Merge branch 'rj/add-i-leak-fix'
[git.git] / t / t5402-post-merge-hook.sh
blob46ebdfbeebaf522281e8e4aa4c68e9fb33ca8513
1 #!/bin/sh
3 # Copyright (c) 2006 Josh England
6 test_description='Test the post-merge hook.'
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
13 test_expect_success setup '
14 echo Data for commit0. >a &&
15 git update-index --add a &&
16 tree0=$(git write-tree) &&
17 commit0=$(echo setup | git commit-tree $tree0) &&
18 echo Changed data for commit1. >a &&
19 git update-index a &&
20 tree1=$(git write-tree) &&
21 commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
22 git update-ref refs/heads/main $commit0 &&
23 git clone ./. clone1 &&
24 GIT_DIR=clone1/.git git update-index --add a &&
25 git clone ./. clone2 &&
26 GIT_DIR=clone2/.git git update-index --add a
29 test_expect_success 'setup clone hooks' '
30 test_when_finished "rm -f hook" &&
31 cat >hook <<-\EOF &&
32 echo $@ >>$GIT_DIR/post-merge.args
33 EOF
35 test_hook --setup -C clone1 post-merge <hook &&
36 test_hook --setup -C clone2 post-merge <hook
39 test_expect_success 'post-merge does not run for up-to-date ' '
40 GIT_DIR=clone1/.git git merge $commit0 &&
41 ! test -f clone1/.git/post-merge.args
44 test_expect_success 'post-merge runs as expected ' '
45 GIT_DIR=clone1/.git git merge $commit1 &&
46 test -e clone1/.git/post-merge.args
49 test_expect_success 'post-merge from normal merge receives the right argument ' '
50 grep 0 clone1/.git/post-merge.args
53 test_expect_success 'post-merge from squash merge runs as expected ' '
54 GIT_DIR=clone2/.git git merge --squash $commit1 &&
55 test -e clone2/.git/post-merge.args
58 test_expect_success 'post-merge from squash merge receives the right argument ' '
59 grep 1 clone2/.git/post-merge.args
62 test_done