t / t5520-pull.shon commit Merge branch 'js/regexec-buf' into maint (68eb7b1)
   1#!/bin/sh
   2
   3test_description='pulling into void'
   4
   5. ./test-lib.sh
   6
   7modify () {
   8        sed -e "$1" <"$2" >"$2.x" &&
   9        mv "$2.x" "$2"
  10}
  11
  12test_pull_autostash () {
  13        git reset --hard before-rebase &&
  14        echo dirty >new_file &&
  15        git add new_file &&
  16        git pull "$@" . copy &&
  17        test_cmp_rev HEAD^ copy &&
  18        test "$(cat new_file)" = dirty &&
  19        test "$(cat file)" = "modified again"
  20}
  21
  22test_pull_autostash_fail () {
  23        git reset --hard before-rebase &&
  24        echo dirty >new_file &&
  25        git add new_file &&
  26        test_must_fail git pull "$@" . copy 2>err &&
  27        test_i18ngrep "uncommitted changes." err
  28}
  29
  30test_expect_success setup '
  31        echo file >file &&
  32        git add file &&
  33        git commit -a -m original
  34'
  35
  36test_expect_success 'pulling into void' '
  37        git init cloned &&
  38        (
  39                cd cloned &&
  40                git pull ..
  41        ) &&
  42        test -f file &&
  43        test -f cloned/file &&
  44        test_cmp file cloned/file
  45'
  46
  47test_expect_success 'pulling into void using master:master' '
  48        git init cloned-uho &&
  49        (
  50                cd cloned-uho &&
  51                git pull .. master:master
  52        ) &&
  53        test -f file &&
  54        test -f cloned-uho/file &&
  55        test_cmp file cloned-uho/file
  56'
  57
  58test_expect_success 'pulling into void does not overwrite untracked files' '
  59        git init cloned-untracked &&
  60        (
  61                cd cloned-untracked &&
  62                echo untracked >file &&
  63                test_must_fail git pull .. master &&
  64                echo untracked >expect &&
  65                test_cmp expect file
  66        )
  67'
  68
  69test_expect_success 'pulling into void does not overwrite staged files' '
  70        git init cloned-staged-colliding &&
  71        (
  72                cd cloned-staged-colliding &&
  73                echo "alternate content" >file &&
  74                git add file &&
  75                test_must_fail git pull .. master &&
  76                echo "alternate content" >expect &&
  77                test_cmp expect file &&
  78                git cat-file blob :file >file.index &&
  79                test_cmp expect file.index
  80        )
  81'
  82
  83test_expect_success 'pulling into void does not remove new staged files' '
  84        git init cloned-staged-new &&
  85        (
  86                cd cloned-staged-new &&
  87                echo "new tracked file" >newfile &&
  88                git add newfile &&
  89                git pull .. master &&
  90                echo "new tracked file" >expect &&
  91                test_cmp expect newfile &&
  92                git cat-file blob :newfile >newfile.index &&
  93                test_cmp expect newfile.index
  94        )
  95'
  96
  97test_expect_success 'pulling into void must not create an octopus' '
  98        git init cloned-octopus &&
  99        (
 100                cd cloned-octopus &&
 101                test_must_fail git pull .. master master &&
 102                ! test -f file
 103        )
 104'
 105
 106test_expect_success 'test . as a remote' '
 107        git branch copy master &&
 108        git config branch.copy.remote . &&
 109        git config branch.copy.merge refs/heads/master &&
 110        echo updated >file &&
 111        git commit -a -m updated &&
 112        git checkout copy &&
 113        test "$(cat file)" = file &&
 114        git pull &&
 115        test "$(cat file)" = updated &&
 116        git reflog -1 >reflog.actual &&
 117        sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
 118        echo "OBJID HEAD@{0}: pull: Fast-forward" >reflog.expected &&
 119        test_cmp reflog.expected reflog.fuzzy
 120'
 121
 122test_expect_success 'the default remote . should not break explicit pull' '
 123        git checkout -b second master^ &&
 124        echo modified >file &&
 125        git commit -a -m modified &&
 126        git checkout copy &&
 127        git reset --hard HEAD^ &&
 128        test "$(cat file)" = file &&
 129        git pull . second &&
 130        test "$(cat file)" = modified &&
 131        git reflog -1 >reflog.actual &&
 132        sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
 133        echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected &&
 134        test_cmp reflog.expected reflog.fuzzy
 135'
 136
 137test_expect_success 'fail if wildcard spec does not match any refs' '
 138        git checkout -b test copy^ &&
 139        test_when_finished "git checkout -f copy && git branch -D test" &&
 140        test "$(cat file)" = file &&
 141        test_must_fail git pull . "refs/nonexisting1/*:refs/nonexisting2/*" 2>err &&
 142        test_i18ngrep "no candidates for merging" err &&
 143        test "$(cat file)" = file
 144'
 145
 146test_expect_success 'fail if no branches specified with non-default remote' '
 147        git remote add test_remote . &&
 148        test_when_finished "git remote remove test_remote" &&
 149        git checkout -b test copy^ &&
 150        test_when_finished "git checkout -f copy && git branch -D test" &&
 151        test "$(cat file)" = file &&
 152        test_config branch.test.remote origin &&
 153        test_must_fail git pull test_remote 2>err &&
 154        test_i18ngrep "specify a branch on the command line" err &&
 155        test "$(cat file)" = file
 156'
 157
 158test_expect_success 'fail if not on a branch' '
 159        git remote add origin . &&
 160        test_when_finished "git remote remove origin" &&
 161        git checkout HEAD^ &&
 162        test_when_finished "git checkout -f copy" &&
 163        test "$(cat file)" = file &&
 164        test_must_fail git pull 2>err &&
 165        test_i18ngrep "not currently on a branch" err &&
 166        test "$(cat file)" = file
 167'
 168
 169test_expect_success 'fail if no configuration for current branch' '
 170        git remote add test_remote . &&
 171        test_when_finished "git remote remove test_remote" &&
 172        git checkout -b test copy^ &&
 173        test_when_finished "git checkout -f copy && git branch -D test" &&
 174        test_config branch.test.remote test_remote &&
 175        test "$(cat file)" = file &&
 176        test_must_fail git pull 2>err &&
 177        test_i18ngrep "no tracking information" err &&
 178        test "$(cat file)" = file
 179'
 180
 181test_expect_success 'pull --all: fail if no configuration for current branch' '
 182        git remote add test_remote . &&
 183        test_when_finished "git remote remove test_remote" &&
 184        git checkout -b test copy^ &&
 185        test_when_finished "git checkout -f copy && git branch -D test" &&
 186        test_config branch.test.remote test_remote &&
 187        test "$(cat file)" = file &&
 188        test_must_fail git pull --all 2>err &&
 189        test_i18ngrep "There is no tracking information" err &&
 190        test "$(cat file)" = file
 191'
 192
 193test_expect_success 'fail if upstream branch does not exist' '
 194        git checkout -b test copy^ &&
 195        test_when_finished "git checkout -f copy && git branch -D test" &&
 196        test_config branch.test.remote . &&
 197        test_config branch.test.merge refs/heads/nonexisting &&
 198        test "$(cat file)" = file &&
 199        test_must_fail git pull 2>err &&
 200        test_i18ngrep "no such ref was fetched" err &&
 201        test "$(cat file)" = file
 202'
 203
 204test_expect_success 'fail if the index has unresolved entries' '
 205        git checkout -b third second^ &&
 206        test_when_finished "git checkout -f copy && git branch -D third" &&
 207        test "$(cat file)" = file &&
 208        test_commit modified2 file &&
 209        test -z "$(git ls-files -u)" &&
 210        test_must_fail git pull . second &&
 211        test -n "$(git ls-files -u)" &&
 212        cp file expected &&
 213        test_must_fail git pull . second 2>err &&
 214        test_i18ngrep "Pulling is not possible because you have unmerged files." err &&
 215        test_cmp expected file &&
 216        git add file &&
 217        test -z "$(git ls-files -u)" &&
 218        test_must_fail git pull . second 2>err &&
 219        test_i18ngrep "You have not concluded your merge" err &&
 220        test_cmp expected file
 221'
 222
 223test_expect_success 'fast-forwards working tree if branch head is updated' '
 224        git checkout -b third second^ &&
 225        test_when_finished "git checkout -f copy && git branch -D third" &&
 226        test "$(cat file)" = file &&
 227        git pull . second:third 2>err &&
 228        test_i18ngrep "fetch updated the current branch head" err &&
 229        test "$(cat file)" = modified &&
 230        test "$(git rev-parse third)" = "$(git rev-parse second)"
 231'
 232
 233test_expect_success 'fast-forward fails with conflicting work tree' '
 234        git checkout -b third second^ &&
 235        test_when_finished "git checkout -f copy && git branch -D third" &&
 236        test "$(cat file)" = file &&
 237        echo conflict >file &&
 238        test_must_fail git pull . second:third 2>err &&
 239        test_i18ngrep "Cannot fast-forward your working tree" err &&
 240        test "$(cat file)" = conflict &&
 241        test "$(git rev-parse third)" = "$(git rev-parse second)"
 242'
 243
 244test_expect_success '--rebase' '
 245        git branch to-rebase &&
 246        echo modified again > file &&
 247        git commit -m file file &&
 248        git checkout to-rebase &&
 249        echo new > file2 &&
 250        git add file2 &&
 251        git commit -m "new file" &&
 252        git tag before-rebase &&
 253        git pull --rebase . copy &&
 254        test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
 255        test new = "$(git show HEAD:file2)"
 256'
 257
 258test_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        test_i18ngrep "When you have resolved this problem" out
 274'
 275
 276test_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        test_i18ngrep "When you have resolved this problem" out
 288'
 289
 290test_expect_success '--rebase fails with multiple branches' '
 291        git reset --hard before-rebase &&
 292        test_must_fail git pull --rebase . copy master 2>err &&
 293        test "$(git rev-parse HEAD)" = "$(git rev-parse before-rebase)" &&
 294        test_i18ngrep "Cannot rebase onto multiple branches" err &&
 295        test modified = "$(git show HEAD:file)"
 296'
 297
 298test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
 299        test_config rebase.autostash true &&
 300        test_pull_autostash --rebase
 301'
 302
 303test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
 304        test_config rebase.autostash true &&
 305        test_pull_autostash --rebase --autostash
 306'
 307
 308test_expect_success 'pull --rebase --autostash & rebase.autostash=false' '
 309        test_config rebase.autostash false &&
 310        test_pull_autostash --rebase --autostash
 311'
 312
 313test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
 314        test_unconfig rebase.autostash &&
 315        test_pull_autostash --rebase --autostash
 316'
 317
 318test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '
 319        test_config rebase.autostash true &&
 320        test_pull_autostash_fail --rebase --no-autostash
 321'
 322
 323test_expect_success 'pull --rebase --no-autostash & rebase.autostash=false' '
 324        test_config rebase.autostash false &&
 325        test_pull_autostash_fail --rebase --no-autostash
 326'
 327
 328test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
 329        test_unconfig rebase.autostash &&
 330        test_pull_autostash_fail --rebase --no-autostash
 331'
 332
 333for i in --autostash --no-autostash
 334do
 335        test_expect_success "pull $i (without --rebase) is illegal" '
 336                test_must_fail git pull $i . copy 2>err &&
 337                test_i18ngrep "only valid with --rebase" err
 338        '
 339done
 340
 341test_expect_success 'pull.rebase' '
 342        git reset --hard before-rebase &&
 343        test_config pull.rebase true &&
 344        git pull . copy &&
 345        test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
 346        test new = "$(git show HEAD:file2)"
 347'
 348
 349test_expect_success 'pull --autostash & pull.rebase=true' '
 350        test_config pull.rebase true &&
 351        test_pull_autostash --autostash
 352'
 353
 354test_expect_success 'pull --no-autostash & pull.rebase=true' '
 355        test_config pull.rebase true &&
 356        test_pull_autostash_fail --no-autostash
 357'
 358
 359test_expect_success 'branch.to-rebase.rebase' '
 360        git reset --hard before-rebase &&
 361        test_config branch.to-rebase.rebase true &&
 362        git pull . copy &&
 363        test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
 364        test new = "$(git show HEAD:file2)"
 365'
 366
 367test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
 368        git reset --hard before-rebase &&
 369        test_config pull.rebase true &&
 370        test_config branch.to-rebase.rebase false &&
 371        git pull . copy &&
 372        test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" &&
 373        test new = "$(git show HEAD:file2)"
 374'
 375
 376test_expect_success "pull --rebase warns on --verify-signatures" '
 377        git reset --hard before-rebase &&
 378        git pull --rebase --verify-signatures . copy 2>err &&
 379        test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
 380        test new = "$(git show HEAD:file2)" &&
 381        test_i18ngrep "ignoring --verify-signatures for rebase" err
 382'
 383
 384test_expect_success "pull --rebase does not warn on --no-verify-signatures" '
 385        git reset --hard before-rebase &&
 386        git pull --rebase --no-verify-signatures . copy 2>err &&
 387        test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
 388        test new = "$(git show HEAD:file2)" &&
 389        test_i18ngrep ! "verify-signatures" err
 390'
 391
 392# add a feature branch, keep-merge, that is merged into master, so the
 393# test can try preserving the merge commit (or not) with various
 394# --rebase flags/pull.rebase settings.
 395test_expect_success 'preserve merge setup' '
 396        git reset --hard before-rebase &&
 397        git checkout -b keep-merge second^ &&
 398        test_commit file3 &&
 399        git checkout to-rebase &&
 400        git merge keep-merge &&
 401        git tag before-preserve-rebase
 402'
 403
 404test_expect_success 'pull.rebase=false create a new merge commit' '
 405        git reset --hard before-preserve-rebase &&
 406        test_config pull.rebase false &&
 407        git pull . copy &&
 408        test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
 409        test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
 410        test file3 = "$(git show HEAD:file3.t)"
 411'
 412
 413test_expect_success 'pull.rebase=true flattens keep-merge' '
 414        git reset --hard before-preserve-rebase &&
 415        test_config pull.rebase true &&
 416        git pull . copy &&
 417        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 418        test file3 = "$(git show HEAD:file3.t)"
 419'
 420
 421test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
 422        git reset --hard before-preserve-rebase &&
 423        test_config pull.rebase 1 &&
 424        git pull . copy &&
 425        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 426        test file3 = "$(git show HEAD:file3.t)"
 427'
 428
 429test_expect_success 'pull.rebase=preserve rebases and merges keep-merge' '
 430        git reset --hard before-preserve-rebase &&
 431        test_config pull.rebase preserve &&
 432        git pull . copy &&
 433        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 434        test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
 435'
 436
 437test_expect_success 'pull.rebase=interactive' '
 438        write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
 439        echo I was here >fake.out &&
 440        false
 441        EOF
 442        test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
 443        test_must_fail git pull --rebase=interactive . copy &&
 444        test "I was here" = "$(cat fake.out)"
 445'
 446
 447test_expect_success 'pull.rebase=invalid fails' '
 448        git reset --hard before-preserve-rebase &&
 449        test_config pull.rebase invalid &&
 450        ! git pull . copy
 451'
 452
 453test_expect_success '--rebase=false create a new merge commit' '
 454        git reset --hard before-preserve-rebase &&
 455        test_config pull.rebase true &&
 456        git pull --rebase=false . copy &&
 457        test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
 458        test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
 459        test file3 = "$(git show HEAD:file3.t)"
 460'
 461
 462test_expect_success '--rebase=true rebases and flattens keep-merge' '
 463        git reset --hard before-preserve-rebase &&
 464        test_config pull.rebase preserve &&
 465        git pull --rebase=true . copy &&
 466        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 467        test file3 = "$(git show HEAD:file3.t)"
 468'
 469
 470test_expect_success '--rebase=preserve rebases and merges keep-merge' '
 471        git reset --hard before-preserve-rebase &&
 472        test_config pull.rebase true &&
 473        git pull --rebase=preserve . copy &&
 474        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 475        test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
 476'
 477
 478test_expect_success '--rebase=invalid fails' '
 479        git reset --hard before-preserve-rebase &&
 480        ! git pull --rebase=invalid . copy
 481'
 482
 483test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-merge' '
 484        git reset --hard before-preserve-rebase &&
 485        test_config pull.rebase preserve &&
 486        git pull --rebase . copy &&
 487        test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
 488        test file3 = "$(git show HEAD:file3.t)"
 489'
 490
 491test_expect_success '--rebase with rebased upstream' '
 492
 493        git remote add -f me . &&
 494        git checkout copy &&
 495        git tag copy-orig &&
 496        git reset --hard HEAD^ &&
 497        echo conflicting modification > file &&
 498        git commit -m conflict file &&
 499        git checkout to-rebase &&
 500        echo file > file2 &&
 501        git commit -m to-rebase file2 &&
 502        git tag to-rebase-orig &&
 503        git pull --rebase me copy &&
 504        test "conflicting modification" = "$(cat file)" &&
 505        test file = "$(cat file2)"
 506
 507'
 508
 509test_expect_success '--rebase -f with rebased upstream' '
 510        test_when_finished "test_might_fail git rebase --abort" &&
 511        git reset --hard to-rebase-orig &&
 512        git pull --rebase -f me copy &&
 513        test "conflicting modification" = "$(cat file)" &&
 514        test file = "$(cat file2)"
 515'
 516
 517test_expect_success '--rebase with rebased default upstream' '
 518
 519        git update-ref refs/remotes/me/copy copy-orig &&
 520        git checkout --track -b to-rebase2 me/copy &&
 521        git reset --hard to-rebase-orig &&
 522        git pull --rebase &&
 523        test "conflicting modification" = "$(cat file)" &&
 524        test file = "$(cat file2)"
 525
 526'
 527
 528test_expect_success 'rebased upstream + fetch + pull --rebase' '
 529
 530        git update-ref refs/remotes/me/copy copy-orig &&
 531        git reset --hard to-rebase-orig &&
 532        git checkout --track -b to-rebase3 me/copy &&
 533        git reset --hard to-rebase-orig &&
 534        git fetch &&
 535        git pull --rebase &&
 536        test "conflicting modification" = "$(cat file)" &&
 537        test file = "$(cat file2)"
 538
 539'
 540
 541test_expect_success 'pull --rebase dies early with dirty working directory' '
 542
 543        git checkout to-rebase &&
 544        git update-ref refs/remotes/me/copy copy^ &&
 545        COPY="$(git rev-parse --verify me/copy)" &&
 546        git rebase --onto $COPY copy &&
 547        test_config branch.to-rebase.remote me &&
 548        test_config branch.to-rebase.merge refs/heads/copy &&
 549        test_config branch.to-rebase.rebase true &&
 550        echo dirty >> file &&
 551        git add file &&
 552        test_must_fail git pull &&
 553        test "$COPY" = "$(git rev-parse --verify me/copy)" &&
 554        git checkout HEAD -- file &&
 555        git pull &&
 556        test "$COPY" != "$(git rev-parse --verify me/copy)"
 557
 558'
 559
 560test_expect_success 'pull --rebase works on branch yet to be born' '
 561        git rev-parse master >expect &&
 562        mkdir empty_repo &&
 563        (cd empty_repo &&
 564         git init &&
 565         git pull --rebase .. master &&
 566         git rev-parse HEAD >../actual
 567        ) &&
 568        test_cmp expect actual
 569'
 570
 571test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
 572        test_when_finished "rm -rf empty_repo2" &&
 573        git init empty_repo2 &&
 574        (
 575                cd empty_repo2 &&
 576                echo staged-file >staged-file &&
 577                git add staged-file &&
 578                test "$(git ls-files)" = staged-file &&
 579                test_must_fail git pull --rebase .. master 2>err &&
 580                test "$(git ls-files)" = staged-file &&
 581                test "$(git show :staged-file)" = staged-file &&
 582                test_i18ngrep "unborn branch with changes added to the index" err
 583        )
 584'
 585
 586test_expect_success 'setup for detecting upstreamed changes' '
 587        mkdir src &&
 588        (cd src &&
 589         git init &&
 590         printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
 591         git add stuff &&
 592         git commit -m "Initial revision"
 593        ) &&
 594        git clone src dst &&
 595        (cd src &&
 596         modify s/5/43/ stuff &&
 597         git commit -a -m "5->43" &&
 598         modify s/6/42/ stuff &&
 599         git commit -a -m "Make it bigger"
 600        ) &&
 601        (cd dst &&
 602         modify s/5/43/ stuff &&
 603         git commit -a -m "Independent discovery of 5->43"
 604        )
 605'
 606
 607test_expect_success 'git pull --rebase detects upstreamed changes' '
 608        (cd dst &&
 609         git pull --rebase &&
 610         test -z "$(git ls-files -u)"
 611        )
 612'
 613
 614test_expect_success 'setup for avoiding reapplying old patches' '
 615        (cd dst &&
 616         test_might_fail git rebase --abort &&
 617         git reset --hard origin/master
 618        ) &&
 619        git clone --bare src src-replace.git &&
 620        rm -rf src &&
 621        mv src-replace.git src &&
 622        (cd dst &&
 623         modify s/2/22/ stuff &&
 624         git commit -a -m "Change 2" &&
 625         modify s/3/33/ stuff &&
 626         git commit -a -m "Change 3" &&
 627         modify s/4/44/ stuff &&
 628         git commit -a -m "Change 4" &&
 629         git push &&
 630
 631         modify s/44/55/ stuff &&
 632         git commit --amend -a -m "Modified Change 4"
 633        )
 634'
 635
 636test_expect_success 'git pull --rebase does not reapply old patches' '
 637        (cd dst &&
 638         test_must_fail git pull --rebase &&
 639         test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
 640        )
 641'
 642
 643test_expect_success 'git pull --rebase against local branch' '
 644        git checkout -b copy2 to-rebase-orig &&
 645        git pull --rebase . to-rebase &&
 646        test "conflicting modification" = "$(cat file)" &&
 647        test file = "$(cat file2)"
 648'
 649
 650test_done