3 test_description
='rebase topology tests with merges'
5 .
"$TEST_DIRECTORY"/lib-rebase.sh
7 test_revision_subjects
() {
10 set -- $
(git log
--format=%s
--no-walk=unsorted
"$@")
11 test "$expected" = "$*"
21 test_expect_success
'setup of non-linear-history' '
50 test_expect_
$result "rebase $* after merge from upstream" "
53 test_cmp_rev e HEAD~2 &&
54 test_linear_range 'n o' e..
57 test_run_rebase success
''
58 test_run_rebase success
-m
59 test_run_rebase success
-i
66 test_expect_
$result "rebase $* of non-linear history is linearized in place" "
69 test_cmp_rev d HEAD~3 &&
70 test_linear_range "\'"$expected"\'" d..
73 #TODO: make order consistent across all flavors of rebase
74 test_run_rebase success
'e n o' ''
75 test_run_rebase success
'e n o' -m
76 test_run_rebase success
'n o e' -i
83 test_expect_
$result "rebase $* of non-linear history is linearized upstream" "
86 test_cmp_rev c HEAD~4 &&
87 test_linear_range "\'"$expected"\'" c..
90 #TODO: make order consistent across all flavors of rebase
91 test_run_rebase success
'd e n o' ''
92 test_run_rebase success
'd e n o' -m
93 test_run_rebase success
'd n o e' -i
100 test_expect_
$result "rebase $* of non-linear history with merges after upstream merge is linearized" "
103 test_cmp_rev c HEAD~4 &&
104 test_linear_range "\'"$expected"\'" c..
107 #TODO: make order consistent across all flavors of rebase
108 test_run_rebase success
'd e n o' ''
109 test_run_rebase success
'd e n o' -m
110 test_run_rebase success
'd n o e' -i
112 test_expect_success
"rebase -p is no-op in non-linear history" "
118 test_expect_success
"rebase -p is no-op when base inside second parent" "
124 test_expect_failure
"rebase -p --root on non-linear history is a no-op" "
126 git rebase -p --root w &&
130 test_expect_success
"rebase -p re-creates merge from side branch" "
133 test_cmp_rev z HEAD^ &&
134 test_cmp_rev w^2 HEAD^2
137 test_expect_success
"rebase -p re-creates internal merge" "
140 test_cmp_rev c HEAD~4 &&
141 test_cmp_rev HEAD^2^ HEAD~3 &&
142 test_revision_subjects 'd n e o w' HEAD~3 HEAD~2 HEAD^2 HEAD^ HEAD
145 test_expect_success
"rebase -p can re-create two branches on onto" "
147 git rebase -p --onto c d w &&
148 test_cmp_rev c HEAD~3 &&
149 test_cmp_rev c HEAD^2^ &&
150 test_revision_subjects 'n e o w' HEAD~2 HEAD^2 HEAD^ HEAD
161 # gp = cherry-picked g
163 test_expect_success
'setup of non-linear-history for patch-equivalence tests' '
168 test_expect_success
"rebase -p re-creates history around dropped commit matching upstream" "
171 test_cmp_rev h HEAD~3 &&
172 test_cmp_rev HEAD^2^ HEAD~2 &&
173 test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
176 test_expect_success
"rebase -p --onto in merged history drops patches in upstream" "
178 git rebase -p --onto f h u &&
179 test_cmp_rev f HEAD~3 &&
180 test_cmp_rev HEAD^2^ HEAD~2 &&
181 test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
184 test_expect_success
"rebase -p --onto in merged history does not drop patches in onto" "
186 git rebase -p --onto h f u &&
187 test_cmp_rev h HEAD~3 &&
188 test_cmp_rev HEAD^2~2 HEAD~2 &&
189 test_revision_subjects 'd gp i e u' HEAD~2 HEAD^2^ HEAD^2 HEAD^ HEAD
200 # gp = cherry-picked g
202 test_expect_success
'setup of non-linear-history for dropping whole side' '
209 test_expect_failure
"rebase -p drops merge commit when entire first-parent side is dropped" "
212 test_cmp_rev h HEAD~2 &&
213 test_linear_range 'd e' h..
216 test_expect_success
"rebase -p drops merge commit when entire second-parent side is dropped" "
219 test_cmp_rev h HEAD~2 &&
220 test_linear_range 'd e' h..
231 # r = tree-same with n
232 test_expect_success
'setup of non-linear-history for empty commits' '
234 git merge --no-commit e &&
242 test_expect_success
"rebase -p re-creates empty internal merge commit" "
245 test_cmp_rev c HEAD~3 &&
246 test_cmp_rev HEAD^2^ HEAD~2 &&
247 test_revision_subjects 'd e n r' HEAD~2 HEAD^2 HEAD^ HEAD
250 test_expect_success
"rebase -p re-creates empty merge commit" "
253 test_cmp_rev e HEAD^2 &&
254 test_cmp_rev o HEAD^ &&
255 test_revision_subjects 'r' HEAD