3 test_description
='basic rebase topology tests'
5 .
"$TEST_DIRECTORY"/lib-rebase.sh
10 test_expect_success
'setup' '
22 test_expect_
$result "simple rebase $*" "
25 test_cmp_rev c HEAD~2 &&
26 test_linear_range 'd e' c..
29 test_run_rebase success
''
30 test_run_rebase success
-m
31 test_run_rebase success
-i
32 test_have_prereq
!REBASE_P || test_run_rebase success
-p
37 test_expect_
$result "rebase $* is no-op if upstream is an ancestor" "
43 test_run_rebase success
''
44 test_run_rebase success
-m
45 test_run_rebase success
-i
46 test_have_prereq
!REBASE_P || test_run_rebase success
-p
51 test_expect_
$result "rebase $* -f rewrites even if upstream is an ancestor" "
53 git rebase $* -f b e &&
54 ! test_cmp_rev e HEAD &&
55 test_cmp_rev b HEAD~2 &&
56 test_linear_range 'd e' b..
59 test_run_rebase success
''
60 test_run_rebase success
-m
61 test_run_rebase success
-i
62 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
67 test_expect_
$result "rebase $* fast-forwards from ancestor of upstream" "
73 test_run_rebase success
''
74 test_run_rebase success
-m
75 test_run_rebase success
-i
76 test_have_prereq
!REBASE_P || test_run_rebase success
-p
84 # gp = cherry-picked g
87 # Reverted patches are there for tests to be able to check if a commit
88 # that introduced the same change as another commit is
89 # dropped. Without reverted commits, we could get false positives
90 # because applying the patch succeeds, but simply results in no
92 test_expect_success
'setup of linear history for range selection tests' '
106 test_expect_
$result "rebase $* drops patches in upstream" "
109 test_cmp_rev h HEAD~2 &&
110 test_linear_range 'd i' h..
113 test_run_rebase success
''
114 test_run_rebase failure
-m
115 test_run_rebase success
-i
116 test_have_prereq
!REBASE_P || test_run_rebase success
-p
121 test_expect_
$result "rebase $* can drop last patch if in upstream" "
123 git rebase $* h gp &&
124 test_cmp_rev h HEAD^ &&
125 test_linear_range 'd' h..
128 test_run_rebase success
''
129 test_run_rebase failure
-m
130 test_run_rebase success
-i
131 test_have_prereq
!REBASE_P || test_run_rebase success
-p
136 test_expect_
$result "rebase $* --onto drops patches in upstream" "
138 git rebase $* --onto f h i &&
139 test_cmp_rev f HEAD~2 &&
140 test_linear_range 'd i' f..
143 test_run_rebase success
''
144 test_run_rebase failure
-m
145 test_run_rebase success
-i
146 test_have_prereq
!REBASE_P || test_run_rebase success
-p
151 test_expect_
$result "rebase $* --onto does not drop patches in onto" "
153 git rebase $* --onto h f i &&
154 test_cmp_rev h HEAD~3 &&
155 test_linear_range 'd gp i' h..
158 test_run_rebase success
''
159 test_run_rebase success
-m
160 test_run_rebase success
-i
161 test_have_prereq
!REBASE_P || test_run_rebase success
-p
168 test_expect_success
'setup of linear history for empty commit tests' '
179 test_expect_
$result "rebase $* drops empty commit" "
182 test_cmp_rev c HEAD~2 &&
183 test_linear_range 'd l' c..
186 test_run_rebase success
''
187 test_run_rebase success
-m
188 test_run_rebase success
-i
189 test_have_prereq
!REBASE_P || test_run_rebase success
-p
194 test_expect_
$result "rebase $* --keep-empty" "
196 git rebase $* --keep-empty c l &&
197 test_cmp_rev c HEAD~3 &&
198 test_linear_range 'd k l' c..
201 test_run_rebase success
''
202 test_run_rebase success
-m
203 test_run_rebase success
-i
204 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
209 test_expect_
$result "rebase $* --keep-empty keeps empty even if already in upstream" "
211 git rebase $* --keep-empty j l &&
212 test_cmp_rev j HEAD~3 &&
213 test_linear_range 'd k l' j..
216 test_run_rebase success
''
217 test_run_rebase success
-m
218 test_run_rebase success
-i
219 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
220 test_run_rebase success
--rebase-merges
228 # bp = cherry-picked b
231 # Reverted patches are there for tests to be able to check if a commit
232 # that introduced the same change as another commit is
233 # dropped. Without reverted commits, we could get false positives
234 # because applying the patch succeeds, but simply results in no
236 test_expect_success
'setup of linear history for test involving root' '
239 git checkout --orphan disjoint &&
249 test_expect_
$result "rebase $* --onto --root" "
251 git rebase $* --onto c --root y &&
252 test_cmp_rev c HEAD~2 &&
253 test_linear_range 'x y' c..
256 test_run_rebase success
''
257 test_run_rebase success
-m
258 test_run_rebase success
-i
259 test_have_prereq
!REBASE_P || test_run_rebase success
-p
264 test_expect_
$result "rebase $* without --onto --root with disjoint history" "
267 test_cmp_rev c HEAD~2 &&
268 test_linear_range 'x y' c..
271 test_run_rebase success
''
272 test_run_rebase success
-m
273 test_run_rebase success
-i
274 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
279 test_expect_
$result "rebase $* --onto --root drops patch in onto" "
281 git rebase $* --onto m --root bp &&
282 test_cmp_rev m HEAD~2 &&
283 test_linear_range 'x y' m..
286 test_run_rebase success
''
287 test_run_rebase failure
-m
288 test_run_rebase success
-i
289 test_have_prereq
!REBASE_P || test_run_rebase success
-p
294 test_expect_
$result "rebase $* --onto --root with merge-base does not go to root" "
296 git rebase $* --onto m --root g &&
297 test_cmp_rev m HEAD~2 &&
298 test_linear_range 'c g' m..
302 test_run_rebase success
''
303 test_run_rebase success
-m
304 test_run_rebase success
-i
305 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
310 test_expect_
$result "rebase $* without --onto --root with disjoint history drops patch in onto" "
312 git rebase $* m bp &&
313 test_cmp_rev m HEAD~2 &&
314 test_linear_range 'x y' m..
317 test_run_rebase success
''
318 test_run_rebase failure
-m
319 test_run_rebase success
-i
320 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
325 test_expect_
$result "rebase $* --root on linear history is a no-op" "
327 git rebase $* --root c &&
331 test_run_rebase success
''
332 test_run_rebase success
-m
333 test_run_rebase success
-i
334 test_have_prereq
!REBASE_P || test_run_rebase failure
-p
339 test_expect_
$result "rebase $* -f --root on linear history causes re-write" "
341 git rebase $* -f --root c &&
342 ! test_cmp_rev a HEAD~2 &&
343 test_linear_range 'a b c' HEAD
346 test_run_rebase success
''
347 test_run_rebase success
-m
348 test_run_rebase success
-i
349 test_have_prereq
!REBASE_P || test_run_rebase success
-p