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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
496 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
497 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
498 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
499 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
500 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
501 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
503 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
505 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
506 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
507 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
511 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
512 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
513 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
515 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
516 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
517 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
521 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
522 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
523 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
527 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
531 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
532 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
533 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
537 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
538 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
539 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
542 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
543 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
547 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
549 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
550 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
552 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
553 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
558 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
559 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
560 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
561 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
562 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
564 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
565 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
566 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
570 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
572 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
573 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
575 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
576 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
581 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
582 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
583 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
584 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
585 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
587 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
588 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
590 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
593 f259c4c1 2021-09-24 stsp test_merge_abort() {
594 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
595 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
596 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
598 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
599 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
600 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
601 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
603 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
604 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
605 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
606 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
607 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
608 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
609 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
610 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
611 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
612 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
613 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
614 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
615 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
617 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
619 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
620 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
621 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
625 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
626 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
628 f259c4c1 2021-09-24 stsp # create a conflicting commit
629 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
630 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
631 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
632 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
634 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
635 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
637 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
638 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
639 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
643 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
644 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
646 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
647 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
648 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
652 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
653 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
654 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
655 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
656 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
657 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
658 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
660 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
661 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
662 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
666 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
667 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
668 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
670 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
671 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
672 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
676 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
678 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
679 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
680 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
681 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
682 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
683 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
684 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
686 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
687 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
688 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
692 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
694 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
695 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
696 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
700 f259c4c1 2021-09-24 stsp echo "R alpha" > $testroot/stdout.expected
701 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
702 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
703 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
704 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
705 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
706 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
708 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
710 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
711 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
712 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
716 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
717 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
718 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
720 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
721 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
722 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
726 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
727 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
728 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
730 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
731 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
732 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
736 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
737 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
738 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
740 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
741 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
742 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
746 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
747 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
748 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
752 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
753 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
754 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
758 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
760 41f061b2 2021-10-05 stsp echo "? unversioned-file" > $testroot/stdout.expected
761 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
763 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
764 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
765 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
769 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
770 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
771 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
772 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
774 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
775 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
776 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
780 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
782 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
783 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
785 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
786 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
788 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
791 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
792 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
793 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
794 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
796 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
797 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
798 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
799 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
801 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
803 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
804 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
805 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
809 f259c4c1 2021-09-24 stsp # create a conflicting commit
810 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
811 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
812 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
813 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
815 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
816 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
818 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
819 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
820 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
824 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
825 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
827 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
828 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
829 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
833 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
834 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
835 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
837 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
838 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
839 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
843 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
844 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
845 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
847 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
848 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
849 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
853 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
855 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
856 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
858 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
859 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
860 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
864 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
865 f259c4c1 2021-09-24 stsp "integrate newbranch" "stage alpha"; do
866 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
867 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
869 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
870 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
872 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
873 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
874 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
878 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
879 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
880 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
881 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
882 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
884 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
885 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
886 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
891 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
894 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
895 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
896 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
897 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
899 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
900 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
901 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
902 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
904 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
905 f259c4c1 2021-09-24 stsp > /dev/null
907 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
908 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
909 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
913 f259c4c1 2021-09-24 stsp # create a conflicting commit
914 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
915 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
916 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
917 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
919 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
920 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
922 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
923 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
924 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
928 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
929 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
931 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
932 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
933 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
937 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
938 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
939 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
940 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
942 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
943 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
945 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
948 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
949 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
950 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
951 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
953 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
954 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
955 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
956 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
957 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
959 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
963 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
967 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
968 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
969 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
970 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
971 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
973 f259c4c1 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
974 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
976 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
977 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
978 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
982 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
983 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
985 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
986 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
987 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
991 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
992 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
993 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
994 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
995 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
996 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
998 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
999 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1000 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1004 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1005 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1006 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1007 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1008 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1009 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1010 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1012 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1013 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1014 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1018 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1020 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1021 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1025 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1029 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1032 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1033 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1034 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1035 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1037 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1038 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1039 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1040 a6a8f8bb 2021-09-24 stsp local branch_commitk=`git_show_branch_head $testroot/repo newbranch`
1042 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1046 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1050 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1051 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1052 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1053 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1054 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1056 a6a8f8bb 2021-09-24 stsp # need an up-to-date work tree for 'got merge'
1057 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1059 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1060 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1061 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1065 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1066 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1068 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1069 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1070 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1074 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1075 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1076 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1078 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1079 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1080 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1084 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1085 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1086 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1088 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1089 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1090 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1094 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1096 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1097 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1099 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1100 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1101 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1105 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1106 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1109 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1110 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1114 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1115 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1117 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1118 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1119 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1123 a6a8f8bb 2021-09-24 stsp echo -n "got: merge of refs/heads/newbranch cannot proceed: " \
1124 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1125 a6a8f8bb 2021-09-24 stsp echo "no changes to commit" >> $testroot/stderr.expected
1126 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1128 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1129 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1130 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1134 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1136 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1137 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1139 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1140 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1142 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1145 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1146 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1147 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1148 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1150 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1151 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1152 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1153 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1154 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1155 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1156 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1157 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1158 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1159 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1161 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1164 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1165 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1169 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1173 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1177 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1178 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1179 4e91ef15 2021-09-26 stsp A be/lots/of
1180 4e91ef15 2021-09-26 stsp A files/here
1181 4e91ef15 2021-09-26 stsp A there/should
1182 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1184 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1186 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1187 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1188 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1192 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1193 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1196 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1197 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1200 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1201 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1203 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1204 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1205 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1209 4e91ef15 2021-09-26 stsp # update the 'files' branch
1210 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1211 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1212 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1213 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1214 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1215 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1216 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1218 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1220 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1221 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1222 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1226 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1227 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1230 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1231 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1235 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1236 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1237 4e91ef15 2021-09-26 stsp G be/lots/of
1239 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1242 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1244 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1245 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1247 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1250 088449d3 2021-09-26 stsp test_merge_interrupt() {
1251 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1252 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1253 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1255 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1256 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1257 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1258 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1260 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1263 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1264 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1268 088449d3 2021-09-26 stsp # create a non-conflicting commit
1269 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1270 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1271 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1272 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1274 088449d3 2021-09-26 stsp # need an up-to-date work tree for 'got merge'
1275 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1277 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1278 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1279 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1283 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1284 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1287 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1288 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1292 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1293 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1294 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1295 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1297 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1298 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1299 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1303 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1305 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1306 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1308 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1309 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1310 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1314 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1315 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1316 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1318 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1319 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1320 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1324 088449d3 2021-09-26 stsp # adjust merge result
1325 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1327 088449d3 2021-09-26 stsp # continue the merge
1328 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1331 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1332 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1336 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1338 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1339 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1340 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1341 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1343 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1345 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1346 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1347 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1351 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1353 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1354 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1357 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1358 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1362 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1363 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1364 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1365 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1366 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1368 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1369 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1370 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1374 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1376 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1377 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1379 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1380 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1381 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1385 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1386 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1387 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1388 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1389 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1391 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1392 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1394 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1397 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1398 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1399 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1400 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1401 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1402 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1403 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1404 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
1405 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
1406 088449d3 2021-09-26 stsp run_test test_merge_interrupt