t / t3411-rebase-preserve-around-merges.shon commit format-patch: introduce format.useAutoBase configuration (bb52995)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Stephen Haberman
   4#
   5
   6test_description='git rebase preserve merges
   7
   8This test runs git rebase with -p and tries to squash a commit from after
   9a merge to before the merge.
  10'
  11. ./test-lib.sh
  12
  13. "$TEST_DIRECTORY"/lib-rebase.sh
  14
  15set_fake_editor
  16
  17# set up two branches like this:
  18#
  19# A1 - B1 - D1 - E1 - F1
  20#       \        /
  21#        -- C1 --
  22
  23test_expect_success 'setup' '
  24        test_commit A1 &&
  25        test_commit B1 &&
  26        test_commit C1 &&
  27        git reset --hard B1 &&
  28        test_commit D1 &&
  29        test_merge E1 C1 &&
  30        test_commit F1
  31'
  32
  33# Should result in:
  34#
  35# A1 - B1 - D2 - E2
  36#       \        /
  37#        -- C1 --
  38#
  39test_expect_success 'squash F1 into D1' '
  40        FAKE_LINES="1 squash 4 2 3" git rebase -i -p B1 &&
  41        test "$(git rev-parse HEAD^2)" = "$(git rev-parse C1)" &&
  42        test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
  43        git tag E2
  44'
  45
  46# Start with:
  47#
  48# A1 - B1 - D2 - E2
  49#  \
  50#   G1 ---- L1 ---- M1
  51#    \             /
  52#     H1 -- J1 -- K1
  53#      \         /
  54#        -- I1 --
  55#
  56# And rebase G1..M1 onto E2
  57
  58test_expect_success 'rebase two levels of merge' '
  59        git checkout A1 &&
  60        test_commit G1 &&
  61        test_commit H1 &&
  62        test_commit I1 &&
  63        git checkout -b branch3 H1 &&
  64        test_commit J1 &&
  65        test_merge K1 I1 &&
  66        git checkout -b branch2 G1 &&
  67        test_commit L1 &&
  68        test_merge M1 K1 &&
  69        GIT_EDITOR=: git rebase -i -p E2 &&
  70        test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" &&
  71        test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" &&
  72        test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"
  73'
  74
  75test_done