t7606 (merge-theirs): modernize style
[git/jnareb-git.git] / t / t7606-merge-custom.sh
blob82045cd543e7e62cd1dc0fa3c38d7d5212f32090
1 #!/bin/sh
3 test_description="git merge
5 Testing a custom strategy.
7 * (HEAD, master) Merge commit 'c2'
8 |\
9 | * (tag: c2) c2
10 * | (tag: c1) c1
12 * (tag: c0) c0
15 . ./test-lib.sh
17 test_expect_success 'set up custom strategy' '
18 cat >git-merge-theirs <<-EOF &&
19 #!$SHELL_PATH
20 eval git read-tree --reset -u \\\$\$#
21 EOF
23 chmod +x git-merge-theirs &&
24 PATH=.:$PATH &&
25 export PATH
28 test_expect_success 'setup' '
29 test_commit c0 c0.c &&
30 test_commit c1 c1.c &&
31 git reset --keep c0 &&
32 echo c1c1 >c1.c &&
33 git add c1.c &&
34 test_commit c2 c2.c
37 test_expect_success 'merge c2 with a custom strategy' '
38 git reset --hard c1 &&
40 git rev-parse c1 >head.old &&
41 git rev-parse c2 >second-parent.expected &&
42 git rev-parse c2^{tree} >tree.expected &&
43 git merge -s theirs c2 &&
45 git rev-parse HEAD >head &&
46 git rev-parse HEAD^1 >first-parent &&
47 git rev-parse HEAD^2 >second-parent &&
48 git rev-parse HEAD^{tree} >tree &&
49 git update-index --refresh &&
50 git diff --exit-code &&
51 git diff --exit-code c2 HEAD &&
52 git diff --exit-code c2 &&
54 ! test_cmp head.old head &&
55 test_cmp head.old first-parent &&
56 test_cmp second-parent.expected second-parent &&
57 test_cmp tree.expected tree &&
58 test -f c0.c &&
59 grep c1c1 c1.c &&
60 test -f c2.c
63 test_done