t / t3409-rebase-preserve-merges.shon commit t7006: add tests for how git branch paginates (ed104fa)
   1#!/bin/sh
   2#
   3# Copyright(C) 2008 Stephen Habermann & Andreas Ericsson
   4#
   5test_description='git rebase -p should preserve merges
   6
   7Run "git rebase -p" and check that merges are properly carried along
   8'
   9. ./test-lib.sh
  10
  11GIT_AUTHOR_EMAIL=bogus_email_address
  12export GIT_AUTHOR_EMAIL
  13
  14# Clone 2 (conflicting merge):
  15#
  16# A1--A2--B3   <-- origin/master
  17#  \       \
  18#   B1------M  <-- topic
  19#    \
  20#     B2       <-- origin/topic
  21#
  22# Clone 3 (no-ff merge):
  23#
  24# A1--A2--B3   <-- origin/master
  25#  \
  26#   B1------M  <-- topic
  27#    \     /
  28#     \--A3    <-- topic2
  29#      \
  30#       B2     <-- origin/topic
  31#
  32# Clone 4 (same as Clone 3)
  33
  34test_expect_success 'setup for merge-preserving rebase' \
  35        'echo First > A &&
  36        git add A &&
  37        git commit -m "Add A1" &&
  38        git checkout -b topic &&
  39        echo Second > B &&
  40        git add B &&
  41        git commit -m "Add B1" &&
  42        git checkout -f master &&
  43        echo Third >> A &&
  44        git commit -a -m "Modify A2" &&
  45        echo Fifth > B &&
  46        git add B &&
  47        git commit -m "Add different B" &&
  48
  49        git clone ./. clone2 &&
  50        (
  51                cd clone2 &&
  52                git checkout -b topic origin/topic &&
  53                test_must_fail git merge origin/master &&
  54                echo Resolved >B &&
  55                git add B &&
  56                git commit -m "Merge origin/master into topic"
  57        ) &&
  58
  59        git clone ./. clone3 &&
  60        (
  61                cd clone3 &&
  62                git checkout -b topic2 origin/topic &&
  63                echo Sixth > A &&
  64                git commit -a -m "Modify A3" &&
  65                git checkout -b topic origin/topic &&
  66                git merge --no-ff topic2
  67        ) &&
  68
  69        git clone ./. clone4 &&
  70        (
  71                cd clone4 &&
  72                git checkout -b topic2 origin/topic &&
  73                echo Sixth > A &&
  74                git commit -a -m "Modify A3" &&
  75                git checkout -b topic origin/topic &&
  76                git merge --no-ff topic2
  77        ) &&
  78
  79        git checkout topic &&
  80        echo Fourth >> B &&
  81        git commit -a -m "Modify B2"
  82'
  83
  84test_expect_success '--continue works after a conflict' '
  85        (
  86        cd clone2 &&
  87        git fetch &&
  88        test_must_fail git rebase -p origin/topic &&
  89        test 2 = $(git ls-files B | wc -l) &&
  90        echo Resolved again > B &&
  91        test_must_fail git rebase --continue &&
  92        grep "^@@@ " .git/rebase-merge/patch &&
  93        git add B &&
  94        git rebase --continue &&
  95        test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
  96        test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
  97        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
  98        )
  99'
 100
 101test_expect_success 'rebase -p preserves no-ff merges' '
 102        (
 103        cd clone3 &&
 104        git fetch &&
 105        git rebase -p origin/topic &&
 106        test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
 107        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
 108        )
 109'
 110
 111test_expect_success 'rebase -p ignores merge.log config' '
 112        (
 113        cd clone4 &&
 114        git fetch &&
 115        git -c merge.log=1 rebase -p origin/topic &&
 116        echo >expected &&
 117        git log --format="%b" -1 >current &&
 118        test_cmp expected current
 119        )
 120'
 121
 122test_done