3 # Copyright (c) 2006 Josh England
6 test_description
='Test the post-merge hook.'
9 test_expect_success setup
'
10 echo Data for commit0. >a &&
11 git update-index --add a &&
12 tree0=$(git write-tree) &&
13 commit0=$(echo setup | git commit-tree $tree0) &&
14 echo Changed data for commit1. >a &&
16 tree1=$(git write-tree) &&
17 commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
18 git update-ref refs/heads/master $commit0 &&
19 git clone ./. clone1 &&
20 GIT_DIR=clone1/.git git update-index --add a &&
21 git clone ./. clone2 &&
22 GIT_DIR=clone2/.git git update-index --add a
26 cat >clone
${clone}/.git
/hooks
/post-merge
<<'EOF'
28 echo $@ >> $GIT_DIR/post-merge.args
30 chmod u
+x clone
${clone}/.git
/hooks
/post-merge
33 test_expect_success
'post-merge does not run for up-to-date ' '
34 GIT_DIR=clone1/.git git merge $commit0 &&
35 ! test -f clone1/.git/post-merge.args
38 test_expect_success
'post-merge runs as expected ' '
39 GIT_DIR=clone1/.git git merge $commit1 &&
40 test -e clone1/.git/post-merge.args
43 test_expect_success
'post-merge from normal merge receives the right argument ' '
44 grep 0 clone1/.git/post-merge.args
47 test_expect_success
'post-merge from squash merge runs as expected ' '
48 GIT_DIR=clone2/.git git merge --squash $commit1 &&
49 test -e clone2/.git/post-merge.args
52 test_expect_success
'post-merge from squash merge receives the right argument ' '
53 grep 1 clone2/.git/post-merge.args