3 test_description
='git rebase --onto A...B'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=master
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 .
"$TEST_DIRECTORY/lib-rebase.sh"
11 # Rebase only the tip commit of "topic" on merge base between "master"
12 # and "topic". Cannot do this for "side" with "master" because there
13 # is no single merge base.
18 # A---B---C---D---E master --> A---B---C---D---E
24 test_expect_success setup
'
32 git checkout master &&
48 test_expect_success
'rebase --onto master...topic' '
53 git rebase --onto master...topic F &&
54 git rev-parse HEAD^1 >actual &&
55 git rev-parse C^0 >expect &&
56 test_cmp expect actual
59 test_expect_success
'rebase --onto master...' '
64 git rebase --onto master... F &&
65 git rev-parse HEAD^1 >actual &&
66 git rev-parse C^0 >expect &&
67 test_cmp expect actual
70 test_expect_success
'rebase --onto master...side' '
75 test_must_fail git rebase --onto master...side J
78 test_expect_success
'rebase -i --onto master...topic' '
83 EXPECT_COUNT=1 git rebase -i --onto master...topic F &&
84 git rev-parse HEAD^1 >actual &&
85 git rev-parse C^0 >expect &&
86 test_cmp expect actual
89 test_expect_success
'rebase -i --onto master...' '
94 EXPECT_COUNT=1 git rebase -i --onto master... F &&
95 git rev-parse HEAD^1 >actual &&
96 git rev-parse C^0 >expect &&
97 test_cmp expect actual
100 test_expect_success
'rebase -i --onto master...side' '
103 git reset --hard K &&
106 test_must_fail git rebase -i --onto master...side J
109 test_expect_success
'rebase --keep-base --onto incompatible' '
110 test_must_fail git rebase --keep-base --onto master...
113 test_expect_success
'rebase --keep-base --root incompatible' '
114 test_must_fail git rebase --keep-base --root
117 test_expect_success
'rebase --keep-base master from topic' '
119 git checkout topic &&
120 git reset --hard G &&
122 git rebase --keep-base master &&
123 git rev-parse C >base.expect &&
124 git merge-base master HEAD >base.actual &&
125 test_cmp base.expect base.actual &&
127 git rev-parse HEAD~2 >actual &&
128 git rev-parse C^0 >expect &&
129 test_cmp expect actual
132 test_expect_success
'rebase --keep-base master from side' '
135 git reset --hard K &&
137 test_must_fail git rebase --keep-base master
140 test_expect_success
'rebase -i --keep-base master from topic' '
142 git checkout topic &&
143 git reset --hard G &&
146 EXPECT_COUNT=2 git rebase -i --keep-base master &&
147 git rev-parse C >base.expect &&
148 git merge-base master HEAD >base.actual &&
149 test_cmp base.expect base.actual &&
151 git rev-parse HEAD~2 >actual &&
152 git rev-parse C^0 >expect &&
153 test_cmp expect actual
156 test_expect_success
'rebase -i --keep-base master from side' '
159 git reset --hard K &&
162 test_must_fail git rebase -i --keep-base master