The twelfth batch
[git/gitster.git] / t / t7606-merge-custom.sh
blob135cb2308565337afb25fbef9730972b7bac09f0
1 #!/bin/sh
3 test_description="git merge
5 Testing a custom strategy.
7 * (HEAD, main) Merge commit 'c3'
8 |\
9 | * (tag: c3) c3
10 * | (tag: c1) c1
12 | * tag: c2) c2
14 * (tag: c0) c0
17 TEST_PASSES_SANITIZE_LEAK=true
18 . ./test-lib.sh
20 test_expect_success 'set up custom strategy' '
21 cat >git-merge-theirs <<-EOF &&
22 #!$SHELL_PATH
23 eval git read-tree --reset -u \\\$\$#
24 EOF
26 chmod +x git-merge-theirs &&
27 PATH=.:$PATH &&
28 export PATH
31 test_expect_success 'setup' '
32 test_commit c0 c0.c &&
33 test_commit c1 c1.c &&
34 git reset --keep c0 &&
35 echo c1c1 >c1.c &&
36 git add c1.c &&
37 test_commit c2 c2.c &&
38 git reset --keep c0 &&
39 test_commit c3 c3.c
42 test_expect_success 'merge c2 with a custom strategy' '
43 git reset --hard c1 &&
45 git rev-parse c1 >head.old &&
46 git rev-parse c2 >second-parent.expected &&
47 git rev-parse c2^{tree} >tree.expected &&
48 git merge -s theirs c2 &&
50 git rev-parse HEAD >head.new &&
51 git rev-parse HEAD^1 >first-parent &&
52 git rev-parse HEAD^2 >second-parent &&
53 git rev-parse HEAD^{tree} >tree &&
54 git update-index --refresh &&
55 git diff --exit-code &&
56 git diff --exit-code c2 HEAD &&
57 git diff --exit-code c2 &&
59 ! test_cmp head.old head.new &&
60 test_cmp head.old first-parent &&
61 test_cmp second-parent.expected second-parent &&
62 test_cmp tree.expected tree &&
63 test -f c0.c &&
64 grep c1c1 c1.c &&
65 test -f c2.c
68 test_expect_success 'trivial merge with custom strategy' '
69 git reset --hard c1 &&
71 git rev-parse c1 >head.old &&
72 git rev-parse c3 >second-parent.expected &&
73 git rev-parse c3^{tree} >tree.expected &&
74 git merge -s theirs c3 &&
76 git rev-parse HEAD >head.new &&
77 git rev-parse HEAD^1 >first-parent &&
78 git rev-parse HEAD^2 >second-parent &&
79 git rev-parse HEAD^{tree} >tree &&
80 git update-index --refresh &&
81 git diff --exit-code &&
82 git diff --exit-code c3 HEAD &&
83 git diff --exit-code c3 &&
85 ! test_cmp head.old head.new &&
86 test_cmp head.old first-parent &&
87 test_cmp second-parent.expected second-parent &&
88 test_cmp tree.expected tree &&
89 test -f c0.c &&
90 ! test -e c1.c &&
91 test -f c3.c
94 test_done