t / t3409-rebase-preserve-merges.shon commit Merge branch 'aw/git-p4-deletion' into maint (385cc9d)
   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 1 (trivial merge):
  15#
  16# A1--A2  <-- origin/master
  17#  \   \
  18#   B1--M  <-- topic
  19#    \
  20#     B2  <-- origin/topic
  21#
  22# Clone 2 (conflicting merge):
  23#
  24# A1--A2--B3   <-- origin/master
  25#  \       \
  26#   B1------M  <-- topic
  27#    \
  28#     B2       <-- origin/topic
  29#
  30# In both cases, 'topic' is rebased onto 'origin/topic'.
  31
  32test_expect_success 'setup for merge-preserving rebase' \
  33        'echo First > A &&
  34        git add A &&
  35        git commit -m "Add A1" &&
  36        git checkout -b topic &&
  37        echo Second > B &&
  38        git add B &&
  39        git commit -m "Add B1" &&
  40        git checkout -f master &&
  41        echo Third >> A &&
  42        git commit -a -m "Modify A2" &&
  43
  44        git clone ./. clone1 &&
  45        (cd clone1 &&
  46        git checkout -b topic origin/topic &&
  47        git merge origin/master
  48        ) &&
  49
  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 checkout topic &&
  65        echo Fourth >> B &&
  66        git commit -a -m "Modify B2"
  67'
  68
  69test_expect_success 'rebase -p fakes interactive rebase' '
  70        (
  71        cd clone1 &&
  72        git fetch &&
  73        git rebase -p origin/topic &&
  74        test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
  75        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote branch " | wc -l)
  76        )
  77'
  78
  79test_expect_success '--continue works after a conflict' '
  80        (
  81        cd clone2 &&
  82        git fetch &&
  83        test_must_fail git rebase -p origin/topic &&
  84        test 2 = $(git ls-files B | wc -l) &&
  85        echo Resolved again > B &&
  86        test_must_fail git rebase --continue &&
  87        grep "^@@@ " .git/rebase-merge/patch &&
  88        git add B &&
  89        git rebase --continue &&
  90        test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
  91        test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
  92        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
  93        )
  94'
  95
  96test_done