GIT 1.6.2.2
[git/mjg.git] / t / t5402-post-merge-hook.sh
blob6eb2ffd6ecabb9125d06e76a17d0821d7e907dfd
1 #!/bin/sh
3 # Copyright (c) 2006 Josh England
6 test_description='Test the post-merge hook.'
7 . ./test-lib.sh
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 &&
15 git update-index 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
25 for clone in 1 2; do
26 cat >clone${clone}/.git/hooks/post-merge <<'EOF'
27 #!/bin/sh
28 echo $@ >> $GIT_DIR/post-merge.args
29 EOF
30 chmod u+x clone${clone}/.git/hooks/post-merge
31 done
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
56 test_done