Code

Merge branch 'ph/rerere-doc' into maint-1.7.8
[git.git] / t / t3411-rebase-preserve-around-merges.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2008 Stephen Haberman
4 #
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.
10 '
11 . ./test-lib.sh
13 . "$TEST_DIRECTORY"/lib-rebase.sh
15 set_fake_editor
17 # set up two branches like this:
18 #
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
31 '
33 # Should result in:
34 #
35 # A1 - B1 - D2 - E2
36 #       \        /
37 #        -- C1 --
38 #
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
44 '
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
58 test_expect_success 'rebase two levels of merge' '
59         test_commit G1 &&
60         test_commit H1 &&
61         test_commit I1 &&
62         git checkout -b branch3 H1 &&
63         test_commit J1 &&
64         test_merge K1 I1 &&
65         git checkout -b branch2 G1 &&
66         test_commit L1 &&
67         test_merge M1 K1 &&
68         GIT_EDITOR=: git rebase -i -p E2 &&
69         test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" &&
70         test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" &&
71         test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"
72 '
74 test_done