@@ -35,6 +35,7 @@ printf '%s\n' 1 2 3 4 5 6 7 8 '9 X' >file.9
35
35
printf ' %s\n' ' 1 X' 2 3 4 5 6 7 8 9 > result.1
36
36
printf ' %s\n' ' 1 X' 2 3 4 ' 5 X' 6 7 8 9 > result.1-5
37
37
printf ' %s\n' ' 1 X' 2 3 4 ' 5 X' 6 7 8 ' 9 X' > result.1-5-9
38
+ > empty
38
39
39
40
create_merge_msgs () {
40
41
echo " Merge commit 'c2'" > msg.1-5 &&
@@ -224,12 +225,28 @@ test_expect_success 'merge c1 with c2 and c3' '
224
225
225
226
test_debug ' git log --graph --decorate --oneline --all'
226
227
227
- test_expect_success ' failing merges with --ff-only' '
228
+ test_expect_success ' merges with --ff-only' '
228
229
git reset --hard c1 &&
229
230
test_tick &&
230
231
test_must_fail git merge --ff-only c2 &&
231
232
test_must_fail git merge --ff-only c3 &&
232
- test_must_fail git merge --ff-only c2 c3
233
+ test_must_fail git merge --ff-only c2 c3 &&
234
+ git reset --hard c0 &&
235
+ git merge c3 &&
236
+ verify_head $c3
237
+ '
238
+
239
+ test_expect_success ' merges with merge.ff=only' '
240
+ git reset --hard c1 &&
241
+ test_tick &&
242
+ test_when_finished "git config --unset merge.ff" &&
243
+ git config merge.ff only &&
244
+ test_must_fail git merge c2 &&
245
+ test_must_fail git merge c3 &&
246
+ test_must_fail git merge c2 c3 &&
247
+ git reset --hard c0 &&
248
+ git merge c3 &&
249
+ verify_head $c3
233
250
'
234
251
235
252
test_expect_success ' merge c0 with c1 (no-commit)' '
@@ -338,10 +355,11 @@ test_expect_success 'merge c1 with c2 (log in config)' '
338
355
'
339
356
340
357
test_expect_success ' merge c1 with c2 (log in config gets overridden)' '
341
- (
342
- git config --remove-section branch.master
343
- git config --remove-section merge
344
- )
358
+ test_when_finished "git config --remove-section branch.master" &&
359
+ test_when_finished "git config --remove-section merge" &&
360
+ test_might_fail git config --remove-section branch.master &&
361
+ test_might_fail git config --remove-section merge &&
362
+
345
363
git reset --hard c1 &&
346
364
git merge c2 &&
347
365
git show -s --pretty=tformat:%s%n%b >expect &&
@@ -446,7 +464,41 @@ test_expect_success 'merge c0 with c1 (no-ff)' '
446
464
447
465
test_debug ' git log --graph --decorate --oneline --all'
448
466
467
+ test_expect_success ' merge c0 with c1 (merge.ff=false)' '
468
+ git reset --hard c0 &&
469
+ git config merge.ff false &&
470
+ test_tick &&
471
+ git merge c1 &&
472
+ git config --remove-section merge &&
473
+ verify_merge file result.1 &&
474
+ verify_parents $c0 $c1
475
+ '
476
+ test_debug ' git log --graph --decorate --oneline --all'
477
+
478
+ test_expect_success ' combine branch.master.mergeoptions with merge.ff' '
479
+ git reset --hard c0 &&
480
+ git config branch.master.mergeoptions --ff &&
481
+ git config merge.ff false &&
482
+ test_tick &&
483
+ git merge c1 &&
484
+ git config --remove-section "branch.master" &&
485
+ git config --remove-section "merge" &&
486
+ verify_merge file result.1 &&
487
+ verify_parents "$c0"
488
+ '
489
+
490
+ test_expect_success ' tolerate unknown values for merge.ff' '
491
+ git reset --hard c0 &&
492
+ git config merge.ff something-new &&
493
+ test_tick &&
494
+ git merge c1 2>message &&
495
+ git config --remove-section "merge" &&
496
+ verify_head "$c1" &&
497
+ test_cmp empty message
498
+ '
499
+
449
500
test_expect_success ' combining --squash and --no-ff is refused' '
501
+ git reset --hard c0 &&
450
502
test_must_fail git merge --squash --no-ff c1 &&
451
503
test_must_fail git merge --no-ff --squash c1
452
504
'
0 commit comments