Blame


1 2822a352 2019-10-15 stsp #!/bin/sh
2 2822a352 2019-10-15 stsp #
3 2822a352 2019-10-15 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 2822a352 2019-10-15 stsp #
5 2822a352 2019-10-15 stsp # Permission to use, copy, modify, and distribute this software for any
6 2822a352 2019-10-15 stsp # purpose with or without fee is hereby granted, provided that the above
7 2822a352 2019-10-15 stsp # copyright notice and this permission notice appear in all copies.
8 2822a352 2019-10-15 stsp #
9 2822a352 2019-10-15 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 2822a352 2019-10-15 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 2822a352 2019-10-15 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 2822a352 2019-10-15 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 2822a352 2019-10-15 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 2822a352 2019-10-15 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 2822a352 2019-10-15 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 2822a352 2019-10-15 stsp
17 2822a352 2019-10-15 stsp . ./common.sh
18 2822a352 2019-10-15 stsp
19 2822a352 2019-10-15 stsp function test_integrate_basic {
20 2822a352 2019-10-15 stsp local testroot=`test_init integrate_basic`
21 2822a352 2019-10-15 stsp
22 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q -b newbranch)
23 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
24 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
25 2822a352 2019-10-15 stsp
26 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
27 2822a352 2019-10-15 stsp (cd $testroot/repo && git rm -q beta)
28 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
29 2822a352 2019-10-15 stsp (cd $testroot/repo && git add epsilon/new)
30 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
31 2822a352 2019-10-15 stsp
32 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
33 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
34 2822a352 2019-10-15 stsp
35 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q master)
36 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
37 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
38 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
39 2822a352 2019-10-15 stsp
40 2822a352 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
41 2822a352 2019-10-15 stsp ret="$?"
42 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
43 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
44 2822a352 2019-10-15 stsp return 1
45 2822a352 2019-10-15 stsp fi
46 2822a352 2019-10-15 stsp
47 2822a352 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
48 2822a352 2019-10-15 stsp ret="$?"
49 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
50 2822a352 2019-10-15 stsp echo "got rebase failed unexpectedly"
51 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
52 2822a352 2019-10-15 stsp return 1
53 2822a352 2019-10-15 stsp fi
54 2822a352 2019-10-15 stsp
55 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q newbranch)
56 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
57 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
58 2822a352 2019-10-15 stsp
59 2822a352 2019-10-15 stsp (cd $testroot/wt && got update -b master > /dev/null)
60 2822a352 2019-10-15 stsp ret="$?"
61 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
62 2822a352 2019-10-15 stsp echo "got update failed unexpectedly"
63 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
64 2822a352 2019-10-15 stsp return 1
65 2822a352 2019-10-15 stsp fi
66 2822a352 2019-10-15 stsp
67 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch > $testroot/stdout)
68 2822a352 2019-10-15 stsp
69 2822a352 2019-10-15 stsp echo "U alpha" > $testroot/stdout.expected
70 2822a352 2019-10-15 stsp echo "D beta" >> $testroot/stdout.expected
71 2822a352 2019-10-15 stsp echo "A epsilon/new" >> $testroot/stdout.expected
72 2822a352 2019-10-15 stsp echo "U gamma/delta" >> $testroot/stdout.expected
73 2822a352 2019-10-15 stsp echo "Integrated refs/heads/newbranch into refs/heads/master" \
74 2822a352 2019-10-15 stsp >> $testroot/stdout.expected
75 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 2822a352 2019-10-15 stsp ret="$?"
77 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
78 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
80 2822a352 2019-10-15 stsp return 1
81 2822a352 2019-10-15 stsp fi
82 2822a352 2019-10-15 stsp
83 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/content.expected
84 2822a352 2019-10-15 stsp cat $testroot/wt/gamma/delta > $testroot/content
85 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
86 2822a352 2019-10-15 stsp ret="$?"
87 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
88 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
89 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
90 2822a352 2019-10-15 stsp return 1
91 2822a352 2019-10-15 stsp fi
92 2822a352 2019-10-15 stsp
93 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/content.expected
94 2822a352 2019-10-15 stsp cat $testroot/wt/alpha > $testroot/content
95 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
96 2822a352 2019-10-15 stsp ret="$?"
97 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
98 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
99 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
100 2822a352 2019-10-15 stsp return 1
101 2822a352 2019-10-15 stsp fi
102 2822a352 2019-10-15 stsp
103 2822a352 2019-10-15 stsp if [ -e $testroot/wt/beta ]; then
104 2822a352 2019-10-15 stsp echo "removed file beta still exists on disk" >&2
105 2822a352 2019-10-15 stsp test_done "$testroot" "1"
106 2822a352 2019-10-15 stsp return 1
107 2822a352 2019-10-15 stsp fi
108 2822a352 2019-10-15 stsp
109 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/content.expected
110 2822a352 2019-10-15 stsp cat $testroot/wt/epsilon/new > $testroot/content
111 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
112 2822a352 2019-10-15 stsp ret="$?"
113 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
114 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
115 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
116 2822a352 2019-10-15 stsp return 1
117 2822a352 2019-10-15 stsp fi
118 2822a352 2019-10-15 stsp
119 2822a352 2019-10-15 stsp (cd $testroot/wt && got status > $testroot/stdout)
120 2822a352 2019-10-15 stsp
121 2822a352 2019-10-15 stsp echo -n > $testroot/stdout.expected
122 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
123 2822a352 2019-10-15 stsp ret="$?"
124 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
125 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
126 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
127 2822a352 2019-10-15 stsp return 1
128 2822a352 2019-10-15 stsp fi
129 2822a352 2019-10-15 stsp
130 2822a352 2019-10-15 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
131 2822a352 2019-10-15 stsp echo "commit $new_commit2 (master, newbranch)" \
132 2822a352 2019-10-15 stsp > $testroot/stdout.expected
133 2822a352 2019-10-15 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
134 2822a352 2019-10-15 stsp echo "commit $master_commit" >> $testroot/stdout.expected
135 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
136 2822a352 2019-10-15 stsp ret="$?"
137 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
138 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 2822a352 2019-10-15 stsp fi
140 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
141 2822a352 2019-10-15 stsp }
142 2822a352 2019-10-15 stsp
143 2822a352 2019-10-15 stsp function test_integrate_requires_rebase_first {
144 2822a352 2019-10-15 stsp local testroot=`test_init integrate_requires_rebase_first`
145 2822a352 2019-10-15 stsp local init_commit=`git_show_head $testroot/repo`
146 2822a352 2019-10-15 stsp
147 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q -b newbranch)
148 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
149 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
150 2822a352 2019-10-15 stsp
151 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
152 2822a352 2019-10-15 stsp (cd $testroot/repo && git rm -q beta)
153 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
154 2822a352 2019-10-15 stsp (cd $testroot/repo && git add epsilon/new)
155 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
156 2822a352 2019-10-15 stsp
157 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
158 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
159 2822a352 2019-10-15 stsp
160 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q master)
161 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
162 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
163 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
164 2822a352 2019-10-15 stsp
165 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q newbranch)
166 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
167 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
168 2822a352 2019-10-15 stsp
169 2822a352 2019-10-15 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
170 2822a352 2019-10-15 stsp ret="$?"
171 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
172 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
173 2822a352 2019-10-15 stsp return 1
174 2822a352 2019-10-15 stsp fi
175 2822a352 2019-10-15 stsp
176 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch \
177 2822a352 2019-10-15 stsp > $testroot/stdout 2> $testroot/stderr)
178 2822a352 2019-10-15 stsp ret="$?"
179 2822a352 2019-10-15 stsp if [ "$ret" == "0" ]; then
180 2822a352 2019-10-15 stsp echo "got integrate succeeded unexpectedly"
181 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
182 2822a352 2019-10-15 stsp return 1
183 2822a352 2019-10-15 stsp fi
184 2822a352 2019-10-15 stsp
185 2822a352 2019-10-15 stsp echo -n > $testroot/stdout.expected
186 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 2822a352 2019-10-15 stsp ret="$?"
188 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
189 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
191 2822a352 2019-10-15 stsp return 1
192 2822a352 2019-10-15 stsp fi
193 2822a352 2019-10-15 stsp
194 2822a352 2019-10-15 stsp echo "got: specified branch must be rebased first" \
195 2822a352 2019-10-15 stsp > $testroot/stderr.expected
196 2822a352 2019-10-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
197 2822a352 2019-10-15 stsp ret="$?"
198 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
199 2822a352 2019-10-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
200 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
201 2822a352 2019-10-15 stsp return 1
202 2822a352 2019-10-15 stsp fi
203 2822a352 2019-10-15 stsp
204 2822a352 2019-10-15 stsp (cd $testroot/repo && got log -c master | \
205 2822a352 2019-10-15 stsp grep ^commit > $testroot/stdout)
206 2822a352 2019-10-15 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
207 2822a352 2019-10-15 stsp echo "commit $init_commit" >> $testroot/stdout.expected
208 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 2822a352 2019-10-15 stsp ret="$?"
210 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
211 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
213 2822a352 2019-10-15 stsp return 1
214 2822a352 2019-10-15 stsp fi
215 2822a352 2019-10-15 stsp
216 2822a352 2019-10-15 stsp (cd $testroot/repo && got log -c newbranch | \
217 2822a352 2019-10-15 stsp grep ^commit > $testroot/stdout)
218 2822a352 2019-10-15 stsp echo "commit $new_commit2 (newbranch)" \
219 2822a352 2019-10-15 stsp > $testroot/stdout.expected
220 2822a352 2019-10-15 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
221 2822a352 2019-10-15 stsp echo "commit $init_commit" >> $testroot/stdout.expected
222 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
223 8b692cd0 2019-10-21 stsp ret="$?"
224 8b692cd0 2019-10-21 stsp if [ "$ret" != "0" ]; then
225 8b692cd0 2019-10-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
226 8b692cd0 2019-10-21 stsp test_done "$testroot" "$ret"
227 8b692cd0 2019-10-21 stsp return 1
228 8b692cd0 2019-10-21 stsp fi
229 8b692cd0 2019-10-21 stsp
230 8b692cd0 2019-10-21 stsp (cd $testroot/repo && got branch -l > $testroot/stdout)
231 8b692cd0 2019-10-21 stsp ret="$?"
232 8b692cd0 2019-10-21 stsp if [ "$ret" != "0" ]; then
233 8b692cd0 2019-10-21 stsp echo "got rebase failed unexpectedly"
234 8b692cd0 2019-10-21 stsp test_done "$testroot" "$ret"
235 8b692cd0 2019-10-21 stsp return 1
236 8b692cd0 2019-10-21 stsp fi
237 8b692cd0 2019-10-21 stsp
238 8b692cd0 2019-10-21 stsp echo " master: $master_commit" > $testroot/stdout.expected
239 8b692cd0 2019-10-21 stsp echo " newbranch: $new_commit2" >> $testroot/stdout.expected
240 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
241 2822a352 2019-10-15 stsp ret="$?"
242 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
243 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
244 2822a352 2019-10-15 stsp fi
245 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
246 2822a352 2019-10-15 stsp }
247 2822a352 2019-10-15 stsp
248 2822a352 2019-10-15 stsp function test_integrate_path_prefix {
249 2822a352 2019-10-15 stsp local testroot=`test_init integrate_path_prefix`
250 2822a352 2019-10-15 stsp
251 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q -b newbranch)
252 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
253 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
254 2822a352 2019-10-15 stsp
255 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
256 2822a352 2019-10-15 stsp (cd $testroot/repo && git rm -q beta)
257 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
258 2822a352 2019-10-15 stsp (cd $testroot/repo && git add epsilon/new)
259 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
260 2822a352 2019-10-15 stsp
261 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
262 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
263 2822a352 2019-10-15 stsp
264 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q master)
265 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
266 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
267 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
268 2822a352 2019-10-15 stsp
269 2822a352 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
270 2822a352 2019-10-15 stsp ret="$?"
271 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
272 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
273 2822a352 2019-10-15 stsp return 1
274 2822a352 2019-10-15 stsp fi
275 2822a352 2019-10-15 stsp
276 2822a352 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
277 2822a352 2019-10-15 stsp ret="$?"
278 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
279 2822a352 2019-10-15 stsp echo "got rebase failed unexpectedly"
280 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
281 2822a352 2019-10-15 stsp return 1
282 2822a352 2019-10-15 stsp fi
283 2822a352 2019-10-15 stsp
284 2822a352 2019-10-15 stsp (cd $testroot/repo && git checkout -q newbranch)
285 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
286 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
287 2822a352 2019-10-15 stsp
288 2822a352 2019-10-15 stsp rm -r $testroot/wt
289 2822a352 2019-10-15 stsp got checkout -b master -p epsilon $testroot/repo $testroot/wt \
290 2822a352 2019-10-15 stsp > /dev/null
291 2822a352 2019-10-15 stsp ret="$?"
292 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
293 2822a352 2019-10-15 stsp echo "got checkout failed unexpectedly"
294 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
295 2822a352 2019-10-15 stsp return 1
296 2822a352 2019-10-15 stsp fi
297 2822a352 2019-10-15 stsp
298 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch > $testroot/stdout)
299 2822a352 2019-10-15 stsp
300 2822a352 2019-10-15 stsp echo "A new" > $testroot/stdout.expected
301 2822a352 2019-10-15 stsp echo "Integrated refs/heads/newbranch into refs/heads/master" \
302 2822a352 2019-10-15 stsp >> $testroot/stdout.expected
303 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
304 2822a352 2019-10-15 stsp ret="$?"
305 2822a352 2019-10-15 stsp if [ "$ret" != "0" ]; then
306 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
307 2822a352 2019-10-15 stsp fi
308 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
309 2822a352 2019-10-15 stsp }
310 3aef623b 2019-10-15 stsp
311 3aef623b 2019-10-15 stsp function test_integrate_backwards_in_time {
312 3aef623b 2019-10-15 stsp local testroot=`test_init integrate_backwards_in_time`
313 3aef623b 2019-10-15 stsp
314 3aef623b 2019-10-15 stsp (cd $testroot/repo && git checkout -q -b newbranch)
315 3aef623b 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
316 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
317 3aef623b 2019-10-15 stsp
318 3aef623b 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
319 3aef623b 2019-10-15 stsp (cd $testroot/repo && git rm -q beta)
320 3aef623b 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
321 3aef623b 2019-10-15 stsp (cd $testroot/repo && git add epsilon/new)
322 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
323 3aef623b 2019-10-15 stsp
324 3aef623b 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
325 3aef623b 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
326 3aef623b 2019-10-15 stsp
327 3aef623b 2019-10-15 stsp (cd $testroot/repo && git checkout -q master)
328 3aef623b 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
329 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
330 3aef623b 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
331 2822a352 2019-10-15 stsp
332 3aef623b 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
333 3aef623b 2019-10-15 stsp ret="$?"
334 3aef623b 2019-10-15 stsp if [ "$ret" != "0" ]; then
335 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
336 3aef623b 2019-10-15 stsp return 1
337 3aef623b 2019-10-15 stsp fi
338 2822a352 2019-10-15 stsp
339 3aef623b 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
340 3aef623b 2019-10-15 stsp ret="$?"
341 3aef623b 2019-10-15 stsp if [ "$ret" != "0" ]; then
342 3aef623b 2019-10-15 stsp echo "got rebase failed unexpectedly"
343 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
344 3aef623b 2019-10-15 stsp return 1
345 3aef623b 2019-10-15 stsp fi
346 3aef623b 2019-10-15 stsp
347 3aef623b 2019-10-15 stsp (cd $testroot/repo && git checkout -q newbranch)
348 3aef623b 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
349 3aef623b 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
350 3aef623b 2019-10-15 stsp
351 3aef623b 2019-10-15 stsp # attempt to integrate master into newbranch (wrong way around)
352 3aef623b 2019-10-15 stsp (cd $testroot/wt && got update -b newbranch > /dev/null)
353 3aef623b 2019-10-15 stsp ret="$?"
354 3aef623b 2019-10-15 stsp if [ "$ret" != "0" ]; then
355 3aef623b 2019-10-15 stsp echo "got update failed unexpectedly"
356 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
357 3aef623b 2019-10-15 stsp return 1
358 3aef623b 2019-10-15 stsp fi
359 3aef623b 2019-10-15 stsp
360 3aef623b 2019-10-15 stsp (cd $testroot/wt && got integrate master \
361 3aef623b 2019-10-15 stsp > $testroot/stdout 2> $testroot/stderr)
362 3aef623b 2019-10-15 stsp ret="$?"
363 3aef623b 2019-10-15 stsp if [ "$ret" == "0" ]; then
364 3aef623b 2019-10-15 stsp echo "got integrate succeeded unexpectedly"
365 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
366 3aef623b 2019-10-15 stsp return 1
367 3aef623b 2019-10-15 stsp fi
368 3aef623b 2019-10-15 stsp
369 3aef623b 2019-10-15 stsp echo -n > $testroot/stdout.expected
370 3aef623b 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
371 3aef623b 2019-10-15 stsp ret="$?"
372 3aef623b 2019-10-15 stsp if [ "$ret" != "0" ]; then
373 3aef623b 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
374 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
375 3aef623b 2019-10-15 stsp return 1
376 3aef623b 2019-10-15 stsp fi
377 3aef623b 2019-10-15 stsp
378 3aef623b 2019-10-15 stsp echo "got: specified branch must be rebased first" \
379 3aef623b 2019-10-15 stsp > $testroot/stderr.expected
380 3aef623b 2019-10-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
381 3aef623b 2019-10-15 stsp ret="$?"
382 3aef623b 2019-10-15 stsp if [ "$ret" != "0" ]; then
383 3aef623b 2019-10-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
384 3aef623b 2019-10-15 stsp fi
385 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
386 3aef623b 2019-10-15 stsp }
387 3aef623b 2019-10-15 stsp
388 2822a352 2019-10-15 stsp run_test test_integrate_basic
389 2822a352 2019-10-15 stsp run_test test_integrate_requires_rebase_first
390 2822a352 2019-10-15 stsp run_test test_integrate_path_prefix
391 3aef623b 2019-10-15 stsp run_test test_integrate_backwards_in_time