Seventh batch for 2.20
[git/debian.git] / t / t3411-rebase-preserve-around-merges.sh
blobdc81bf27eb736d32df0f0c3205de3254898d20b5
1 #!/bin/sh
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.
11 . ./test-lib.sh
13 . "$TEST_DIRECTORY"/lib-rebase.sh
15 set_fake_editor
17 # set up two branches like this:
19 # A1 - B1 - D1 - E1 - F1
20 # \ /
21 # -- C1 --
23 test_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
33 # Should result in:
35 # A1 - B1 - D2 - E2
36 # \ /
37 # -- C1 --
39 test_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
46 # Start with:
48 # A1 - B1 - D2 - E2
49 # \
50 # G1 ---- L1 ---- M1
51 # \ /
52 # H1 -- J1 -- K1
53 # \ /
54 # -- I1 --
56 # And rebase G1..M1 onto E2
58 test_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)"
75 test_done