3 f259c4c1 2021-09-24 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 f259c4c1 2021-09-24 stsp # Permission to use, copy, modify, and distribute this software for any
6 f259c4c1 2021-09-24 stsp # purpose with or without fee is hereby granted, provided that the above
7 f259c4c1 2021-09-24 stsp # copyright notice and this permission notice appear in all copies.
9 f259c4c1 2021-09-24 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f259c4c1 2021-09-24 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f259c4c1 2021-09-24 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f259c4c1 2021-09-24 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f259c4c1 2021-09-24 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f259c4c1 2021-09-24 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f259c4c1 2021-09-24 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 f259c4c1 2021-09-24 stsp . ./common.sh
19 f259c4c1 2021-09-24 stsp test_merge_basic() {
20 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_basic`
21 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
22 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
24 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
27 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
29 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
30 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
31 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
32 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
33 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
34 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
35 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
36 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
37 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
38 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
39 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
40 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
41 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
42 5267b9e4 2021-09-26 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
43 5267b9e4 2021-09-26 stsp (cd $testroot/repo && git add dotgotbar.link)
44 5267b9e4 2021-09-26 stsp git_commit $testroot/repo -m "adding a bad symlink on newbranch"
45 5267b9e4 2021-09-26 stsp local branch_commit5=`git_show_branch_head $testroot/repo newbranch`
47 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
49 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
50 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
51 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
55 f259c4c1 2021-09-24 stsp # need a divergant commit on the main branch for 'got merge'
56 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
57 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
59 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
60 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
61 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
64 f259c4c1 2021-09-24 stsp echo -n "got: cannot create a merge commit because " \
65 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
66 f259c4c1 2021-09-24 stsp echo -n "refs/heads/newbranch is based on refs/heads/master; " \
67 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
68 f259c4c1 2021-09-24 stsp echo -n "refs/heads/newbranch can be integrated with " \
69 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
70 f259c4c1 2021-09-24 stsp echo "'got integrate' instead" >> $testroot/stderr.expected
71 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
73 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
74 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
75 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
79 f259c4c1 2021-09-24 stsp # create the required dirvergant commit
80 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
81 f259c4c1 2021-09-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
82 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
83 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
85 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
86 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
87 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
89 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
90 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
91 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
94 f259c4c1 2021-09-24 stsp echo -n "got: work tree must be updated before it can be used " \
95 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
96 f259c4c1 2021-09-24 stsp echo "to merge a branch" >> $testroot/stderr.expected
97 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
99 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
100 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
101 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
105 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
107 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
108 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
109 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
113 f259c4c1 2021-09-24 stsp # must not use a mixed-commit work tree with 'got merge'
114 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
116 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
117 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
118 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
121 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
122 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
124 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
125 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
126 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
129 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains files from multiple base commits; " \
130 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
131 f259c4c1 2021-09-24 stsp echo "the entire work tree must be updated first" \
132 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
133 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
135 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
136 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
137 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
141 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
143 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
144 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
145 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
149 f259c4c1 2021-09-24 stsp # must not have staged files with 'got merge'
150 f259c4c1 2021-09-24 stsp echo "modified file alpha" > $testroot/wt/alpha
151 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got stage alpha > /dev/null)
153 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
154 f259c4c1 2021-09-24 stsp echo "got stage failed unexpectedly" >&2
155 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
158 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
159 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
161 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
162 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
163 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
166 f259c4c1 2021-09-24 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
167 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
169 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
170 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
171 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
174 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
176 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
177 f259c4c1 2021-09-24 stsp echo "got unstage failed unexpectedly" >&2
178 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
182 f259c4c1 2021-09-24 stsp # must not have local changes with 'got merge'
183 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
184 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
186 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
187 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
188 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
191 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains local changes; " \
192 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
193 f259c4c1 2021-09-24 stsp echo "these changes must be committed or reverted first" \
194 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
195 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
197 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
198 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
199 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
203 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
205 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
206 f259c4c1 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
207 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
211 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch > $testroot/stdout)
213 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
214 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
215 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
219 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
221 f259c4c1 2021-09-24 stsp echo "G alpha" >> $testroot/stdout.expected
222 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
223 5267b9e4 2021-09-26 stsp echo "A dotgotbar.link" >> $testroot/stdout.expected
224 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
225 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
226 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
227 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
228 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
229 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
231 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
233 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
234 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
235 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
239 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
240 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
241 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
243 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
244 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
245 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
249 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/content.expected
250 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
251 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
253 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
254 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
255 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
259 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
260 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
261 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
265 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
266 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
267 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
269 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
270 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
271 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
275 5267b9e4 2021-09-26 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
276 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is not a symlink"
277 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
281 f259c4c1 2021-09-24 stsp readlink $testroot/wt/symlink > $testroot/stdout
282 f259c4c1 2021-09-24 stsp echo "alpha" > $testroot/stdout.expected
283 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
285 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
286 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
291 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
293 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
294 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
296 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
297 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
298 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
302 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
303 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
304 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
305 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
306 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
308 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
309 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
310 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
314 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
316 5267b9e4 2021-09-26 stsp echo 'U dotgotbar.link' > $testroot/stdout.expected
317 5267b9e4 2021-09-26 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
318 5267b9e4 2021-09-26 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
319 5267b9e4 2021-09-26 stsp echo >> $testroot/stdout.expected
320 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
322 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
323 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
324 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
328 5267b9e4 2021-09-26 stsp # update has changed the bad symlink into a regular file
329 5267b9e4 2021-09-26 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
330 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is a symlink"
331 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
335 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
336 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
337 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
338 5267b9e4 2021-09-26 stsp echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
339 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
341 5267b9e4 2021-09-26 stsp if [ "$ret" != "0" ]; then
342 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
343 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
347 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
349 5267b9e4 2021-09-26 stsp if [ "$ret" != "0" ]; then
350 5267b9e4 2021-09-26 stsp echo "got tree failed unexpectedly" >&2
351 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
355 5267b9e4 2021-09-26 stsp # bad symlink dotgotbar.link appears as a symlink in the merge commit:
356 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
358 5267b9e4 2021-09-26 stsp dotgotbar.link@ -> .got/bar
360 5267b9e4 2021-09-26 stsp epsilon/new
361 5267b9e4 2021-09-26 stsp epsilon/zeta
363 5267b9e4 2021-09-26 stsp gamma/delta
364 5267b9e4 2021-09-26 stsp symlink@ -> alpha
366 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
368 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
369 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
371 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
374 f259c4c1 2021-09-24 stsp test_merge_continue() {
375 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
376 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
377 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
379 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
380 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
381 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
382 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
384 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
385 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
386 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
387 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
388 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
389 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
390 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
391 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
392 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
393 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
395 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
397 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
398 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
399 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
403 f259c4c1 2021-09-24 stsp # create a conflicting commit
404 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
405 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
406 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
407 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
409 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
410 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
412 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
413 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
414 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
418 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
419 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
421 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
422 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
423 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
427 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
428 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
429 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
430 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
431 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
432 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
434 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
435 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
436 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
440 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
441 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
442 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
444 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
445 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
446 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
450 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
452 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
453 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
454 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
455 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
456 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
458 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
459 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
460 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
464 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
465 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
466 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
467 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
468 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
469 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
470 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
471 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
472 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
473 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
474 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
476 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
477 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
478 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
482 f259c4c1 2021-09-24 stsp # resolve the conflict
483 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
485 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
487 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
488 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
489 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
493 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
495 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
496 f259c4c1 2021-09-24 stsp > $testroot/stdout.expected
497 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
499 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
501 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
502 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
503 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
507 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
508 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
509 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
511 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
512 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
513 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
517 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
518 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
519 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
521 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
522 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
523 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
527 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
528 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
529 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
533 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
534 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
535 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
537 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
538 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
539 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
543 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
545 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
546 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
548 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
549 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
550 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
554 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
555 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
556 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
557 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
558 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
560 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
561 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
562 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
566 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
568 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
569 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
571 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
572 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
573 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
577 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
578 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
579 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
580 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
581 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
583 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
584 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
586 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
589 f259c4c1 2021-09-24 stsp test_merge_abort() {
590 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
591 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
592 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
594 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
595 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
596 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
597 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
599 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
600 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
601 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
602 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
603 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
604 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
605 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
606 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
607 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
608 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
609 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
610 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
611 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
613 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
615 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
616 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
617 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
621 f259c4c1 2021-09-24 stsp # create a conflicting commit
622 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
623 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
624 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
625 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
627 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
628 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
630 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
631 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
632 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
636 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
637 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
639 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
640 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
641 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
645 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
646 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
647 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
648 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
649 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
650 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
651 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
653 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
654 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
655 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
659 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
660 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
661 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
663 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
664 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
665 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
669 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
671 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
672 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
673 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
674 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
675 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
676 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
678 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
679 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
680 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
684 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
686 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
687 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
688 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
692 f259c4c1 2021-09-24 stsp echo "R alpha" > $testroot/stdout.expected
693 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
694 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
695 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
696 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
697 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
698 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
700 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
702 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
703 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
704 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
708 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
709 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
710 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
712 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
713 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
714 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
718 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
719 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
720 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
722 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
723 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
724 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
728 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
729 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
730 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
732 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
733 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
734 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
738 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
739 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
740 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
744 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
745 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
746 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
750 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
752 f259c4c1 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
753 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
755 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
756 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
761 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
762 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
763 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
764 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
766 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
767 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
768 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
772 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
774 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
775 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
777 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
778 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
783 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
784 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
785 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
786 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
788 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
789 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
790 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
791 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
793 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
795 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
796 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
797 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
801 f259c4c1 2021-09-24 stsp # create a conflicting commit
802 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
803 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
804 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
805 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
807 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
808 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
810 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
811 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
812 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
816 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
817 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
819 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
820 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
821 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
825 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
826 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
827 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
829 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
830 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
835 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
836 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
837 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
839 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
840 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
841 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
845 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
847 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
848 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
850 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
851 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
856 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
857 f259c4c1 2021-09-24 stsp "integrate newbranch" "stage alpha"; do
858 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
859 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
861 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
862 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
864 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
865 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
866 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
870 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
871 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
872 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
873 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
874 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
876 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
877 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
878 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
883 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
886 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
887 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
888 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
889 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
891 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
892 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
893 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
894 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
896 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
897 f259c4c1 2021-09-24 stsp > /dev/null
899 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
900 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
901 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
905 f259c4c1 2021-09-24 stsp # create a conflicting commit
906 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
907 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
908 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
909 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
911 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
912 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
914 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
915 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
916 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
920 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
921 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
923 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
924 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
925 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
929 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
930 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
931 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
932 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
934 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
935 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
937 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
940 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
941 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
942 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
943 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
945 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
946 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
947 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
948 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
949 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
951 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
953 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
954 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
955 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
959 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
960 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
961 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
962 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
963 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
965 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
966 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
968 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
969 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
970 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
974 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
975 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
977 f259c4c1 2021-09-24 stsp if [ "$ret" == "0" ]; then
978 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
979 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
983 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
984 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
985 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
987 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
988 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
989 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
993 1acd48bc 2021-09-24 stsp echo -n "got: changes destined for missing files " \
994 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
995 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
996 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
997 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
998 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
999 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1001 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
1002 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1003 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1007 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1009 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1010 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1012 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1013 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1014 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1018 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1021 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1022 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1023 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1024 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1026 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1027 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1028 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1029 a6a8f8bb 2021-09-24 stsp local branch_commitk=`git_show_branch_head $testroot/repo newbranch`
1031 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1033 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1034 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1035 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1039 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1040 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1041 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1042 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1043 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1045 a6a8f8bb 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
1046 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1048 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1049 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1050 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1054 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1055 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1057 a6a8f8bb 2021-09-24 stsp if [ "$ret" == "0" ]; then
1058 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1059 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1063 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1064 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1065 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1067 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1068 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1069 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1073 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1074 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1075 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1077 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1078 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1079 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1083 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1085 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1086 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1088 f259c4c1 2021-09-24 stsp if [ "$ret" != "0" ]; then
1089 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1090 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1094 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1095 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1097 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1098 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1099 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1103 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1104 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1106 a6a8f8bb 2021-09-24 stsp if [ "$ret" == "0" ]; then
1107 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1108 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1112 a6a8f8bb 2021-09-24 stsp echo -n "got: merge of refs/heads/newbranch cannot proceed: " \
1113 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1114 a6a8f8bb 2021-09-24 stsp echo "no changes to commit" >> $testroot/stderr.expected
1115 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1117 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1118 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1119 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1123 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1125 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1126 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1128 a6a8f8bb 2021-09-24 stsp if [ "$ret" != "0" ]; then
1129 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1131 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1134 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1135 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1136 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1137 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1138 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1139 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1140 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1141 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op