t5520: verify that `pull --rebase` shows the helpful advice when failing

It was noticed by Brendan Forster last October that the builtin `git am` regressed on that. Our hot fix reverted to spawning the recursive merge instead of using it as a library function. As we are about to revert that hot fix, after making the recursive merge a true library function (i.e. a function that does not die() in case of "normal" errors), let's add a test that verifies that we do not regress on the same problem which made the hot fix necessary in the first place. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 26, 2016 at 18:05 UTC 3be18b47e4249a3e3f8ae9968abffc954c7e293a
1 file changed +32
t/t5520-pull.sh
+32
@@ -255,6 +255,38 @@ test_expect_success '--rebase' '
255 test new = "$(git show HEAD:file2)"
256 '
257
258 +test_expect_success '--rebase with conflicts shows advice' '
259 + test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
260 + git checkout -b seq &&
261 + test_seq 5 >seq.txt &&
262 + git add seq.txt &&
263 + test_tick &&
264 + git commit -m "Add seq.txt" &&
265 + echo 6 >>seq.txt &&
266 + test_tick &&
267 + git commit -m "Append to seq.txt" seq.txt &&
268 + git checkout -b with-conflicts HEAD^ &&
269 + echo conflicting >>seq.txt &&
270 + test_tick &&
271 + git commit -m "Create conflict" seq.txt &&
272 + test_must_fail git pull --rebase . seq 2>err >out &&
273 + grep "When you have resolved this problem" out
274 +'
275 +
276 +test_expect_success 'failed --rebase shows advice' '
277 + test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
278 + git checkout -b diverging &&
279 + test_commit attributes .gitattributes "* text=auto" attrs &&
280 + sha1="$(printf "1\\r\\n" | git hash-object -w --stdin)" &&
281 + git update-index --cacheinfo 0644 $sha1 file &&
282 + git commit -m v1-with-cr &&
283 + # force checkout because `git reset --hard` will not leave clean `file`
284 + git checkout -f -b fails-to-rebase HEAD^ &&
285 + test_commit v2-without-cr file "2" file2-lf &&
286 + test_must_fail git pull --rebase . diverging 2>err >out &&
287 + grep "When you have resolved this problem" out
288 +'
289 +
290 test_expect_success '--rebase fails with multiple branches' '
291 git reset --hard before-rebase &&
292 test_must_fail git pull --rebase . copy master 2>err &&