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