]>
Commit | Line | Data |
---|---|---|
42f939e4 SH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2008 Stephen Haberman | |
4 | # | |
5 | ||
6 | test_description='git rebase preserve merges | |
7 | ||
29a03348 JS |
8 | This test runs git rebase with -p and tries to squash a commit from after |
9 | a merge to before the merge. | |
42f939e4 SH |
10 | ' |
11 | . ./test-lib.sh | |
12 | ||
eaf0551d | 13 | . "$TEST_DIRECTORY"/lib-rebase.sh |
42f939e4 | 14 | |
29a03348 | 15 | set_fake_editor |
42f939e4 SH |
16 | |
17 | # set up two branches like this: | |
18 | # | |
19 | # A1 - B1 - D1 - E1 - F1 | |
20 | # \ / | |
21 | # -- C1 -- | |
22 | ||
23 | test_expect_success 'setup' ' | |
37e5c8f4 JS |
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 | |
42f939e4 SH |
31 | ' |
32 | ||
33 | # Should result in: | |
34 | # | |
35 | # A1 - B1 - D2 - E2 | |
36 | # \ / | |
37 | # -- C1 -- | |
38 | # | |
80fe82e4 | 39 | test_expect_success 'squash F1 into D1' ' |
12bf8283 | 40 | FAKE_LINES="1 squash 4 2 3" git rebase -i -p B1 && |
37e5c8f4 | 41 | test "$(git rev-parse HEAD^2)" = "$(git rev-parse C1)" && |
42f939e4 SH |
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 | ||
80fe82e4 | 58 | test_expect_success 'rebase two levels of merge' ' |
9ef5b2bd | 59 | git checkout A1 && |
37e5c8f4 JS |
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 && | |
42f939e4 SH |
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 | ||
75 | test_done |