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 -c color.advice=always pull . c1 2>err &&
33 test_decode_color <err >decoded &&
34 test_i18ngrep "<YELLOW>hint: " decoded &&
35 test_i18ngrep "Pulling without specifying how to reconcile" decoded
39 test_expect_success 'pull.rebase not set and pull.ff=true' '
40 git reset --hard c0 &&
41 test_config pull.ff true &&
42 git pull . c1 2>err &&
43 test_i18ngrep ! "Pulling without specifying how to reconcile" err
46 test_expect_success 'pull.rebase not set and pull.ff=false' '
47 git reset --hard c0 &&
48 test_config pull.ff false &&
49 git pull . c1 2>err &&
50 test_i18ngrep ! "Pulling without specifying how to reconcile" err
53 test_expect_success 'pull.rebase not set and pull.ff=only' '
54 git reset --hard c0 &&
55 test_config pull.ff only &&
56 git pull . c1 2>err &&
57 test_i18ngrep ! "Pulling without specifying how to reconcile" err
60 test_expect_success 'pull.rebase not set and --rebase given' '
61 git reset --hard c0 &&
62 git pull --rebase . c1 2>err &&
63 test_i18ngrep ! "Pulling without specifying how to reconcile" err
66 test_expect_success 'pull.rebase not set and --no-rebase given' '
67 git reset --hard c0 &&
68 git pull --no-rebase . c1 2>err &&
69 test_i18ngrep ! "Pulling without specifying how to reconcile" err
72 test_expect_success 'pull.rebase not set and --ff given' '
73 git reset --hard c0 &&
74 git pull --ff . c1 2>err &&
75 test_i18ngrep ! "Pulling without specifying how to reconcile" err
78 test_expect_success 'pull.rebase not set and --no-ff given' '
79 git reset --hard c0 &&
80 git pull --no-ff . c1 2>err &&
81 test_i18ngrep ! "Pulling without specifying how to reconcile" err
84 test_expect_success 'pull.rebase not set and --ff-only given' '
85 git reset --hard c0 &&
86 git pull --ff-only . c1 2>err &&
87 test_i18ngrep ! "Pulling without specifying how to reconcile" err
90 test_expect_success 'merge c1 with c2' '
91 git reset --hard c1 &&
101 test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
102 git reset --hard c0 &&
103 test_config pull.ff true &&
105 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
108 test_expect_success 'pull.ff=true overrides merge.ff=false' '
109 git reset --hard c0 &&
110 test_config merge.ff false &&
111 test_config pull.ff true &&
113 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
116 test_expect_success 'fast-forward pull creates merge with "false" in pull.ff' '
117 git reset --hard c0 &&
118 test_config pull.ff false &&
120 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
121 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
124 test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
125 git reset --hard c1 &&
126 test_config pull.ff only &&
127 test_must_fail git pull . c3
130 test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
131 git reset --hard c1 &&
132 git config pull.twohead ours &&
138 test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
139 git reset --hard c1 &&
140 git config pull.octopus "recursive" &&
141 test_must_fail git merge c2 c3 &&
142 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
145 test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
146 git reset --hard c1 &&
147 git config pull.octopus "recursive octopus" &&
149 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
150 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
151 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
152 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
153 git diff --exit-code &&
163 git diff-files --name-only
164 git ls-files --unmerged
171 # There are two conflicts here:
173 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
176 # 2) One in conflict.c and that will always fail.
178 test_expect_success 'setup conflicted merge' '
179 git reset --hard c0 &&
180 echo A >conflict.c &&
181 git add conflict.c &&
182 echo contents >foo.c &&
186 echo B >conflict.c &&
187 git add conflict.c &&
188 git mv foo.c bar.c &&
191 git reset --hard c4 &&
192 echo C >conflict.c &&
193 git add conflict.c &&
194 echo secondline >> foo.c &&
200 # First do the merge with resolve and recursive then verify that
201 # recursive is chosen.
203 test_expect_success 'merge picks up the best result' '
204 git config --unset-all pull.twohead &&
205 git reset --hard c5 &&
206 test_must_fail git merge -s resolve c6 &&
207 resolve_count=$(conflict_count) &&
208 git reset --hard c5 &&
209 test_must_fail git merge -s recursive c6 &&
210 recursive_count=$(conflict_count) &&
211 git reset --hard c5 &&
212 test_must_fail git merge -s recursive -s resolve c6 &&
213 auto_count=$(conflict_count) &&
214 test $auto_count = $recursive_count &&
215 test $auto_count != $resolve_count
218 test_expect_success 'merge picks up the best result (from config)' '
219 git config pull.twohead "recursive resolve" &&
220 git reset --hard c5 &&
221 test_must_fail git merge -s resolve c6 &&
222 resolve_count=$(conflict_count) &&
223 git reset --hard c5 &&
224 test_must_fail git merge -s recursive c6 &&
225 recursive_count=$(conflict_count) &&
226 git reset --hard c5 &&
227 test_must_fail git merge c6 &&
228 auto_count=$(conflict_count) &&
229 test $auto_count = $recursive_count &&
230 test $auto_count != $resolve_count
233 test_expect_success 'merge errors out on invalid strategy' '
234 git config pull.twohead "foobar" &&
235 git reset --hard c5 &&
236 test_must_fail git merge c6
239 test_expect_success 'merge errors out on invalid strategy' '
240 git config --unset-all pull.twohead &&
241 git reset --hard c5 &&
242 test_must_fail git merge -s "resolve recursive" c6