3 test_description='git rebase --onto A...B'
6 . "$TEST_DIRECTORY/lib-rebase.sh"
8 # Rebase only the tip commit of "topic" on merge base between "master"
9 # and "topic". Cannot do this for "side" with "master" because there
10 # is no single merge base.
15 # A---B---C---D---E master --> A---B---C---D---E
21 test_expect_success setup '
29 git checkout master &&
45 test_expect_success 'rebase --onto master...topic' '
50 git rebase --onto master...topic F &&
51 git rev-parse HEAD^1 >actual &&
52 git rev-parse C^0 >expect &&
53 test_cmp expect actual
56 test_expect_success 'rebase --onto master...' '
61 git rebase --onto master... F &&
62 git rev-parse HEAD^1 >actual &&
63 git rev-parse C^0 >expect &&
64 test_cmp expect actual
67 test_expect_success 'rebase --onto master...side' '
72 test_must_fail git rebase --onto master...side J
75 test_expect_success 'rebase -i --onto master...topic' '
80 EXPECT_COUNT=1 git rebase -i --onto master...topic F &&
81 git rev-parse HEAD^1 >actual &&
82 git rev-parse C^0 >expect &&
83 test_cmp expect actual
86 test_expect_success 'rebase -i --onto master...' '
91 EXPECT_COUNT=1 git rebase -i --onto master... F &&
92 git rev-parse HEAD^1 >actual &&
93 git rev-parse C^0 >expect &&
94 test_cmp expect actual
97 test_expect_success 'rebase -i --onto master...side' '
100 git reset --hard K &&
103 test_must_fail git rebase -i --onto master...side J
106 test_expect_success 'rebase --keep-base --onto incompatible' '
107 test_must_fail git rebase --keep-base --onto master...
110 test_expect_success 'rebase --keep-base --root incompatible' '
111 test_must_fail git rebase --keep-base --root
114 test_expect_success 'rebase --keep-base master from topic' '
116 git checkout topic &&
117 git reset --hard G &&
119 git rebase --keep-base master &&
120 git rev-parse C >base.expect &&
121 git merge-base master HEAD >base.actual &&
122 test_cmp base.expect base.actual &&
124 git rev-parse HEAD~2 >actual &&
125 git rev-parse C^0 >expect &&
126 test_cmp expect actual
129 test_expect_success 'rebase --keep-base master from side' '
132 git reset --hard K &&
134 test_must_fail git rebase --keep-base master
137 test_expect_success 'rebase -i --keep-base master from topic' '
139 git checkout topic &&
140 git reset --hard G &&
143 EXPECT_COUNT=2 git rebase -i --keep-base master &&
144 git rev-parse C >base.expect &&
145 git merge-base master HEAD >base.actual &&
146 test_cmp base.expect base.actual &&
148 git rev-parse HEAD~2 >actual &&
149 git rev-parse C^0 >expect &&
150 test_cmp expect actual
153 test_expect_success 'rebase -i --keep-base master from side' '
156 git reset --hard K &&
159 test_must_fail git rebase -i --keep-base master