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 179f9db0 2023-06-20 falsifian # create a divergent commit
56 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
57 f259c4c1 2021-09-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
58 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
59 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
61 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
62 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
63 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
65 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
66 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
67 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
70 f259c4c1 2021-09-24 stsp echo -n "got: work tree must be updated before it can be used " \
71 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
72 f259c4c1 2021-09-24 stsp echo "to merge a branch" >> $testroot/stderr.expected
73 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
75 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
76 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
77 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
81 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
83 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
84 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
85 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
89 5e91dae4 2022-08-30 stsp # must not use a mixed-commit work tree with 'got merge'
90 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
92 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
93 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
94 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
97 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
98 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
100 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
101 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
102 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
105 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains files from multiple base commits; " \
106 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
107 f259c4c1 2021-09-24 stsp echo "the entire work tree must be updated first" \
108 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
109 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
111 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
112 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
113 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
117 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
119 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
120 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
121 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
125 5e91dae4 2022-08-30 stsp # must not have staged files with 'got merge'
126 f259c4c1 2021-09-24 stsp echo "modified file alpha" > $testroot/wt/alpha
127 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got stage alpha > /dev/null)
129 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
130 f259c4c1 2021-09-24 stsp echo "got stage failed unexpectedly" >&2
131 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
134 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
135 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
137 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
138 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
139 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
142 f259c4c1 2021-09-24 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
143 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
146 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
147 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
150 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
152 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
153 f259c4c1 2021-09-24 stsp echo "got unstage failed unexpectedly" >&2
154 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
158 5e91dae4 2022-08-30 stsp # must not have local changes with 'got merge'
159 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
160 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
162 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
163 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
164 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
167 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains local changes; " \
168 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
169 f259c4c1 2021-09-24 stsp echo "these changes must be committed or reverted first" \
170 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
171 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
174 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
175 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
179 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
181 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
182 f259c4c1 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
183 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
187 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch > $testroot/stdout)
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
191 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
195 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
197 f259c4c1 2021-09-24 stsp echo "G alpha" >> $testroot/stdout.expected
198 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
199 5267b9e4 2021-09-26 stsp echo "A dotgotbar.link" >> $testroot/stdout.expected
200 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
201 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
202 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
203 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
204 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
205 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
207 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
210 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
211 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
215 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
216 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
217 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
219 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
220 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
221 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
225 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/content.expected
226 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
227 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
231 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
235 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
236 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
237 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
241 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
242 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
243 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
245 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
246 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
247 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
251 5267b9e4 2021-09-26 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
252 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is not a symlink"
253 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
257 f259c4c1 2021-09-24 stsp readlink $testroot/wt/symlink > $testroot/stdout
258 f259c4c1 2021-09-24 stsp echo "alpha" > $testroot/stdout.expected
259 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
261 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
262 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
267 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
269 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
270 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
273 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
274 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
278 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
279 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
280 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
281 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
282 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
285 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
286 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
290 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
292 5267b9e4 2021-09-26 stsp echo 'U dotgotbar.link' > $testroot/stdout.expected
293 5267b9e4 2021-09-26 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
294 5267b9e4 2021-09-26 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
295 5267b9e4 2021-09-26 stsp echo >> $testroot/stdout.expected
296 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
298 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
299 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
300 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
304 5267b9e4 2021-09-26 stsp # update has changed the bad symlink into a regular file
305 5267b9e4 2021-09-26 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
306 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is a symlink"
307 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
311 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
312 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
313 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
314 5267b9e4 2021-09-26 stsp echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
315 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
318 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
319 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
323 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
325 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
326 5267b9e4 2021-09-26 stsp echo "got tree failed unexpectedly" >&2
327 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
331 5267b9e4 2021-09-26 stsp # bad symlink dotgotbar.link appears as a symlink in the merge commit:
332 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
334 5267b9e4 2021-09-26 stsp dotgotbar.link@ -> .got/bar
336 5267b9e4 2021-09-26 stsp epsilon/new
337 5267b9e4 2021-09-26 stsp epsilon/zeta
339 5267b9e4 2021-09-26 stsp gamma/delta
340 5267b9e4 2021-09-26 stsp symlink@ -> alpha
342 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
343 179f9db0 2023-06-20 falsifian ret=$?
344 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
345 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
347 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
350 179f9db0 2023-06-20 falsifian test_merge_forward() {
351 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_forward`
352 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
354 179f9db0 2023-06-20 falsifian # Create a commit before branching, which will be used to help test
355 179f9db0 2023-06-20 falsifian # preconditions for "got merge".
356 179f9db0 2023-06-20 falsifian echo "modified alpha" > $testroot/repo/alpha
357 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "common commit"
358 179f9db0 2023-06-20 falsifian local commit1=`git_show_head $testroot/repo`
360 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
361 179f9db0 2023-06-20 falsifian echo "modified beta on branch" > $testroot/repo/beta
362 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to beta on newbranch"
363 179f9db0 2023-06-20 falsifian local commit2=`git_show_head $testroot/repo`
365 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
366 179f9db0 2023-06-20 falsifian ret=$?
367 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
368 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
369 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
370 179f9db0 2023-06-20 falsifian return 1
373 179f9db0 2023-06-20 falsifian # must not use a mixed-commit work tree with 'got merge'
374 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
375 179f9db0 2023-06-20 falsifian ret=$?
376 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
377 179f9db0 2023-06-20 falsifian echo "got update failed unexpectedly" >&2
378 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
379 179f9db0 2023-06-20 falsifian return 1
381 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
382 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
383 179f9db0 2023-06-20 falsifian ret=$?
384 179f9db0 2023-06-20 falsifian if [ $ret -eq 0 ]; then
385 179f9db0 2023-06-20 falsifian echo "got merge succeeded unexpectedly" >&2
386 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
387 179f9db0 2023-06-20 falsifian return 1
389 179f9db0 2023-06-20 falsifian echo -n "got: work tree contains files from multiple base commits; " \
390 179f9db0 2023-06-20 falsifian > $testroot/stderr.expected
391 179f9db0 2023-06-20 falsifian echo "the entire work tree must be updated first" \
392 179f9db0 2023-06-20 falsifian >> $testroot/stderr.expected
393 179f9db0 2023-06-20 falsifian cmp -s $testroot/stderr.expected $testroot/stderr
394 179f9db0 2023-06-20 falsifian ret=$?
395 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
396 179f9db0 2023-06-20 falsifian diff -u $testroot/stderr.expected $testroot/stderr
397 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
398 179f9db0 2023-06-20 falsifian return 1
401 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got update > /dev/null)
402 179f9db0 2023-06-20 falsifian ret=$?
403 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
404 179f9db0 2023-06-20 falsifian echo "got update failed unexpectedly" >&2
405 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
406 179f9db0 2023-06-20 falsifian return 1
409 179f9db0 2023-06-20 falsifian # 'got merge -n' refuses to fast-forward
410 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge -n newbranch \
411 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
412 179f9db0 2023-06-20 falsifian ret=$?
413 179f9db0 2023-06-20 falsifian if [ $ret -eq 0 ]; then
414 179f9db0 2023-06-20 falsifian echo "got merge succeeded unexpectedly" >&2
415 179f9db0 2023-06-20 falsifian test_done "$testroot" "1"
416 179f9db0 2023-06-20 falsifian return 1
418 179f9db0 2023-06-20 falsifian echo -n "got: merge is a fast-forward; " > $testroot/stderr.expected
419 179f9db0 2023-06-20 falsifian echo "this is incompatible with got merge -n" \
420 179f9db0 2023-06-20 falsifian >> $testroot/stderr.expected
421 179f9db0 2023-06-20 falsifian cmp -s $testroot/stderr.expected $testroot/stderr
422 179f9db0 2023-06-20 falsifian ret=$?
423 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
424 179f9db0 2023-06-20 falsifian diff -u $testroot/stderr.expected $testroot/stderr
425 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
426 179f9db0 2023-06-20 falsifian return 1
429 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
430 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
431 179f9db0 2023-06-20 falsifian ret=$?
432 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
433 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
434 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
435 179f9db0 2023-06-20 falsifian return 1
438 179f9db0 2023-06-20 falsifian echo "Forwarding refs/heads/master to refs/heads/newbranch" \
439 179f9db0 2023-06-20 falsifian > $testroot/stdout.expected
440 179f9db0 2023-06-20 falsifian echo "U beta" >> $testroot/stdout.expected
441 179f9db0 2023-06-20 falsifian echo "Updated to commit $commit2" \
442 179f9db0 2023-06-20 falsifian >> $testroot/stdout.expected
443 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
446 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
448 179f9db0 2023-06-20 falsifian return 1
451 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
452 179f9db0 2023-06-20 falsifian echo -n "commit $commit2 " > $testroot/stdout.expected
453 179f9db0 2023-06-20 falsifian echo "(master, newbranch)" >> $testroot/stdout.expected
454 179f9db0 2023-06-20 falsifian echo "commit $commit1" >> $testroot/stdout.expected
455 179f9db0 2023-06-20 falsifian echo "commit $commit0" >> $testroot/stdout.expected
456 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
457 179f9db0 2023-06-20 falsifian ret=$?
458 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
459 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
460 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
461 179f9db0 2023-06-20 falsifian return 1
463 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
466 179f9db0 2023-06-20 falsifian test_merge_backward() {
467 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_backward`
468 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
470 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
471 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q master)
472 179f9db0 2023-06-20 falsifian echo "modified alpha on master" > $testroot/repo/alpha
473 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to alpha on master"
475 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
476 179f9db0 2023-06-20 falsifian ret=$?
477 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
478 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
479 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
480 179f9db0 2023-06-20 falsifian return 1
483 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
484 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
485 179f9db0 2023-06-20 falsifian ret=$?
486 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
487 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
488 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
489 179f9db0 2023-06-20 falsifian return 1
491 179f9db0 2023-06-20 falsifian echo "Already up-to-date" > $testroot/stdout.expected
492 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
493 179f9db0 2023-06-20 falsifian ret=$?
494 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
495 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
496 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
497 179f9db0 2023-06-20 falsifian return 1
499 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
502 f259c4c1 2021-09-24 stsp test_merge_continue() {
503 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
504 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
505 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
507 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
508 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
509 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
510 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
512 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
513 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
514 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
515 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
516 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
517 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
518 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
519 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
520 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
521 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
523 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
527 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
531 f259c4c1 2021-09-24 stsp # create a conflicting commit
532 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
533 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
534 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
535 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
537 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
538 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
542 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
546 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
547 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
549 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
550 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
551 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
555 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
556 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
557 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
558 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
559 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
560 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
562 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
563 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
564 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
568 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
569 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
570 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
573 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
574 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
578 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
580 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
581 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
582 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
583 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
584 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
586 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
587 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
592 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
593 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
594 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
595 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
596 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
597 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
598 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
599 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
600 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
601 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
602 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
604 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
605 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
606 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
610 f259c4c1 2021-09-24 stsp # resolve the conflict
611 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
613 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
615 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
616 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
617 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
621 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
623 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
624 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
625 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
626 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
627 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
628 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
629 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
631 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
633 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
634 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
635 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
639 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
640 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
641 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
644 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
645 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
649 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
650 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
651 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
653 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
654 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
655 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
659 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
660 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
661 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
665 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
666 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
667 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
669 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
670 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
671 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
675 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
677 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
678 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
680 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
681 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
682 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
686 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
687 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
688 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
689 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
690 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
698 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
700 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
701 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
703 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
704 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
709 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
710 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
711 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
712 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
713 6b5246e4 2023-06-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
715 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
716 6b5246e4 2023-06-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
718 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
721 6b5246e4 2023-06-05 stsp test_merge_continue_new_commit() {
722 6b5246e4 2023-06-05 stsp # "got merge -c" should refuse to run if the current branch tip has
723 6b5246e4 2023-06-05 stsp # changed since the merge was started, to avoid clobbering the changes.
724 6b5246e4 2023-06-05 stsp local testroot=`test_init merge_continue_new_commit`
726 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q -b newbranch)
727 6b5246e4 2023-06-05 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
728 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
730 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q master)
731 6b5246e4 2023-06-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
732 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master"
734 6b5246e4 2023-06-05 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
736 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
737 6b5246e4 2023-06-05 stsp echo "got checkout failed unexpectedly" >&2
738 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
742 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -n newbranch >/dev/null)
744 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
745 6b5246e4 2023-06-05 stsp echo "got merge failed unexpectedly" >&2
746 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
750 6b5246e4 2023-06-05 stsp echo "modified alpha again on master" > $testroot/repo/alpha
751 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master again"
753 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
755 6b5246e4 2023-06-05 stsp if [ $ret -eq 0 ]; then
756 6b5246e4 2023-06-05 stsp echo "got merge succeeded unexpectedly" >&2
757 6b5246e4 2023-06-05 stsp test_done "$testroot" "1"
761 6b5246e4 2023-06-05 stsp echo -n > $testroot/stdout.expected
762 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
764 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
765 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
766 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
770 6b5246e4 2023-06-05 stsp echo -n "got: merging cannot proceed because the work tree is no " \
771 6b5246e4 2023-06-05 stsp > $testroot/stderr.expected
772 6b5246e4 2023-06-05 stsp echo "longer up-to-date; merge must be aborted and retried" \
773 6b5246e4 2023-06-05 stsp >> $testroot/stderr.expected
774 6b5246e4 2023-06-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
776 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
777 6b5246e4 2023-06-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
779 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
782 f259c4c1 2021-09-24 stsp test_merge_abort() {
783 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
784 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
785 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
787 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
788 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
789 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
790 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
792 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
793 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
794 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
795 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
796 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
797 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
798 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
799 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
800 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
801 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
802 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
803 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
804 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
806 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
808 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
809 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
810 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
814 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
815 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
817 f259c4c1 2021-09-24 stsp # create a conflicting commit
818 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
819 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
820 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
821 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
823 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
824 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
826 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
827 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
828 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
832 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
833 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
835 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
836 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
837 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
841 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
842 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
843 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
844 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
845 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
846 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
847 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
850 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
855 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
856 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
857 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
859 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
860 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
861 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
865 af179be7 2023-04-14 stsp # unrelated added file added during conflict resolution
866 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
867 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
869 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
871 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
872 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
873 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
874 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
875 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
876 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
877 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
878 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
880 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
881 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
886 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
890 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
894 af179be7 2023-04-14 stsp echo "R added-file" > $testroot/stdout.expected
895 af179be7 2023-04-14 stsp echo "R alpha" >> $testroot/stdout.expected
896 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
897 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
898 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
899 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
900 af179be7 2023-04-14 stsp echo "G added-file" >> $testroot/stdout.expected
901 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
902 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
904 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
906 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
907 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
912 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
913 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
914 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
918 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
922 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
923 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
924 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
926 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
927 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
928 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
932 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
933 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
934 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
938 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
942 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
943 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
944 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
948 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
949 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
950 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
954 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
956 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
957 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
958 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
960 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
961 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
966 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
967 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
968 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
969 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
971 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
972 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
973 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
977 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
979 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
980 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
982 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
983 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
988 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
989 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
990 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
991 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
993 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
994 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
995 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
996 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
998 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1000 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1001 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1002 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1006 f259c4c1 2021-09-24 stsp # create a conflicting commit
1007 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1008 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1009 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1010 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1012 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1013 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1015 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1016 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1017 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1021 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1022 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1024 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1025 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1026 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1030 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1031 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1032 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1034 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1035 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1036 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1040 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1041 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1042 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1050 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1052 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1053 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1056 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1057 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1061 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
1062 42761529 2023-06-01 stsp "integrate newbranch" "merge newbranch" "stage alpha"; do
1063 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
1064 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
1066 42761529 2023-06-01 stsp if [ $ret -eq 0 ]; then
1067 42761529 2023-06-01 stsp echo "got $cmd succeeded unexpectedly" >&2
1068 42761529 2023-06-01 stsp test_done "$testroot" "1"
1072 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
1073 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1081 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
1082 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1083 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
1084 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1085 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1087 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1088 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1089 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1094 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1097 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
1098 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
1099 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1100 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1102 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1103 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1104 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1105 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1107 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1108 f259c4c1 2021-09-24 stsp > /dev/null
1110 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1111 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1112 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1116 f259c4c1 2021-09-24 stsp # create a conflicting commit
1117 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1118 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1119 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1120 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1122 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1123 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1125 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1126 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1127 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1131 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1132 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1134 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1135 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1136 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1140 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
1141 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1142 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
1143 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1146 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1148 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1151 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
1152 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
1153 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1154 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1156 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1157 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1158 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1159 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
1160 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1162 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1164 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1165 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1166 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1170 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
1171 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1172 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1173 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
1174 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1176 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1177 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1181 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1185 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1186 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1188 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1189 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1190 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1194 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
1195 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1196 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1197 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1198 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1199 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1201 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1202 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1203 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1207 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1208 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1209 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1210 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1211 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1212 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1213 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1215 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1216 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1217 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1221 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1223 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1224 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1227 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1228 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1232 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1235 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1236 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1237 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1238 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1240 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1241 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1242 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1243 35d2583f 2023-04-17 stsp local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1245 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1248 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1249 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1253 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1254 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1255 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1256 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1257 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1259 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1260 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1263 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1264 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1268 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1269 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1271 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1272 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1273 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1277 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1278 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1279 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1281 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1282 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1283 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1287 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1288 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1289 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1291 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1292 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1293 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1297 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1299 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1300 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1303 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1304 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1308 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1309 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1312 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1313 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1317 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1318 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1320 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1321 35d2583f 2023-04-17 stsp echo "got merge failed unexpectedly" >&2
1322 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1326 35d2583f 2023-04-17 stsp echo -n '' > $testroot/stderr.expected
1327 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1330 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1331 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1335 35d2583f 2023-04-17 stsp local merge_commit=`git_show_head $testroot/repo`
1336 35d2583f 2023-04-17 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1337 35d2583f 2023-04-17 stsp > $testroot/stdout.expected
1338 35d2583f 2023-04-17 stsp echo $merge_commit >> $testroot/stdout.expected
1340 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1342 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1343 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1344 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1348 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1350 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1351 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1353 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1354 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1355 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1359 35d2583f 2023-04-17 stsp # We should have created a merge commit with two parents.
1360 35d2583f 2023-04-17 stsp got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1361 35d2583f 2023-04-17 stsp > $testroot/stdout
1362 35d2583f 2023-04-17 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1363 35d2583f 2023-04-17 stsp echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1364 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1366 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1367 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1369 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1372 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1373 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1374 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1375 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1377 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1378 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1379 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1380 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1381 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1382 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1383 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1384 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1385 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1386 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1388 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1390 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1391 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1392 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1396 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1399 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1400 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1404 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1405 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1406 4e91ef15 2021-09-26 stsp A be/lots/of
1407 4e91ef15 2021-09-26 stsp A files/here
1408 4e91ef15 2021-09-26 stsp A there/should
1409 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1411 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1414 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1415 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1419 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1420 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1422 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1423 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1424 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1427 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1428 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1430 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1431 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1432 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1436 4e91ef15 2021-09-26 stsp # update the 'files' branch
1437 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1438 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1439 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1440 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1441 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1442 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1443 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1445 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1447 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1448 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1449 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1453 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1454 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1456 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1457 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1458 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1462 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1463 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1464 4e91ef15 2021-09-26 stsp G be/lots/of
1466 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1469 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1472 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1474 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1477 088449d3 2021-09-26 stsp test_merge_interrupt() {
1478 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1479 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1480 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1482 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1483 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1484 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1485 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1487 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1490 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1491 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1495 088449d3 2021-09-26 stsp # create a non-conflicting commit
1496 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1497 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1498 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1499 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1501 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1502 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1504 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1505 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1506 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1510 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1511 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1513 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1514 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1515 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1519 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1520 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1521 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1522 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1525 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1530 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1532 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1533 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1535 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1536 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1537 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1541 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1542 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1543 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1545 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1546 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1547 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1551 088449d3 2021-09-26 stsp # adjust merge result
1552 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1554 088449d3 2021-09-26 stsp # continue the merge
1555 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1557 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1558 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1559 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1563 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1565 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1566 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1567 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1568 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1570 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1573 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1574 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1578 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1580 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1581 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1583 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1584 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1585 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1589 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1590 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1591 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1592 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1593 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1595 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1596 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1597 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1601 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1603 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1604 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1607 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1608 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1612 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1613 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1614 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1615 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1616 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1618 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1619 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1621 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1624 b2b3fce1 2022-10-29 op test_merge_umask() {
1625 b2b3fce1 2022-10-29 op local testroot=`test_init merge_umask`
1627 b2b3fce1 2022-10-29 op (cd $testroot/repo && git checkout -q -b newbranch)
1628 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/repo/alpha
1629 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1630 b2b3fce1 2022-10-29 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1631 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1633 b2b3fce1 2022-10-29 op # diverge from newbranch
1634 b2b3fce1 2022-10-29 op (cd "$testroot/repo" && git checkout -q master)
1635 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/repo/beta
1636 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing zeto no master"
1638 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1640 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1641 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1643 b2b3fce1 2022-10-29 op for f in alpha gamma/delta; do
1644 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1645 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1646 b2b3fce1 2022-10-29 op echo "$f is not 0600 after merge" >&2
1647 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
1648 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1652 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1655 d51d11be 2023-02-21 op test_merge_gitconfig_author() {
1656 d51d11be 2023-02-21 op local testroot=`test_init merge_gitconfig_author`
1658 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.name 'Flan Luck')
1659 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1661 d51d11be 2023-02-21 op (cd $testroot/repo && git checkout -q -b newbranch)
1662 d51d11be 2023-02-21 op echo "modified alpha on branch" >$testroot/repo/alpha
1663 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1664 d51d11be 2023-02-21 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1665 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1667 d51d11be 2023-02-21 op # diverge from newbranch
1668 d51d11be 2023-02-21 op (cd "$testroot/repo" && git checkout -q master)
1669 d51d11be 2023-02-21 op echo "modified beta on master" >$testroot/repo/beta
1670 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing zeto no master"
1672 d51d11be 2023-02-21 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1674 d51d11be 2023-02-21 op # unset in a subshell to avoid affecting our environment
1675 d51d11be 2023-02-21 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1676 d51d11be 2023-02-21 op got merge newbranch > /dev/null)
1678 d51d11be 2023-02-21 op (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1680 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1681 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1685 d51d11be 2023-02-21 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1686 d51d11be 2023-02-21 op > $testroot/stdout.expected
1687 d51d11be 2023-02-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1689 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1690 d51d11be 2023-02-21 op diff -u $testroot/stdout.expected $testroot/stdout
1692 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1695 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1696 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1697 179f9db0 2023-06-20 falsifian run_test test_merge_forward
1698 179f9db0 2023-06-20 falsifian run_test test_merge_backward
1699 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1700 6b5246e4 2023-06-05 stsp run_test test_merge_continue_new_commit
1701 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1702 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1703 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1704 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1705 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
1706 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
1707 088449d3 2021-09-26 stsp run_test test_merge_interrupt
1708 b2b3fce1 2022-10-29 op run_test test_merge_umask
1709 d51d11be 2023-02-21 op run_test test_merge_gitconfig_author