read-tree: narrow scope of index expansion for '--prefix'
[alt-git.git] / t / t5402-post-merge-hook.sh
blob3e5e19c719170112fa77f924c0b9a6828eea2f6c
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-lib.sh
12 test_expect_success setup '
13 echo Data for commit0. >a &&
14 git update-index --add a &&
15 tree0=$(git write-tree) &&
16 commit0=$(echo setup | git commit-tree $tree0) &&
17 echo Changed data for commit1. >a &&
18 git update-index a &&
19 tree1=$(git write-tree) &&
20 commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
21 git update-ref refs/heads/main $commit0 &&
22 git clone ./. clone1 &&
23 GIT_DIR=clone1/.git git update-index --add a &&
24 git clone ./. clone2 &&
25 GIT_DIR=clone2/.git git update-index --add a
28 for clone in 1 2; do
29 cat >clone${clone}/.git/hooks/post-merge <<'EOF'
30 #!/bin/sh
31 echo $@ >> $GIT_DIR/post-merge.args
32 EOF
33 chmod u+x clone${clone}/.git/hooks/post-merge
34 done
36 test_expect_success 'post-merge does not run for up-to-date ' '
37 GIT_DIR=clone1/.git git merge $commit0 &&
38 ! test -f clone1/.git/post-merge.args
41 test_expect_success 'post-merge runs as expected ' '
42 GIT_DIR=clone1/.git git merge $commit1 &&
43 test -e clone1/.git/post-merge.args
46 test_expect_success 'post-merge from normal merge receives the right argument ' '
47 grep 0 clone1/.git/post-merge.args
50 test_expect_success 'post-merge from squash merge runs as expected ' '
51 GIT_DIR=clone2/.git git merge --squash $commit1 &&
52 test -e clone2/.git/post-merge.args
55 test_expect_success 'post-merge from squash merge receives the right argument ' '
56 grep 1 clone2/.git/post-merge.args
59 test_done