]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3411-rebase-preserve-around-merges.sh
t3404 & t3411: undo copy&paste
[thirdparty/git.git] / t / t3411-rebase-preserve-around-merges.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2008 Stephen Haberman
4 #
5
6 test_description='git rebase preserve merges
7
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
12
13 . ../lib-rebase.sh
14
15 set_fake_editor
16
17 # set up two branches like this:
18 #
19 # A1 - B1 - D1 - E1 - F1
20 # \ /
21 # -- C1 --
22
23 test_expect_success 'setup' '
24 touch a &&
25 touch b &&
26 git add a &&
27 git commit -m A1 &&
28 git tag A1
29 git add b &&
30 git commit -m B1 &&
31 git tag B1 &&
32 git checkout -b branch &&
33 touch c &&
34 git add c &&
35 git commit -m C1 &&
36 git checkout master &&
37 touch d &&
38 git add d &&
39 git commit -m D1 &&
40 git merge branch &&
41 touch f &&
42 git add f &&
43 git commit -m F1 &&
44 git tag F1
45 '
46
47 # Should result in:
48 #
49 # A1 - B1 - D2 - E2
50 # \ /
51 # -- C1 --
52 #
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)" &&
57 git tag E2
58 '
59
60 # Start with:
61 #
62 # A1 - B1 - D2 - E2
63 # \
64 # G1 ---- L1 ---- M1
65 # \ /
66 # H1 -- J1 -- K1
67 # \ /
68 # -- I1 --
69 #
70 # And rebase G1..M1 onto E2
71
72 test_expect_success 'rebase two levels of merge' '
73 git checkout -b branch2 A1 &&
74 touch g &&
75 git add g &&
76 git commit -m G1 &&
77 git checkout -b branch3 &&
78 touch h
79 git add h &&
80 git commit -m H1 &&
81 git checkout -b branch4 &&
82 touch i &&
83 git add i &&
84 git commit -m I1 &&
85 git tag I1 &&
86 git checkout branch3 &&
87 touch j &&
88 git add j &&
89 git commit -m J1 &&
90 git merge I1 --no-commit &&
91 git commit -m K1 &&
92 git tag K1 &&
93 git checkout branch2 &&
94 touch l &&
95 git add l &&
96 git commit -m L1 &&
97 git merge K1 --no-commit &&
98 git commit -m M1 &&
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)"
103 '
104
105 test_done