t / t3409-rebase-preserve-merges.shon commit t: branch: fix broken && chains (d0423dd)
   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
  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        echo Fifth > B &&
  44        git add B &&
  45        git commit -m "Add different B" &&
  46
  47        git clone ./. clone2 &&
  48        (
  49                cd clone2 &&
  50                git checkout -b topic origin/topic &&
  51                test_must_fail git merge origin/master &&
  52                echo Resolved >B &&
  53                git add B &&
  54                git commit -m "Merge origin/master into topic"
  55        ) &&
  56
  57        git clone ./. clone3 &&
  58        (
  59                cd clone3 &&
  60                git checkout -b topic2 origin/topic &&
  61                echo Sixth > A &&
  62                git commit -a -m "Modify A3" &&
  63                git checkout -b topic origin/topic &&
  64                git merge --no-ff topic2
  65        ) &&
  66
  67        git checkout topic &&
  68        echo Fourth >> B &&
  69        git commit -a -m "Modify B2"
  70'
  71
  72test_expect_success '--continue works after a conflict' '
  73        (
  74        cd clone2 &&
  75        git fetch &&
  76        test_must_fail git rebase -p origin/topic &&
  77        test 2 = $(git ls-files B | wc -l) &&
  78        echo Resolved again > B &&
  79        test_must_fail git rebase --continue &&
  80        grep "^@@@ " .git/rebase-merge/patch &&
  81        git add B &&
  82        git rebase --continue &&
  83        test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
  84        test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) &&
  85        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l)
  86        )
  87'
  88
  89test_expect_success 'rebase -p preserves no-ff merges' '
  90        (
  91        cd clone3 &&
  92        git fetch &&
  93        git rebase -p origin/topic &&
  94        test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
  95        test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
  96        )
  97'
  98
  99test_done