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
'pull.rebase not set' '
31 git reset --hard c0 &&
32 git pull . c1 2>err &&
33 test_i18ngrep "Pulling without specifying how to reconcile" err
36 test_expect_success
'pull.rebase not set and pull.ff=false' '
37 git reset --hard c0 &&
38 test_config pull.ff false &&
39 git pull . c1 2>err &&
40 test_i18ngrep "Pulling without specifying how to reconcile" err
43 test_expect_success
'pull.rebase not set and pull.ff=only' '
44 git reset --hard c0 &&
45 test_config pull.ff only &&
46 git pull . c1 2>err &&
47 test_i18ngrep ! "Pulling without specifying how to reconcile" err
50 test_expect_success
'pull.rebase not set and --rebase given' '
51 git reset --hard c0 &&
52 git pull --rebase . c1 2>err &&
53 test_i18ngrep ! "Pulling without specifying how to reconcile" err
56 test_expect_success
'pull.rebase not set and --no-rebase given' '
57 git reset --hard c0 &&
58 git pull --no-rebase . c1 2>err &&
59 test_i18ngrep ! "Pulling without specifying how to reconcile" err
62 test_expect_success
'pull.rebase not set and --ff-only given' '
63 git reset --hard c0 &&
64 git pull --ff-only . c1 2>err &&
65 test_i18ngrep ! "Pulling without specifying how to reconcile" err
68 test_expect_success
'merge c1 with c2' '
69 git reset --hard c1 &&
79 test_expect_success
'fast-forward pull succeeds with "true" in pull.ff' '
80 git reset --hard c0 &&
81 test_config pull.ff true &&
83 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
86 test_expect_success
'pull.ff=true overrides merge.ff=false' '
87 git reset --hard c0 &&
88 test_config merge.ff false &&
89 test_config pull.ff true &&
91 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
94 test_expect_success
'fast-forward pull creates merge with "false" in pull.ff' '
95 git reset --hard c0 &&
96 test_config pull.ff false &&
98 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
99 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
102 test_expect_success
'pull prevents non-fast-forward with "only" in pull.ff' '
103 git reset --hard c1 &&
104 test_config pull.ff only &&
105 test_must_fail git pull . c3
108 test_expect_success
'merge c1 with c2 (ours in pull.twohead)' '
109 git reset --hard c1 &&
110 git config pull.twohead ours &&
116 test_expect_success
'merge c1 with c2 and c3 (recursive in pull.octopus)' '
117 git reset --hard c1 &&
118 git config pull.octopus "recursive" &&
119 test_must_fail git merge c2 c3 &&
120 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
123 test_expect_success
'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
124 git reset --hard c1 &&
125 git config pull.octopus "recursive octopus" &&
127 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
128 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
129 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
130 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
131 git diff --exit-code &&
141 git diff-files
--name-only
142 git ls-files
--unmerged
149 # There are two conflicts here:
151 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
154 # 2) One in conflict.c and that will always fail.
156 test_expect_success
'setup conflicted merge' '
157 git reset --hard c0 &&
158 echo A >conflict.c &&
159 git add conflict.c &&
160 echo contents >foo.c &&
164 echo B >conflict.c &&
165 git add conflict.c &&
166 git mv foo.c bar.c &&
169 git reset --hard c4 &&
170 echo C >conflict.c &&
171 git add conflict.c &&
172 echo secondline >> foo.c &&
178 # First do the merge with resolve and recursive then verify that
179 # recursive is chosen.
181 test_expect_success
'merge picks up the best result' '
182 git config --unset-all pull.twohead &&
183 git reset --hard c5 &&
184 test_must_fail git merge -s resolve c6 &&
185 resolve_count=$(conflict_count) &&
186 git reset --hard c5 &&
187 test_must_fail git merge -s recursive c6 &&
188 recursive_count=$(conflict_count) &&
189 git reset --hard c5 &&
190 test_must_fail git merge -s recursive -s resolve c6 &&
191 auto_count=$(conflict_count) &&
192 test $auto_count = $recursive_count &&
193 test $auto_count != $resolve_count
196 test_expect_success
'merge picks up the best result (from config)' '
197 git config pull.twohead "recursive resolve" &&
198 git reset --hard c5 &&
199 test_must_fail git merge -s resolve c6 &&
200 resolve_count=$(conflict_count) &&
201 git reset --hard c5 &&
202 test_must_fail git merge -s recursive c6 &&
203 recursive_count=$(conflict_count) &&
204 git reset --hard c5 &&
205 test_must_fail git merge c6 &&
206 auto_count=$(conflict_count) &&
207 test $auto_count = $recursive_count &&
208 test $auto_count != $resolve_count
211 test_expect_success
'merge errors out on invalid strategy' '
212 git config pull.twohead "foobar" &&
213 git reset --hard c5 &&
214 test_must_fail git merge c6
217 test_expect_success
'merge errors out on invalid strategy' '
218 git config --unset-all pull.twohead &&
219 git reset --hard c5 &&
220 test_must_fail git merge -s "resolve recursive" c6