3 # Copyright (c) 2008 Stephen Haberman
6 test_description
='git rebase preserve merges
8 This test runs git rebase with -p and tries to squash a commit from after
9 a merge to before the merge.
17 # set up two branches like this:
19 # A1 - B1 - D1 - E1 - F1
23 test_expect_success
'setup' '
32 git checkout -b branch &&
36 git checkout master &&
53 test_expect_success
'squash F1 into D1' '
54 FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
55 test "$(git rev-parse HEAD^2)" = "$(git rev-parse branch)" &&
56 test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
70 # And rebase G1..M1 onto E2
72 test_expect_success
'rebase two levels of merge' '
73 git checkout -b branch2 A1 &&
77 git checkout -b branch3 &&
81 git checkout -b branch4 &&
86 git checkout branch3 &&
90 git merge I1 --no-commit &&
93 git checkout branch2 &&
97 git merge K1 --no-commit &&
99 GIT_EDITOR=: git rebase -i -p E2 &&
100 test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" &&
101 test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" &&
102 test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"