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 if ! test_have_prereq REBASE_P
; then
113 skip_all
='skipping git rebase -p tests, as asked for'
117 test_expect_success
"rebase -p is no-op in non-linear history" "
123 test_expect_success
"rebase -p is no-op when base inside second parent" "
129 test_expect_failure
"rebase -p --root on non-linear history is a no-op" "
131 git rebase -p --root w &&
135 test_expect_success
"rebase -p re-creates merge from side branch" "
138 test_cmp_rev z HEAD^ &&
139 test_cmp_rev w^2 HEAD^2
142 test_expect_success
"rebase -p re-creates internal merge" "
145 test_cmp_rev c HEAD~4 &&
146 test_cmp_rev HEAD^2^ HEAD~3 &&
147 test_revision_subjects 'd n e o w' HEAD~3 HEAD~2 HEAD^2 HEAD^ HEAD
150 test_expect_success
"rebase -p can re-create two branches on onto" "
152 git rebase -p --onto c d w &&
153 test_cmp_rev c HEAD~3 &&
154 test_cmp_rev c HEAD^2^ &&
155 test_revision_subjects 'n e o w' HEAD~2 HEAD^2 HEAD^ HEAD
166 # gp = cherry-picked g
168 test_expect_success
'setup of non-linear-history for patch-equivalence tests' '
173 test_expect_success
"rebase -p re-creates history around dropped commit matching upstream" "
176 test_cmp_rev h HEAD~3 &&
177 test_cmp_rev HEAD^2^ HEAD~2 &&
178 test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
181 test_expect_success
"rebase -p --onto in merged history drops patches in upstream" "
183 git rebase -p --onto f h u &&
184 test_cmp_rev f HEAD~3 &&
185 test_cmp_rev HEAD^2^ HEAD~2 &&
186 test_revision_subjects 'd i e u' HEAD~2 HEAD^2 HEAD^ HEAD
189 test_expect_success
"rebase -p --onto in merged history does not drop patches in onto" "
191 git rebase -p --onto h f u &&
192 test_cmp_rev h HEAD~3 &&
193 test_cmp_rev HEAD^2~2 HEAD~2 &&
194 test_revision_subjects 'd gp i e u' HEAD~2 HEAD^2^ HEAD^2 HEAD^ HEAD
205 # gp = cherry-picked g
207 test_expect_success
'setup of non-linear-history for dropping whole side' '
214 test_expect_failure
"rebase -p drops merge commit when entire first-parent side is dropped" "
217 test_cmp_rev h HEAD~2 &&
218 test_linear_range 'd e' h..
221 test_expect_success
"rebase -p drops merge commit when entire second-parent side is dropped" "
224 test_cmp_rev h HEAD~2 &&
225 test_linear_range 'd e' h..
236 # r = tree-same with n
237 test_expect_success
'setup of non-linear-history for empty commits' '
239 git merge --no-commit e &&
247 test_expect_success
"rebase -p re-creates empty internal merge commit" "
250 test_cmp_rev c HEAD~3 &&
251 test_cmp_rev HEAD^2^ HEAD~2 &&
252 test_revision_subjects 'd e n r' HEAD~2 HEAD^2 HEAD^ HEAD
255 test_expect_success
"rebase -p re-creates empty merge commit" "
258 test_cmp_rev e HEAD^2 &&
259 test_cmp_rev o HEAD^ &&
260 test_revision_subjects 'r' HEAD