t / t3410-rebase-preserve-dropped-merges.shon commit Merge branch 'jk/pack-objects-reports-num-objects-to-trace2' (3d67555)
   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 preserve merges and ensures commits
   9dropped by the --cherry-pick flag have their childrens parents
  10rewritten.
  11'
  12. ./test-lib.sh
  13
  14if ! test_have_prereq REBASE_P; then
  15        skip_all='skipping git rebase -p tests, as asked for'
  16        test_done
  17fi
  18
  19# set up two branches like this:
  20#
  21# A - B - C - D - E
  22#   \
  23#     F - G - H
  24#       \
  25#         I
  26#
  27# where B, D and G touch the same file.
  28
  29test_expect_success 'setup' '
  30        test_commit A file1 &&
  31        test_commit B file1 1 &&
  32        test_commit C file2 &&
  33        test_commit D file1 2 &&
  34        test_commit E file3 &&
  35        git checkout A &&
  36        test_commit F file4 &&
  37        test_commit G file1 3 &&
  38        test_commit H file5 &&
  39        git checkout F &&
  40        test_commit I file6
  41'
  42
  43# A - B - C - D - E
  44#   \             \ \
  45#     F - G - H -- L \        -->   L
  46#       \            |               \
  47#         I -- G2 -- J -- K           I -- K
  48# G2 = same changes as G
  49test_expect_success 'skip same-resolution merges with -p' '
  50        git checkout H &&
  51        test_must_fail git merge E &&
  52        test_commit L file1 23 &&
  53        git checkout I &&
  54        test_commit G2 file1 3 &&
  55        test_must_fail git merge E &&
  56        test_commit J file1 23 &&
  57        test_commit K file7 file7 &&
  58        git rebase -i -p L &&
  59        test $(git rev-parse HEAD^^) = $(git rev-parse L) &&
  60        test "23" = "$(cat file1)" &&
  61        test "I" = "$(cat file6)" &&
  62        test "file7" = "$(cat file7)"
  63'
  64
  65# A - B - C - D - E
  66#   \             \ \
  67#     F - G - H -- L2 \        -->   L2
  68#       \             |                \
  69#         I -- G3 --- J2 -- K2           I -- G3 -- K2
  70# G2 = different changes as G
  71test_expect_success 'keep different-resolution merges with -p' '
  72        git checkout H &&
  73        test_must_fail git merge E &&
  74        test_commit L2 file1 23 &&
  75        git checkout I &&
  76        test_commit G3 file1 4 &&
  77        test_must_fail git merge E &&
  78        test_commit J2 file1 24 &&
  79        test_commit K2 file7 file7 &&
  80        test_must_fail git rebase -i -p L2 &&
  81        echo 234 > file1 &&
  82        git add file1 &&
  83        git rebase --continue &&
  84        test $(git rev-parse HEAD^^^) = $(git rev-parse L2) &&
  85        test "234" = "$(cat file1)" &&
  86        test "I" = "$(cat file6)" &&
  87        test "file7" = "$(cat file7)"
  88'
  89
  90test_done