t / t7600-merge.shon commit merge: add '--continue' option as a synonym for 'git commit' (367ff69)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Lars Hjemli
   4#
   5
   6test_description='git merge
   7
   8Testing basic merge operations/option parsing.
   9
  10! [c0] commit 0
  11 ! [c1] commit 1
  12  ! [c2] commit 2
  13   ! [c3] commit 3
  14    ! [c4] c4
  15     ! [c5] c5
  16      ! [c6] c6
  17       * [master] Merge commit 'c1'
  18--------
  19       - [master] Merge commit 'c1'
  20 +     * [c1] commit 1
  21      +  [c6] c6
  22     +   [c5] c5
  23    ++   [c4] c4
  24   ++++  [c3] commit 3
  25  +      [c2] commit 2
  26+++++++* [c0] commit 0
  27'
  28
  29. ./test-lib.sh
  30. "$TEST_DIRECTORY"/lib-gpg.sh
  31
  32printf '%s\n' 1 2 3 4 5 6 7 8 9 >file
  33printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >file.1
  34printf '%s\n' 1 2 3 4 '5 X' 6 7 8 9 >file.5
  35printf '%s\n' 1 2 3 4 5 6 7 8 '9 X' >file.9
  36printf '%s\n' 1 2 3 4 5 6 7 8 '9 Y' >file.9y
  37printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >result.1
  38printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 9 >result.1-5
  39printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 '9 X' >result.1-5-9
  40printf '%s\n' 1 2 3 4 5 6 7 8 '9 Z' >result.9z
  41>empty
  42
  43create_merge_msgs () {
  44        echo "Merge tag 'c2'" >msg.1-5 &&
  45        echo "Merge tags 'c2' and 'c3'" >msg.1-5-9 &&
  46        {
  47                echo "Squashed commit of the following:" &&
  48                echo &&
  49                git log --no-merges ^HEAD c1
  50        } >squash.1 &&
  51        {
  52                echo "Squashed commit of the following:" &&
  53                echo &&
  54                git log --no-merges ^HEAD c2
  55        } >squash.1-5 &&
  56        {
  57                echo "Squashed commit of the following:" &&
  58                echo &&
  59                git log --no-merges ^HEAD c2 c3
  60        } >squash.1-5-9 &&
  61        : >msg.nologff &&
  62        : >msg.nolognoff &&
  63        {
  64                echo "* tag 'c3':" &&
  65                echo "  commit 3"
  66        } >msg.log
  67}
  68
  69verify_merge () {
  70        test_cmp "$2" "$1" &&
  71        git update-index --refresh &&
  72        git diff --exit-code &&
  73        if test -n "$3"
  74        then
  75                git show -s --pretty=tformat:%s HEAD >msg.act &&
  76                test_cmp "$3" msg.act
  77        fi
  78}
  79
  80verify_head () {
  81        echo "$1" >head.expected &&
  82        git rev-parse HEAD >head.actual &&
  83        test_cmp head.expected head.actual
  84}
  85
  86verify_parents () {
  87        printf '%s\n' "$@" >parents.expected &&
  88        >parents.actual &&
  89        i=1 &&
  90        while test $i -le $#
  91        do
  92                git rev-parse HEAD^$i >>parents.actual &&
  93                i=$(expr $i + 1) ||
  94                return 1
  95        done &&
  96        test_must_fail git rev-parse --verify "HEAD^$i" &&
  97        test_cmp parents.expected parents.actual
  98}
  99
 100verify_mergeheads () {
 101        printf '%s\n' "$@" >mergehead.expected &&
 102        while read sha1 rest
 103        do
 104                git rev-parse $sha1
 105        done <.git/MERGE_HEAD >mergehead.actual &&
 106        test_cmp mergehead.expected mergehead.actual
 107}
 108
 109verify_no_mergehead () {
 110        ! test -e .git/MERGE_HEAD
 111}
 112
 113test_expect_success 'setup' '
 114        git add file &&
 115        test_tick &&
 116        git commit -m "commit 0" &&
 117        git tag c0 &&
 118        c0=$(git rev-parse HEAD) &&
 119        cp file.1 file &&
 120        git add file &&
 121        test_tick &&
 122        git commit -m "commit 1" &&
 123        git tag c1 &&
 124        c1=$(git rev-parse HEAD) &&
 125        git reset --hard "$c0" &&
 126        cp file.5 file &&
 127        git add file &&
 128        test_tick &&
 129        git commit -m "commit 2" &&
 130        git tag c2 &&
 131        c2=$(git rev-parse HEAD) &&
 132        git reset --hard "$c0" &&
 133        cp file.9y file &&
 134        git add file &&
 135        test_tick &&
 136        git commit -m "commit 7" &&
 137        git tag c7 &&
 138        git reset --hard "$c0" &&
 139        cp file.9 file &&
 140        git add file &&
 141        test_tick &&
 142        git commit -m "commit 3" &&
 143        git tag c3 &&
 144        c3=$(git rev-parse HEAD) &&
 145        git reset --hard "$c0" &&
 146        create_merge_msgs
 147'
 148
 149test_debug 'git log --graph --decorate --oneline --all'
 150
 151test_expect_success 'test option parsing' '
 152        test_must_fail git merge -$ c1 &&
 153        test_must_fail git merge --no-such c1 &&
 154        test_must_fail git merge -s foobar c1 &&
 155        test_must_fail git merge -s=foobar c1 &&
 156        test_must_fail git merge -m &&
 157        test_must_fail git merge --continue foobar &&
 158        test_must_fail git merge --continue --quiet &&
 159        test_must_fail git merge
 160'
 161
 162test_expect_success 'merge -h with invalid index' '
 163        mkdir broken &&
 164        (
 165                cd broken &&
 166                git init &&
 167                >.git/index &&
 168                test_expect_code 129 git merge -h 2>usage
 169        ) &&
 170        test_i18ngrep "[Uu]sage: git merge" broken/usage
 171'
 172
 173test_expect_success 'reject non-strategy with a git-merge-foo name' '
 174        test_must_fail git merge -s index c1
 175'
 176
 177test_expect_success 'merge c0 with c1' '
 178        echo "OBJID HEAD@{0}: merge c1: Fast-forward" >reflog.expected &&
 179
 180        git reset --hard c0 &&
 181        git merge c1 &&
 182        verify_merge file result.1 &&
 183        verify_head "$c1" &&
 184
 185        git reflog -1 >reflog.actual &&
 186        sed "s/$_x05[0-9a-f]*/OBJID/g" reflog.actual >reflog.fuzzy &&
 187        test_cmp reflog.expected reflog.fuzzy
 188'
 189
 190test_debug 'git log --graph --decorate --oneline --all'
 191
 192test_expect_success 'merge c0 with c1 with --ff-only' '
 193        git reset --hard c0 &&
 194        git merge --ff-only c1 &&
 195        git merge --ff-only HEAD c0 c1 &&
 196        verify_merge file result.1 &&
 197        verify_head "$c1"
 198'
 199
 200test_debug 'git log --graph --decorate --oneline --all'
 201
 202test_expect_success 'merge from unborn branch' '
 203        git checkout -f master &&
 204        test_might_fail git branch -D kid &&
 205
 206        echo "OBJID HEAD@{0}: initial pull" >reflog.expected &&
 207
 208        git checkout --orphan kid &&
 209        test_when_finished "git checkout -f master" &&
 210        git rm -fr . &&
 211        test_tick &&
 212        git merge --ff-only c1 &&
 213        verify_merge file result.1 &&
 214        verify_head "$c1" &&
 215
 216        git reflog -1 >reflog.actual &&
 217        sed "s/$_x05[0-9a-f][0-9a-f]/OBJID/g" reflog.actual >reflog.fuzzy &&
 218        test_cmp reflog.expected reflog.fuzzy
 219'
 220
 221test_debug 'git log --graph --decorate --oneline --all'
 222
 223test_expect_success 'merge c1 with c2' '
 224        git reset --hard c1 &&
 225        test_tick &&
 226        git merge c2 &&
 227        verify_merge file result.1-5 msg.1-5 &&
 228        verify_parents $c1 $c2
 229'
 230
 231test_expect_success 'merge --squash c3 with c7' '
 232        git reset --hard c3 &&
 233        test_must_fail git merge --squash c7 &&
 234        cat result.9z >file &&
 235        git commit --no-edit -a &&
 236
 237        {
 238                cat <<-EOF
 239                Squashed commit of the following:
 240
 241                $(git show -s c7)
 242
 243                # Conflicts:
 244                #       file
 245                EOF
 246        } >expect &&
 247        git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
 248        test_cmp expect actual
 249'
 250
 251test_debug 'git log --graph --decorate --oneline --all'
 252
 253test_expect_success 'merge c1 with c2 and c3' '
 254        git reset --hard c1 &&
 255        test_tick &&
 256        git merge c2 c3 &&
 257        verify_merge file result.1-5-9 msg.1-5-9 &&
 258        verify_parents $c1 $c2 $c3
 259'
 260
 261test_debug 'git log --graph --decorate --oneline --all'
 262
 263test_expect_success 'merges with --ff-only' '
 264        git reset --hard c1 &&
 265        test_tick &&
 266        test_must_fail git merge --ff-only c2 &&
 267        test_must_fail git merge --ff-only c3 &&
 268        test_must_fail git merge --ff-only c2 c3 &&
 269        git reset --hard c0 &&
 270        git merge c3 &&
 271        verify_head $c3
 272'
 273
 274test_expect_success 'merges with merge.ff=only' '
 275        git reset --hard c1 &&
 276        test_tick &&
 277        test_config merge.ff "only" &&
 278        test_must_fail git merge c2 &&
 279        test_must_fail git merge c3 &&
 280        test_must_fail git merge c2 c3 &&
 281        git reset --hard c0 &&
 282        git merge c3 &&
 283        verify_head $c3
 284'
 285
 286test_expect_success 'merge c0 with c1 (no-commit)' '
 287        git reset --hard c0 &&
 288        git merge --no-commit c1 &&
 289        verify_merge file result.1 &&
 290        verify_head $c1
 291'
 292
 293test_debug 'git log --graph --decorate --oneline --all'
 294
 295test_expect_success 'merge c1 with c2 (no-commit)' '
 296        git reset --hard c1 &&
 297        git merge --no-commit c2 &&
 298        verify_merge file result.1-5 &&
 299        verify_head $c1 &&
 300        verify_mergeheads $c2
 301'
 302
 303test_debug 'git log --graph --decorate --oneline --all'
 304
 305test_expect_success 'merge c1 with c2 and c3 (no-commit)' '
 306        git reset --hard c1 &&
 307        git merge --no-commit c2 c3 &&
 308        verify_merge file result.1-5-9 &&
 309        verify_head $c1 &&
 310        verify_mergeheads $c2 $c3
 311'
 312
 313test_debug 'git log --graph --decorate --oneline --all'
 314
 315test_expect_success 'merge c0 with c1 (squash)' '
 316        git reset --hard c0 &&
 317        git merge --squash c1 &&
 318        verify_merge file result.1 &&
 319        verify_head $c0 &&
 320        verify_no_mergehead &&
 321        test_cmp squash.1 .git/SQUASH_MSG
 322'
 323
 324test_debug 'git log --graph --decorate --oneline --all'
 325
 326test_expect_success 'merge c0 with c1 (squash, ff-only)' '
 327        git reset --hard c0 &&
 328        git merge --squash --ff-only c1 &&
 329        verify_merge file result.1 &&
 330        verify_head $c0 &&
 331        verify_no_mergehead &&
 332        test_cmp squash.1 .git/SQUASH_MSG
 333'
 334
 335test_debug 'git log --graph --decorate --oneline --all'
 336
 337test_expect_success 'merge c1 with c2 (squash)' '
 338        git reset --hard c1 &&
 339        git merge --squash c2 &&
 340        verify_merge file result.1-5 &&
 341        verify_head $c1 &&
 342        verify_no_mergehead &&
 343        test_cmp squash.1-5 .git/SQUASH_MSG
 344'
 345
 346test_debug 'git log --graph --decorate --oneline --all'
 347
 348test_expect_success 'unsuccessful merge of c1 with c2 (squash, ff-only)' '
 349        git reset --hard c1 &&
 350        test_must_fail git merge --squash --ff-only c2
 351'
 352
 353test_debug 'git log --graph --decorate --oneline --all'
 354
 355test_expect_success 'merge c1 with c2 and c3 (squash)' '
 356        git reset --hard c1 &&
 357        git merge --squash c2 c3 &&
 358        verify_merge file result.1-5-9 &&
 359        verify_head $c1 &&
 360        verify_no_mergehead &&
 361        test_cmp squash.1-5-9 .git/SQUASH_MSG
 362'
 363
 364test_debug 'git log --graph --decorate --oneline --all'
 365
 366test_expect_success 'merge c1 with c2 (no-commit in config)' '
 367        git reset --hard c1 &&
 368        test_config branch.master.mergeoptions "--no-commit" &&
 369        git merge c2 &&
 370        verify_merge file result.1-5 &&
 371        verify_head $c1 &&
 372        verify_mergeheads $c2
 373'
 374
 375test_debug 'git log --graph --decorate --oneline --all'
 376
 377test_expect_success 'merge c1 with c2 (log in config)' '
 378        git reset --hard c1 &&
 379        git merge --log c2 &&
 380        git show -s --pretty=tformat:%s%n%b >expect &&
 381
 382        test_config branch.master.mergeoptions "--log" &&
 383        git reset --hard c1 &&
 384        git merge c2 &&
 385        git show -s --pretty=tformat:%s%n%b >actual &&
 386
 387        test_cmp expect actual
 388'
 389
 390test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
 391        git reset --hard c1 &&
 392        git merge c2 &&
 393        git show -s --pretty=tformat:%s%n%b >expect &&
 394
 395        test_config branch.master.mergeoptions "--no-log" &&
 396        test_config merge.log "true" &&
 397        git reset --hard c1 &&
 398        git merge c2 &&
 399        git show -s --pretty=tformat:%s%n%b >actual &&
 400
 401        test_cmp expect actual
 402'
 403
 404test_expect_success 'merge c1 with c2 (squash in config)' '
 405        git reset --hard c1 &&
 406        test_config branch.master.mergeoptions "--squash" &&
 407        git merge c2 &&
 408        verify_merge file result.1-5 &&
 409        verify_head $c1 &&
 410        verify_no_mergehead &&
 411        test_cmp squash.1-5 .git/SQUASH_MSG
 412'
 413
 414test_debug 'git log --graph --decorate --oneline --all'
 415
 416test_expect_success 'override config option -n with --summary' '
 417        git reset --hard c1 &&
 418        test_config branch.master.mergeoptions "-n" &&
 419        test_tick &&
 420        git merge --summary c2 >diffstat.txt &&
 421        verify_merge file result.1-5 msg.1-5 &&
 422        verify_parents $c1 $c2 &&
 423        if ! grep "^ file |  *2 +-$" diffstat.txt
 424        then
 425                echo "[OOPS] diffstat was not generated with --summary"
 426                false
 427        fi
 428'
 429
 430test_expect_success 'override config option -n with --stat' '
 431        git reset --hard c1 &&
 432        test_config branch.master.mergeoptions "-n" &&
 433        test_tick &&
 434        git merge --stat c2 >diffstat.txt &&
 435        verify_merge file result.1-5 msg.1-5 &&
 436        verify_parents $c1 $c2 &&
 437        if ! grep "^ file |  *2 +-$" diffstat.txt
 438        then
 439                echo "[OOPS] diffstat was not generated with --stat"
 440                false
 441        fi
 442'
 443
 444test_debug 'git log --graph --decorate --oneline --all'
 445
 446test_expect_success 'override config option --stat' '
 447        git reset --hard c1 &&
 448        test_config branch.master.mergeoptions "--stat" &&
 449        test_tick &&
 450        git merge -n c2 >diffstat.txt &&
 451        verify_merge file result.1-5 msg.1-5 &&
 452        verify_parents $c1 $c2 &&
 453        if grep "^ file |  *2 +-$" diffstat.txt
 454        then
 455                echo "[OOPS] diffstat was generated"
 456                false
 457        fi
 458'
 459
 460test_debug 'git log --graph --decorate --oneline --all'
 461
 462test_expect_success 'merge c1 with c2 (override --no-commit)' '
 463        git reset --hard c1 &&
 464        test_config branch.master.mergeoptions "--no-commit" &&
 465        test_tick &&
 466        git merge --commit c2 &&
 467        verify_merge file result.1-5 msg.1-5 &&
 468        verify_parents $c1 $c2
 469'
 470
 471test_debug 'git log --graph --decorate --oneline --all'
 472
 473test_expect_success 'merge c1 with c2 (override --squash)' '
 474        git reset --hard c1 &&
 475        test_config branch.master.mergeoptions "--squash" &&
 476        test_tick &&
 477        git merge --no-squash c2 &&
 478        verify_merge file result.1-5 msg.1-5 &&
 479        verify_parents $c1 $c2
 480'
 481
 482test_debug 'git log --graph --decorate --oneline --all'
 483
 484test_expect_success 'merge c0 with c1 (no-ff)' '
 485        git reset --hard c0 &&
 486        test_tick &&
 487        git merge --no-ff c1 &&
 488        verify_merge file result.1 &&
 489        verify_parents $c0 $c1
 490'
 491
 492test_debug 'git log --graph --decorate --oneline --all'
 493
 494test_expect_success 'merge c0 with c1 (merge.ff=false)' '
 495        git reset --hard c0 &&
 496        test_config merge.ff "false" &&
 497        test_tick &&
 498        git merge c1 &&
 499        verify_merge file result.1 &&
 500        verify_parents $c0 $c1
 501'
 502test_debug 'git log --graph --decorate --oneline --all'
 503
 504test_expect_success 'combine branch.master.mergeoptions with merge.ff' '
 505        git reset --hard c0 &&
 506        test_config branch.master.mergeoptions "--ff" &&
 507        test_config merge.ff "false" &&
 508        test_tick &&
 509        git merge c1 &&
 510        verify_merge file result.1 &&
 511        verify_parents "$c0"
 512'
 513
 514test_expect_success 'tolerate unknown values for merge.ff' '
 515        git reset --hard c0 &&
 516        test_config merge.ff "something-new" &&
 517        test_tick &&
 518        git merge c1 2>message &&
 519        verify_head "$c1" &&
 520        test_cmp empty message
 521'
 522
 523test_expect_success 'combining --squash and --no-ff is refused' '
 524        git reset --hard c0 &&
 525        test_must_fail git merge --squash --no-ff c1 &&
 526        test_must_fail git merge --no-ff --squash c1
 527'
 528
 529test_expect_success 'option --ff-only overwrites --no-ff' '
 530        git merge --no-ff --ff-only c1 &&
 531        test_must_fail git merge --no-ff --ff-only c2
 532'
 533
 534test_expect_success 'option --no-ff overrides merge.ff=only config' '
 535        git reset --hard c0 &&
 536        test_config merge.ff only &&
 537        git merge --no-ff c1
 538'
 539
 540test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
 541        git reset --hard c0 &&
 542        test_config branch.master.mergeoptions "--no-ff" &&
 543        git merge --ff c1 &&
 544        verify_merge file result.1 &&
 545        verify_head $c1
 546'
 547
 548test_expect_success 'merge log message' '
 549        git reset --hard c0 &&
 550        git merge --no-log c2 &&
 551        git show -s --pretty=format:%b HEAD >msg.act &&
 552        test_cmp msg.nologff msg.act &&
 553
 554        git reset --hard c0 &&
 555        test_config branch.master.mergeoptions "--no-ff" &&
 556        git merge --no-log c2 &&
 557        git show -s --pretty=format:%b HEAD >msg.act &&
 558        test_cmp msg.nolognoff msg.act &&
 559
 560        git merge --log c3 &&
 561        git show -s --pretty=format:%b HEAD >msg.act &&
 562        test_cmp msg.log msg.act &&
 563
 564        git reset --hard HEAD^ &&
 565        test_config merge.log "yes" &&
 566        git merge c3 &&
 567        git show -s --pretty=format:%b HEAD >msg.act &&
 568        test_cmp msg.log msg.act
 569'
 570
 571test_debug 'git log --graph --decorate --oneline --all'
 572
 573test_expect_success 'merge c1 with c0, c2, c0, and c1' '
 574       git reset --hard c1 &&
 575       test_tick &&
 576       git merge c0 c2 c0 c1 &&
 577       verify_merge file result.1-5 &&
 578       verify_parents $c1 $c2
 579'
 580
 581test_debug 'git log --graph --decorate --oneline --all'
 582
 583test_expect_success 'merge c1 with c0, c2, c0, and c1' '
 584       git reset --hard c1 &&
 585       test_tick &&
 586       git merge c0 c2 c0 c1 &&
 587       verify_merge file result.1-5 &&
 588       verify_parents $c1 $c2
 589'
 590
 591test_debug 'git log --graph --decorate --oneline --all'
 592
 593test_expect_success 'merge c1 with c1 and c2' '
 594       git reset --hard c1 &&
 595       test_tick &&
 596       git merge c1 c2 &&
 597       verify_merge file result.1-5 &&
 598       verify_parents $c1 $c2
 599'
 600
 601test_debug 'git log --graph --decorate --oneline --all'
 602
 603test_expect_success 'merge fast-forward in a dirty tree' '
 604       git reset --hard c0 &&
 605       mv file file1 &&
 606       cat file1 >file &&
 607       rm -f file1 &&
 608       git merge c2
 609'
 610
 611test_debug 'git log --graph --decorate --oneline --all'
 612
 613test_expect_success 'in-index merge' '
 614        git reset --hard c0 &&
 615        git merge --no-ff -s resolve c1 >out &&
 616        test_i18ngrep "Wonderful." out &&
 617        verify_parents $c0 $c1
 618'
 619
 620test_debug 'git log --graph --decorate --oneline --all'
 621
 622test_expect_success 'refresh the index before merging' '
 623        git reset --hard c1 &&
 624        cp file file.n && mv -f file.n file &&
 625        git merge c3
 626'
 627
 628cat >expected.branch <<\EOF
 629Merge branch 'c5-branch' (early part)
 630EOF
 631cat >expected.tag <<\EOF
 632Merge commit 'c5~1'
 633EOF
 634
 635test_expect_success 'merge early part of c2' '
 636        git reset --hard c3 &&
 637        echo c4 >c4.c &&
 638        git add c4.c &&
 639        git commit -m c4 &&
 640        git tag c4 &&
 641        echo c5 >c5.c &&
 642        git add c5.c &&
 643        git commit -m c5 &&
 644        git tag c5 &&
 645        git reset --hard c3 &&
 646        echo c6 >c6.c &&
 647        git add c6.c &&
 648        git commit -m c6 &&
 649        git tag c6 &&
 650        git branch -f c5-branch c5 &&
 651        git merge c5-branch~1 &&
 652        git show -s --pretty=tformat:%s HEAD >actual.branch &&
 653        git reset --keep HEAD^ &&
 654        git merge c5~1 &&
 655        git show -s --pretty=tformat:%s HEAD >actual.tag &&
 656        test_cmp expected.branch actual.branch &&
 657        test_cmp expected.tag actual.tag
 658'
 659
 660test_debug 'git log --graph --decorate --oneline --all'
 661
 662test_expect_success 'merge --no-ff --no-commit && commit' '
 663        git reset --hard c0 &&
 664        git merge --no-ff --no-commit c1 &&
 665        EDITOR=: git commit &&
 666        verify_parents $c0 $c1
 667'
 668
 669test_debug 'git log --graph --decorate --oneline --all'
 670
 671test_expect_success 'amending no-ff merge commit' '
 672        EDITOR=: git commit --amend &&
 673        verify_parents $c0 $c1
 674'
 675
 676test_debug 'git log --graph --decorate --oneline --all'
 677
 678cat >editor <<\EOF
 679#!/bin/sh
 680# Add a new message string that was not in the template
 681(
 682        echo "Merge work done on the side branch c1"
 683        echo
 684        cat <"$1"
 685) >"$1.tmp" && mv "$1.tmp" "$1"
 686# strip comments and blank lines from end of message
 687sed -e '/^#/d' < "$1" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > expected
 688EOF
 689chmod 755 editor
 690
 691test_expect_success 'merge --no-ff --edit' '
 692        git reset --hard c0 &&
 693        EDITOR=./editor git merge --no-ff --edit c1 &&
 694        verify_parents $c0 $c1 &&
 695        git cat-file commit HEAD >raw &&
 696        grep "work done on the side branch" raw &&
 697        sed "1,/^$/d" >actual raw &&
 698        test_cmp actual expected
 699'
 700
 701test_expect_success GPG 'merge --ff-only tag' '
 702        git reset --hard c0 &&
 703        git commit --allow-empty -m "A newer commit" &&
 704        git tag -s -m "A newer commit" signed &&
 705        git reset --hard c0 &&
 706
 707        git merge --ff-only signed &&
 708        git rev-parse signed^0 >expect &&
 709        git rev-parse HEAD >actual &&
 710        test_cmp actual expect
 711'
 712
 713test_expect_success GPG 'merge --no-edit tag should skip editor' '
 714        git reset --hard c0 &&
 715        git commit --allow-empty -m "A newer commit" &&
 716        git tag -f -s -m "A newer commit" signed &&
 717        git reset --hard c0 &&
 718
 719        EDITOR=false git merge --no-edit signed &&
 720        git rev-parse signed^0 >expect &&
 721        git rev-parse HEAD^2 >actual &&
 722        test_cmp actual expect
 723'
 724
 725test_expect_success 'set up mod-256 conflict scenario' '
 726        # 256 near-identical stanzas...
 727        for i in $(test_seq 1 256); do
 728                for j in 1 2 3 4 5; do
 729                        echo $i-$j
 730                done
 731        done >file &&
 732        git add file &&
 733        git commit -m base &&
 734
 735        # one side changes the first line of each to "master"
 736        sed s/-1/-master/ <file >tmp &&
 737        mv tmp file &&
 738        git commit -am master &&
 739
 740        # and the other to "side"; merging the two will
 741        # yield 256 separate conflicts
 742        git checkout -b side HEAD^ &&
 743        sed s/-1/-side/ <file >tmp &&
 744        mv tmp file &&
 745        git commit -am side
 746'
 747
 748test_expect_success 'merge detects mod-256 conflicts (recursive)' '
 749        git reset --hard &&
 750        test_must_fail git merge -s recursive master
 751'
 752
 753test_expect_success 'merge detects mod-256 conflicts (resolve)' '
 754        git reset --hard &&
 755        test_must_fail git merge -s resolve master
 756'
 757
 758test_expect_success 'merge nothing into void' '
 759        git init void &&
 760        (
 761                cd void &&
 762                git remote add up .. &&
 763                git fetch up &&
 764                test_must_fail git merge FETCH_HEAD
 765        )
 766'
 767
 768test_expect_success 'merge can be completed with --continue' '
 769        git reset --hard c0 &&
 770        git merge --no-ff --no-commit c1 &&
 771        git merge --continue &&
 772        verify_parents $c0 $c1
 773'
 774
 775test_done