t / t3416-rebase-onto-threedots.shon commit Merge branch 'jk/diff-submodule-diff-inline' (a531ecf)
   1#!/bin/sh
   2
   3test_description='git rebase --onto A...B'
   4
   5. ./test-lib.sh
   6. "$TEST_DIRECTORY/lib-rebase.sh"
   7
   8# Rebase only the tip commit of "topic" on merge base between "master"
   9# and "topic".  Cannot do this for "side" with "master" because there
  10# is no single merge base.
  11#
  12#
  13#           F---G topic                             G'
  14#          /                                       /
  15# A---B---C---D---E master      -->       A---B---C---D---E
  16#      \   \ /
  17#       \   x
  18#        \ / \
  19#         H---I---J---K side
  20
  21test_expect_success setup '
  22        test_commit A &&
  23        test_commit B &&
  24        git branch side &&
  25        test_commit C &&
  26        git branch topic &&
  27        git checkout side &&
  28        test_commit H &&
  29        git checkout master &&
  30        test_tick &&
  31        git merge H &&
  32        git tag D &&
  33        test_commit E &&
  34        git checkout topic &&
  35        test_commit F &&
  36        test_commit G &&
  37        git checkout side &&
  38        test_tick &&
  39        git merge C &&
  40        git tag I &&
  41        test_commit J &&
  42        test_commit K
  43'
  44
  45test_expect_success 'rebase --onto master...topic' '
  46        git reset --hard &&
  47        git checkout topic &&
  48        git reset --hard G &&
  49
  50        git rebase --onto master...topic F &&
  51        git rev-parse HEAD^1 >actual &&
  52        git rev-parse C^0 >expect &&
  53        test_cmp expect actual
  54'
  55
  56test_expect_success 'rebase --onto master...' '
  57        git reset --hard &&
  58        git checkout topic &&
  59        git reset --hard G &&
  60
  61        git rebase --onto master... F &&
  62        git rev-parse HEAD^1 >actual &&
  63        git rev-parse C^0 >expect &&
  64        test_cmp expect actual
  65'
  66
  67test_expect_success 'rebase --onto master...side' '
  68        git reset --hard &&
  69        git checkout side &&
  70        git reset --hard K &&
  71
  72        test_must_fail git rebase --onto master...side J
  73'
  74
  75test_expect_success 'rebase -i --onto master...topic' '
  76        git reset --hard &&
  77        git checkout topic &&
  78        git reset --hard G &&
  79        set_fake_editor &&
  80        EXPECT_COUNT=1 git rebase -i --onto master...topic F &&
  81        git rev-parse HEAD^1 >actual &&
  82        git rev-parse C^0 >expect &&
  83        test_cmp expect actual
  84'
  85
  86test_expect_success 'rebase -i --onto master...' '
  87        git reset --hard &&
  88        git checkout topic &&
  89        git reset --hard G &&
  90        set_fake_editor &&
  91        EXPECT_COUNT=1 git rebase -i --onto master... F &&
  92        git rev-parse HEAD^1 >actual &&
  93        git rev-parse C^0 >expect &&
  94        test_cmp expect actual
  95'
  96
  97test_expect_success 'rebase -i --onto master...side' '
  98        git reset --hard &&
  99        git checkout side &&
 100        git reset --hard K &&
 101
 102        test_must_fail git rebase -i --onto master...side J
 103'
 104
 105test_done