t800[12]: work around MSys limitation
[git/git-svn.git] / t / t3425-rebase-topology-merges.sh
blob1d195fbd64cc9d6de3f94e69e4fbe9b97be38089
1 #!/bin/sh
3 test_description='rebase topology tests with merges'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-rebase.sh
7 test_revision_subjects () {
8 expected="$1"
9 shift
10 set -- $(git log --format=%s --no-walk=unsorted "$@")
11 test "$expected" = "$*"
14 # a---b-----------c
15 # \ \
16 # d-------e \
17 # \ \ \
18 # n---o---w---v
19 # \
20 # z
21 test_expect_success 'setup of non-linear-history' '
22 test_commit a &&
23 test_commit b &&
24 test_commit c &&
25 git checkout b &&
26 test_commit d &&
27 test_commit e
29 git checkout c &&
30 test_commit g &&
31 revert h g &&
32 git checkout d &&
33 cherry_pick gp g &&
34 test_commit i &&
35 git checkout b &&
36 test_commit f
38 git checkout d &&
39 test_commit n &&
40 test_commit o &&
41 test_merge w e &&
42 test_merge v c &&
43 git checkout o &&
44 test_commit z
47 test_run_rebase () {
48 result=$1
49 shift
50 test_expect_$result "rebase $* after merge from upstream" "
51 reset_rebase &&
52 git rebase $* e w &&
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
61 test_run_rebase () {
62 result=$1
63 shift
64 expected=$1
65 shift
66 test_expect_$result "rebase $* of non-linear history is linearized in place" "
67 reset_rebase &&
68 git rebase $* d w &&
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
78 test_run_rebase () {
79 result=$1
80 shift
81 expected=$1
82 shift
83 test_expect_$result "rebase $* of non-linear history is linearized upstream" "
84 reset_rebase &&
85 git rebase $* c w &&
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
95 test_run_rebase () {
96 result=$1
97 shift
98 expected=$1
99 shift
100 test_expect_$result "rebase $* of non-linear history with merges after upstream merge is linearized" "
101 reset_rebase &&
102 git rebase $* c v &&
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" "
113 reset_rebase &&
114 git rebase -p d w &&
115 test_cmp_rev w HEAD
118 test_expect_success "rebase -p is no-op when base inside second parent" "
119 reset_rebase &&
120 git rebase -p e w &&
121 test_cmp_rev w HEAD
124 test_expect_failure "rebase -p --root on non-linear history is a no-op" "
125 reset_rebase &&
126 git rebase -p --root w &&
127 test_cmp_rev w HEAD
130 test_expect_success "rebase -p re-creates merge from side branch" "
131 reset_rebase &&
132 git rebase -p z w &&
133 test_cmp_rev z HEAD^ &&
134 test_cmp_rev w^2 HEAD^2
137 test_expect_success "rebase -p re-creates internal merge" "
138 reset_rebase &&
139 git rebase -p c w &&
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" "
146 reset_rebase &&
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
155 # a---b---c---g---h
157 # d---gp--i
158 # \ \
159 # e-------u
161 # gp = cherry-picked g
162 # h = reverted g
163 test_expect_success 'setup of non-linear-history for patch-equivalence tests' '
164 git checkout e &&
165 test_merge u i
168 test_expect_success "rebase -p re-creates history around dropped commit matching upstream" "
169 reset_rebase &&
170 git rebase -p h u &&
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" "
177 reset_rebase &&
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" "
185 reset_rebase &&
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
192 # a---b---c---g---h
194 # d---gp--s
195 # \ \ /
196 # \ X
197 # \ / \
198 # e---t
200 # gp = cherry-picked g
201 # h = reverted g
202 test_expect_success 'setup of non-linear-history for dropping whole side' '
203 git checkout gp &&
204 test_merge s e &&
205 git checkout e &&
206 test_merge t gp
209 test_expect_failure "rebase -p drops merge commit when entire first-parent side is dropped" "
210 reset_rebase &&
211 git rebase -p h s &&
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" "
217 reset_rebase &&
218 git rebase -p h t &&
219 test_cmp_rev h HEAD~2 &&
220 test_linear_range 'd e' h..
223 # a---b---c
225 # d---e
226 # \ \
227 # n---r
231 # r = tree-same with n
232 test_expect_success 'setup of non-linear-history for empty commits' '
233 git checkout n &&
234 git merge --no-commit e &&
235 git reset n . &&
236 git commit -m r &&
237 git reset --hard &&
238 git clean -f &&
239 git tag r
242 test_expect_success "rebase -p re-creates empty internal merge commit" "
243 reset_rebase &&
244 git rebase -p c r &&
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" "
251 reset_rebase &&
252 git rebase -p o r &&
253 test_cmp_rev e HEAD^2 &&
254 test_cmp_rev o HEAD^ &&
255 test_revision_subjects 'r' HEAD
258 test_done