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=true' '
37 git reset --hard c0 &&
38 test_config pull.ff true &&
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=false' '
44 git reset --hard c0 &&
45 test_config pull.ff false &&
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 pull.ff=only' '
51 git reset --hard c0 &&
52 test_config pull.ff only &&
53 git pull . c1 2>err &&
54 test_i18ngrep ! "Pulling without specifying how to reconcile" err
57 test_expect_success 'pull.rebase not set and --rebase given' '
58 git reset --hard c0 &&
59 git pull --rebase . c1 2>err &&
60 test_i18ngrep ! "Pulling without specifying how to reconcile" err
63 test_expect_success 'pull.rebase not set and --no-rebase given' '
64 git reset --hard c0 &&
65 git pull --no-rebase . c1 2>err &&
66 test_i18ngrep ! "Pulling without specifying how to reconcile" err
69 test_expect_success 'pull.rebase not set and --ff given' '
70 git reset --hard c0 &&
71 git pull --ff . c1 2>err &&
72 test_i18ngrep ! "Pulling without specifying how to reconcile" err
75 test_expect_success 'pull.rebase not set and --no-ff given' '
76 git reset --hard c0 &&
77 git pull --no-ff . c1 2>err &&
78 test_i18ngrep ! "Pulling without specifying how to reconcile" err
81 test_expect_success 'pull.rebase not set and --ff-only given' '
82 git reset --hard c0 &&
83 git pull --ff-only . c1 2>err &&
84 test_i18ngrep ! "Pulling without specifying how to reconcile" err
87 test_expect_success 'merge c1 with c2' '
88 git reset --hard c1 &&
98 test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
99 git reset --hard c0 &&
100 test_config pull.ff true &&
102 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
105 test_expect_success 'pull.ff=true overrides merge.ff=false' '
106 git reset --hard c0 &&
107 test_config merge.ff false &&
108 test_config pull.ff true &&
110 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
113 test_expect_success 'fast-forward pull creates merge with "false" in pull.ff' '
114 git reset --hard c0 &&
115 test_config pull.ff false &&
117 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
118 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
121 test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
122 git reset --hard c1 &&
123 test_config pull.ff only &&
124 test_must_fail git pull . c3
127 test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
128 git reset --hard c1 &&
129 git config pull.twohead ours &&
135 test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
136 git reset --hard c1 &&
137 git config pull.octopus "recursive" &&
138 test_must_fail git merge c2 c3 &&
139 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
142 test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
143 git reset --hard c1 &&
144 git config pull.octopus "recursive octopus" &&
146 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
147 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
148 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
149 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
150 git diff --exit-code &&
160 git diff-files --name-only
161 git ls-files --unmerged
168 # There are two conflicts here:
170 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
173 # 2) One in conflict.c and that will always fail.
175 test_expect_success 'setup conflicted merge' '
176 git reset --hard c0 &&
177 echo A >conflict.c &&
178 git add conflict.c &&
179 echo contents >foo.c &&
183 echo B >conflict.c &&
184 git add conflict.c &&
185 git mv foo.c bar.c &&
188 git reset --hard c4 &&
189 echo C >conflict.c &&
190 git add conflict.c &&
191 echo secondline >> foo.c &&
197 # First do the merge with resolve and recursive then verify that
198 # recursive is chosen.
200 test_expect_success 'merge picks up the best result' '
201 git config --unset-all pull.twohead &&
202 git reset --hard c5 &&
203 test_must_fail git merge -s resolve c6 &&
204 resolve_count=$(conflict_count) &&
205 git reset --hard c5 &&
206 test_must_fail git merge -s recursive c6 &&
207 recursive_count=$(conflict_count) &&
208 git reset --hard c5 &&
209 test_must_fail git merge -s recursive -s resolve c6 &&
210 auto_count=$(conflict_count) &&
211 test $auto_count = $recursive_count &&
212 test $auto_count != $resolve_count
215 test_expect_success 'merge picks up the best result (from config)' '
216 git config pull.twohead "recursive resolve" &&
217 git reset --hard c5 &&
218 test_must_fail git merge -s resolve c6 &&
219 resolve_count=$(conflict_count) &&
220 git reset --hard c5 &&
221 test_must_fail git merge -s recursive c6 &&
222 recursive_count=$(conflict_count) &&
223 git reset --hard c5 &&
224 test_must_fail git merge c6 &&
225 auto_count=$(conflict_count) &&
226 test $auto_count = $recursive_count &&
227 test $auto_count != $resolve_count
230 test_expect_success 'merge errors out on invalid strategy' '
231 git config pull.twohead "foobar" &&
232 git reset --hard c5 &&
233 test_must_fail git merge c6
236 test_expect_success 'merge errors out on invalid strategy' '
237 git config --unset-all pull.twohead &&
238 git reset --hard c5 &&
239 test_must_fail git merge -s "resolve recursive" c6