3 test_description
='git merge
5 Testing pull.* configuration parsing.'
9 test_expect_success
'setup' '
18 git reset --hard c0 &&
23 git reset --hard c0 &&
30 test_expect_success
'merge c1 with c2' '
31 git reset --hard c1 &&
41 test_expect_success
'fast-forward pull succeeds with "true" in pull.ff' '
42 git reset --hard c0 &&
43 test_config pull.ff true &&
45 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
48 test_expect_success
'fast-forward pull creates merge with "false" in pull.ff' '
49 git reset --hard c0 &&
50 test_config pull.ff false &&
52 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
53 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
56 test_expect_success
'pull prevents non-fast-forward with "only" in pull.ff' '
57 git reset --hard c1 &&
58 test_config pull.ff only &&
59 test_must_fail git pull . c3
62 test_expect_success
'merge c1 with c2 (ours in pull.twohead)' '
63 git reset --hard c1 &&
64 git config pull.twohead ours &&
70 test_expect_success
'merge c1 with c2 and c3 (recursive in pull.octopus)' '
71 git reset --hard c1 &&
72 git config pull.octopus "recursive" &&
73 test_must_fail git merge c2 c3 &&
74 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
77 test_expect_success
'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
78 git reset --hard c1 &&
79 git config pull.octopus "recursive octopus" &&
81 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
82 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
83 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
84 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
85 git diff --exit-code &&
95 git diff-files
--name-only
96 git ls-files
--unmerged
103 # There are two conflicts here:
105 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
108 # 2) One in conflict.c and that will always fail.
110 test_expect_success
'setup conflicted merge' '
111 git reset --hard c0 &&
112 echo A >conflict.c &&
113 git add conflict.c &&
114 echo contents >foo.c &&
118 echo B >conflict.c &&
119 git add conflict.c &&
120 git mv foo.c bar.c &&
123 git reset --hard c4 &&
124 echo C >conflict.c &&
125 git add conflict.c &&
126 echo secondline >> foo.c &&
132 # First do the merge with resolve and recursive then verify that
133 # recursive is chosen.
135 test_expect_success
'merge picks up the best result' '
136 git config --unset-all pull.twohead &&
137 git reset --hard c5 &&
138 test_must_fail git merge -s resolve c6 &&
139 resolve_count=$(conflict_count) &&
140 git reset --hard c5 &&
141 test_must_fail git merge -s recursive c6 &&
142 recursive_count=$(conflict_count) &&
143 git reset --hard c5 &&
144 test_must_fail git merge -s recursive -s resolve c6 &&
145 auto_count=$(conflict_count) &&
146 test $auto_count = $recursive_count &&
147 test $auto_count != $resolve_count
150 test_expect_success
'merge picks up the best result (from config)' '
151 git config pull.twohead "recursive resolve" &&
152 git reset --hard c5 &&
153 test_must_fail git merge -s resolve c6 &&
154 resolve_count=$(conflict_count) &&
155 git reset --hard c5 &&
156 test_must_fail git merge -s recursive c6 &&
157 recursive_count=$(conflict_count) &&
158 git reset --hard c5 &&
159 test_must_fail git merge c6 &&
160 auto_count=$(conflict_count) &&
161 test $auto_count = $recursive_count &&
162 test $auto_count != $resolve_count
165 test_expect_success
'merge errors out on invalid strategy' '
166 git config pull.twohead "foobar" &&
167 git reset --hard c5 &&
168 test_must_fail git merge c6
171 test_expect_success
'merge errors out on invalid strategy' '
172 git config --unset-all pull.twohead &&
173 git reset --hard c5 &&
174 test_must_fail git merge -s "resolve recursive" c6