3 10604dce 2021-09-24 thomas # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 10604dce 2021-09-24 thomas # Permission to use, copy, modify, and distribute this software for any
6 10604dce 2021-09-24 thomas # purpose with or without fee is hereby granted, provided that the above
7 10604dce 2021-09-24 thomas # copyright notice and this permission notice appear in all copies.
9 10604dce 2021-09-24 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 10604dce 2021-09-24 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 10604dce 2021-09-24 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 10604dce 2021-09-24 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 10604dce 2021-09-24 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 10604dce 2021-09-24 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 10604dce 2021-09-24 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 10604dce 2021-09-24 thomas . ./common.sh
19 10604dce 2021-09-24 thomas test_merge_basic() {
20 10604dce 2021-09-24 thomas local testroot=`test_init merge_basic`
21 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
22 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
24 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
25 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
26 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
27 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
29 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
30 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
31 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
32 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
33 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
34 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
35 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
36 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
37 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
38 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
39 10604dce 2021-09-24 thomas (cd $testroot/repo && ln -s alpha symlink && git add symlink)
40 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding symlink on newbranch"
41 10604dce 2021-09-24 thomas local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
42 ace90326 2021-09-27 thomas (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
43 ace90326 2021-09-27 thomas (cd $testroot/repo && git add dotgotbar.link)
44 ace90326 2021-09-27 thomas git_commit $testroot/repo -m "adding a bad symlink on newbranch"
45 ace90326 2021-09-27 thomas local branch_commit5=`git_show_branch_head $testroot/repo newbranch`
47 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
49 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
50 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
51 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
55 2b72f32d 2023-06-22 thomas # create a divergent commit
56 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
57 10604dce 2021-09-24 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
58 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to zeta on master"
59 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
61 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
62 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
63 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
65 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
66 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
67 0b477035 2023-06-22 thomas test_done "$testroot" "1"
70 10604dce 2021-09-24 thomas echo -n "got: work tree must be updated before it can be used " \
71 10604dce 2021-09-24 thomas > $testroot/stderr.expected
72 10604dce 2021-09-24 thomas echo "to merge a branch" >> $testroot/stderr.expected
73 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
75 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
76 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
77 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
81 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
83 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
84 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
85 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
89 b6b86fd1 2022-08-30 thomas # must not use a mixed-commit work tree with 'got merge'
90 10604dce 2021-09-24 thomas (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
92 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
93 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
94 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
97 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
98 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
100 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
101 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
102 0b477035 2023-06-22 thomas test_done "$testroot" "1"
105 10604dce 2021-09-24 thomas echo -n "got: work tree contains files from multiple base commits; " \
106 10604dce 2021-09-24 thomas > $testroot/stderr.expected
107 10604dce 2021-09-24 thomas echo "the entire work tree must be updated first" \
108 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
109 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
111 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
112 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
113 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
117 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
119 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
120 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
121 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
125 b6b86fd1 2022-08-30 thomas # must not have staged files with 'got merge'
126 10604dce 2021-09-24 thomas echo "modified file alpha" > $testroot/wt/alpha
127 10604dce 2021-09-24 thomas (cd $testroot/wt && got stage alpha > /dev/null)
129 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
130 10604dce 2021-09-24 thomas echo "got stage failed unexpectedly" >&2
131 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
134 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
135 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
137 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
138 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
139 0b477035 2023-06-22 thomas test_done "$testroot" "1"
142 10604dce 2021-09-24 thomas echo "got: alpha: file is staged" > $testroot/stderr.expected
143 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
145 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
146 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
147 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
150 10604dce 2021-09-24 thomas (cd $testroot/wt && got unstage alpha > /dev/null)
152 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
153 10604dce 2021-09-24 thomas echo "got unstage failed unexpectedly" >&2
154 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
158 b6b86fd1 2022-08-30 thomas # must not have local changes with 'got merge'
159 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
160 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
162 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
163 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
164 0b477035 2023-06-22 thomas test_done "$testroot" "1"
167 10604dce 2021-09-24 thomas echo -n "got: work tree contains local changes; " \
168 10604dce 2021-09-24 thomas > $testroot/stderr.expected
169 10604dce 2021-09-24 thomas echo "these changes must be committed or reverted first" \
170 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
171 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
173 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
174 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
175 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
179 10604dce 2021-09-24 thomas (cd $testroot/wt && got revert alpha > /dev/null)
181 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
182 10604dce 2021-09-24 thomas echo "got revert failed unexpectedly" >&2
183 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
187 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch > $testroot/stdout)
189 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
190 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
191 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
195 10604dce 2021-09-24 thomas local merge_commit=`git_show_head $testroot/repo`
197 10604dce 2021-09-24 thomas echo "G alpha" >> $testroot/stdout.expected
198 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
199 ace90326 2021-09-27 thomas echo "A dotgotbar.link" >> $testroot/stdout.expected
200 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
201 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
202 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
203 10604dce 2021-09-24 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
204 10604dce 2021-09-24 thomas >> $testroot/stdout.expected
205 10604dce 2021-09-24 thomas echo $merge_commit >> $testroot/stdout.expected
207 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
209 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
210 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
211 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
215 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/content.expected
216 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
217 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
219 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
220 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
221 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
225 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/content.expected
226 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
227 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
229 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
230 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
231 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
235 10604dce 2021-09-24 thomas if [ -e $testroot/wt/beta ]; then
236 10604dce 2021-09-24 thomas echo "removed file beta still exists on disk" >&2
237 10604dce 2021-09-24 thomas test_done "$testroot" "1"
241 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/content.expected
242 10604dce 2021-09-24 thomas cat $testroot/wt/epsilon/new > $testroot/content
243 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
245 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
246 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
247 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
251 ace90326 2021-09-27 thomas if [ ! -h $testroot/wt/dotgotbar.link ]; then
252 ace90326 2021-09-27 thomas echo "dotgotbar.link is not a symlink"
253 ace90326 2021-09-27 thomas test_done "$testroot" "1"
257 10604dce 2021-09-24 thomas readlink $testroot/wt/symlink > $testroot/stdout
258 10604dce 2021-09-24 thomas echo "alpha" > $testroot/stdout.expected
259 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
261 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
262 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
263 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
267 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
269 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
270 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
272 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
273 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
274 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
278 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
279 10604dce 2021-09-24 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
280 10604dce 2021-09-24 thomas echo "commit $master_commit" >> $testroot/stdout.expected
281 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
282 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
284 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
285 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
286 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
290 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
292 ace90326 2021-09-27 thomas echo 'U dotgotbar.link' > $testroot/stdout.expected
293 ace90326 2021-09-27 thomas echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
294 ace90326 2021-09-27 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
295 ace90326 2021-09-27 thomas echo >> $testroot/stdout.expected
296 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
298 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
299 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
300 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
304 ace90326 2021-09-27 thomas # update has changed the bad symlink into a regular file
305 ace90326 2021-09-27 thomas if [ -h $testroot/wt/dotgotbar.link ]; then
306 ace90326 2021-09-27 thomas echo "dotgotbar.link is a symlink"
307 ace90326 2021-09-27 thomas test_done "$testroot" "1"
311 10604dce 2021-09-24 thomas # We should have created a merge commit with two parents.
312 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
313 10604dce 2021-09-24 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
314 ace90326 2021-09-27 thomas echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
315 ace90326 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
317 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
318 ace90326 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
319 ace90326 2021-09-27 thomas test_done "$testroot" "$ret"
323 ace90326 2021-09-27 thomas got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
325 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
326 ace90326 2021-09-27 thomas echo "got tree failed unexpectedly" >&2
327 ace90326 2021-09-27 thomas test_done "$testroot" "$ret"
331 ace90326 2021-09-27 thomas # bad symlink dotgotbar.link appears as a symlink in the merge commit:
332 ace90326 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
334 ace90326 2021-09-27 thomas dotgotbar.link@ -> .got/bar
336 ace90326 2021-09-27 thomas epsilon/new
337 ace90326 2021-09-27 thomas epsilon/zeta
339 ace90326 2021-09-27 thomas gamma/delta
340 ace90326 2021-09-27 thomas symlink@ -> alpha
342 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
344 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
345 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
347 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
350 2b72f32d 2023-06-22 thomas test_merge_forward() {
351 2b72f32d 2023-06-22 thomas local testroot=`test_init merge_forward`
352 2b72f32d 2023-06-22 thomas local commit0=`git_show_head $testroot/repo`
354 2b72f32d 2023-06-22 thomas # Create a commit before branching, which will be used to help test
355 2b72f32d 2023-06-22 thomas # preconditions for "got merge".
356 2b72f32d 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
357 2b72f32d 2023-06-22 thomas git_commit $testroot/repo -m "common commit"
358 2b72f32d 2023-06-22 thomas local commit1=`git_show_head $testroot/repo`
360 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
361 2b72f32d 2023-06-22 thomas echo "modified beta on branch" > $testroot/repo/beta
362 2b72f32d 2023-06-22 thomas git_commit $testroot/repo -m "committing to beta on newbranch"
363 2b72f32d 2023-06-22 thomas local commit2=`git_show_head $testroot/repo`
365 2b72f32d 2023-06-22 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
367 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
368 2b72f32d 2023-06-22 thomas echo "got checkout failed unexpectedly" >&2
369 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
373 2b72f32d 2023-06-22 thomas # must not use a mixed-commit work tree with 'got merge'
374 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
376 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
377 2b72f32d 2023-06-22 thomas echo "got update failed unexpectedly" >&2
378 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
381 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
382 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
384 2b72f32d 2023-06-22 thomas if [ $ret -eq 0 ]; then
385 2b72f32d 2023-06-22 thomas echo "got merge succeeded unexpectedly" >&2
386 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
389 2b72f32d 2023-06-22 thomas echo -n "got: work tree contains files from multiple base commits; " \
390 2b72f32d 2023-06-22 thomas > $testroot/stderr.expected
391 2b72f32d 2023-06-22 thomas echo "the entire work tree must be updated first" \
392 2b72f32d 2023-06-22 thomas >> $testroot/stderr.expected
393 2b72f32d 2023-06-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
395 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
396 2b72f32d 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
397 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
401 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got update > /dev/null)
403 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
404 2b72f32d 2023-06-22 thomas echo "got update failed unexpectedly" >&2
405 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
409 2b72f32d 2023-06-22 thomas # 'got merge -n' refuses to fast-forward
410 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge -n newbranch \
411 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
413 2b72f32d 2023-06-22 thomas if [ $ret -eq 0 ]; then
414 2b72f32d 2023-06-22 thomas echo "got merge succeeded unexpectedly" >&2
415 2b72f32d 2023-06-22 thomas test_done "$testroot" "1"
419 0619bbce 2023-06-22 thomas echo -n "got: there are no changes to merge since " \
420 0619bbce 2023-06-22 thomas > $testroot/stderr.expected
421 0619bbce 2023-06-22 thomas echo -n "refs/heads/newbranch is already based on " \
422 2b72f32d 2023-06-22 thomas >> $testroot/stderr.expected
423 0619bbce 2023-06-22 thomas echo -n "refs/heads/master; merge cannot be interrupted " \
424 0619bbce 2023-06-22 thomas >> $testroot/stderr.expected
425 0619bbce 2023-06-22 thomas echo "for amending; -n: option cannot be used" \
426 0619bbce 2023-06-22 thomas >> $testroot/stderr.expected
428 2b72f32d 2023-06-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
430 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
431 2b72f32d 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
432 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
436 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
437 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
439 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
440 2b72f32d 2023-06-22 thomas echo "got merge failed unexpectedly" >&2
441 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
445 2b72f32d 2023-06-22 thomas echo "Forwarding refs/heads/master to refs/heads/newbranch" \
446 2b72f32d 2023-06-22 thomas > $testroot/stdout.expected
447 2b72f32d 2023-06-22 thomas echo "U beta" >> $testroot/stdout.expected
448 2b72f32d 2023-06-22 thomas echo "Updated to commit $commit2" \
449 2b72f32d 2023-06-22 thomas >> $testroot/stdout.expected
450 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
452 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
453 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
454 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
458 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
459 2b72f32d 2023-06-22 thomas echo -n "commit $commit2 " > $testroot/stdout.expected
460 2b72f32d 2023-06-22 thomas echo "(master, newbranch)" >> $testroot/stdout.expected
461 2b72f32d 2023-06-22 thomas echo "commit $commit1" >> $testroot/stdout.expected
462 2b72f32d 2023-06-22 thomas echo "commit $commit0" >> $testroot/stdout.expected
463 31009ade 2023-07-05 thomas cmp -s $testroot/stdout.expected $testroot/stdout
465 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
466 31009ade 2023-07-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
467 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
470 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
473 31009ade 2023-07-05 thomas test_merge_forward_commit() {
474 31009ade 2023-07-05 thomas local testroot=`test_init merge_forward_commit`
475 31009ade 2023-07-05 thomas local commit0=`git_show_head $testroot/repo`
477 31009ade 2023-07-05 thomas (cd $testroot/repo && git checkout -q -b newbranch)
478 31009ade 2023-07-05 thomas echo "modified alpha on branch" > $testroot/repo/alpha
479 31009ade 2023-07-05 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
480 31009ade 2023-07-05 thomas local commit1=`git_show_head $testroot/repo`
482 31009ade 2023-07-05 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
484 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
485 31009ade 2023-07-05 thomas echo "got checkout failed unexpectedly" >&2
486 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
490 31009ade 2023-07-05 thomas (cd $testroot/wt && got merge -M newbranch > $testroot/stdout)
492 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
493 31009ade 2023-07-05 thomas echo "got merge failed unexpectedly" >&2
494 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
498 31009ade 2023-07-05 thomas local merge_commit=`git_show_branch_head $testroot/repo master`
500 31009ade 2023-07-05 thomas echo "G alpha" >> $testroot/stdout.expected
501 31009ade 2023-07-05 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
502 31009ade 2023-07-05 thomas >> $testroot/stdout.expected
503 31009ade 2023-07-05 thomas echo $merge_commit >> $testroot/stdout.expected
505 31009ade 2023-07-05 thomas cmp -s $testroot/stdout.expected $testroot/stdout
507 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
508 31009ade 2023-07-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
509 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
513 31009ade 2023-07-05 thomas # We should have created a merge commit with two parents.
514 31009ade 2023-07-05 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
515 31009ade 2023-07-05 thomas echo "parent 1: $commit0" > $testroot/stdout.expected
516 31009ade 2023-07-05 thomas echo "parent 2: $commit1" >> $testroot/stdout.expected
517 31009ade 2023-07-05 thomas cmp -s $testroot/stdout.expected $testroot/stdout
519 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
520 31009ade 2023-07-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
521 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
525 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
528 31009ade 2023-07-05 thomas test_merge_forward_interrupt() {
529 31009ade 2023-07-05 thomas # Test -M and -n options together.
530 31009ade 2023-07-05 thomas local testroot=`test_init merge_forward_commit`
531 31009ade 2023-07-05 thomas local commit0=`git_show_head $testroot/repo`
533 31009ade 2023-07-05 thomas (cd $testroot/repo && git checkout -q -b newbranch)
534 31009ade 2023-07-05 thomas echo "modified alpha on branch" > $testroot/repo/alpha
535 31009ade 2023-07-05 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
536 31009ade 2023-07-05 thomas local commit1=`git_show_head $testroot/repo`
538 31009ade 2023-07-05 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
540 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
541 31009ade 2023-07-05 thomas echo "got checkout failed unexpectedly" >&2
542 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
546 31009ade 2023-07-05 thomas (cd $testroot/wt && got merge -M -n newbranch > $testroot/stdout)
548 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
549 31009ade 2023-07-05 thomas echo "got merge failed unexpectedly" >&2
550 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
554 31009ade 2023-07-05 thomas echo "G alpha" > $testroot/stdout.expected
555 31009ade 2023-07-05 thomas echo "Merge of refs/heads/newbranch interrupted on request" \
556 31009ade 2023-07-05 thomas >> $testroot/stdout.expected
557 31009ade 2023-07-05 thomas cmp -s $testroot/stdout.expected $testroot/stdout
559 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
560 31009ade 2023-07-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
561 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
565 31009ade 2023-07-05 thomas # Continue the merge.
566 31009ade 2023-07-05 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
568 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
569 31009ade 2023-07-05 thomas echo "got merge failed unexpectedly" >&2
570 31009ade 2023-07-05 thomas test_done "$testroot" "$ret"
574 31009ade 2023-07-05 thomas local merge_commit=`git_show_branch_head $testroot/repo master`
576 31009ade 2023-07-05 thomas echo "M alpha" > $testroot/stdout.expected
577 31009ade 2023-07-05 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
578 31009ade 2023-07-05 thomas >> $testroot/stdout.expected
579 31009ade 2023-07-05 thomas echo $merge_commit >> $testroot/stdout.expected
581 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
583 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
584 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
585 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
589 31009ade 2023-07-05 thomas # We should have created a merge commit with two parents.
590 31009ade 2023-07-05 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
591 31009ade 2023-07-05 thomas echo "parent 1: $commit0" > $testroot/stdout.expected
592 31009ade 2023-07-05 thomas echo "parent 2: $commit1" >> $testroot/stdout.expected
593 31009ade 2023-07-05 thomas cmp -s $testroot/stdout.expected $testroot/stdout
595 31009ade 2023-07-05 thomas if [ $ret -ne 0 ]; then
596 31009ade 2023-07-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
598 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
601 2b72f32d 2023-06-22 thomas test_merge_backward() {
602 2b72f32d 2023-06-22 thomas local testroot=`test_init merge_backward`
603 2b72f32d 2023-06-22 thomas local commit0=`git_show_head $testroot/repo`
605 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
606 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q master)
607 2b72f32d 2023-06-22 thomas echo "modified alpha on master" > $testroot/repo/alpha
608 2b72f32d 2023-06-22 thomas git_commit $testroot/repo -m "committing to alpha on master"
610 2b72f32d 2023-06-22 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
612 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
613 2b72f32d 2023-06-22 thomas echo "got checkout failed unexpectedly" >&2
614 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
618 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
619 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
621 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
622 2b72f32d 2023-06-22 thomas echo "got merge failed unexpectedly" >&2
623 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
626 2b72f32d 2023-06-22 thomas echo "Already up-to-date" > $testroot/stdout.expected
627 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
629 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
630 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
631 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
634 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
637 10604dce 2021-09-24 thomas test_merge_continue() {
638 10604dce 2021-09-24 thomas local testroot=`test_init merge_continue`
639 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
640 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
642 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
643 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
644 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
645 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
647 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
648 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
649 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
650 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
651 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
652 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
653 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
654 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
655 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
656 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
658 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
660 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
661 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
662 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
666 10604dce 2021-09-24 thomas # create a conflicting commit
667 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
668 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
669 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
670 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
672 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
673 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
675 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
676 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
677 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
681 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
682 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
684 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
685 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
686 10604dce 2021-09-24 thomas test_done "$testroot" "1"
690 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
691 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
692 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
693 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
694 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
695 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
697 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
698 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
699 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
703 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
704 10604dce 2021-09-24 thomas > $testroot/stderr.expected
705 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
707 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
708 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
709 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
713 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
715 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
716 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
717 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
718 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
719 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
721 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
722 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
723 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
727 10604dce 2021-09-24 thomas echo '<<<<<<<' > $testroot/content.expected
728 10604dce 2021-09-24 thomas echo "modified alpha on master" >> $testroot/content.expected
729 10604dce 2021-09-24 thomas echo "||||||| 3-way merge base: commit $commit0" \
730 10604dce 2021-09-24 thomas >> $testroot/content.expected
731 10604dce 2021-09-24 thomas echo "alpha" >> $testroot/content.expected
732 10604dce 2021-09-24 thomas echo "=======" >> $testroot/content.expected
733 10604dce 2021-09-24 thomas echo "modified alpha on branch" >> $testroot/content.expected
734 10604dce 2021-09-24 thomas echo ">>>>>>> merged change: commit $branch_commit3" \
735 10604dce 2021-09-24 thomas >> $testroot/content.expected
736 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
737 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
739 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
740 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
741 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
745 10604dce 2021-09-24 thomas # resolve the conflict
746 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/wt/alpha
748 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
750 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
751 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
752 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
756 10604dce 2021-09-24 thomas local merge_commit=`git_show_head $testroot/repo`
758 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
759 ae1e948a 2021-09-28 thomas echo "D beta" >> $testroot/stdout.expected
760 ae1e948a 2021-09-28 thomas echo "A epsilon/new" >> $testroot/stdout.expected
761 ae1e948a 2021-09-28 thomas echo "M gamma/delta" >> $testroot/stdout.expected
762 10604dce 2021-09-24 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
763 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
764 10604dce 2021-09-24 thomas echo $merge_commit >> $testroot/stdout.expected
766 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
768 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
769 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
770 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
774 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/content.expected
775 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
776 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
778 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
779 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
780 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
784 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/content.expected
785 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
786 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
788 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
789 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
790 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
794 10604dce 2021-09-24 thomas if [ -e $testroot/wt/beta ]; then
795 10604dce 2021-09-24 thomas echo "removed file beta still exists on disk" >&2
796 10604dce 2021-09-24 thomas test_done "$testroot" "1"
800 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/content.expected
801 10604dce 2021-09-24 thomas cat $testroot/wt/epsilon/new > $testroot/content
802 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
804 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
805 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
806 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
810 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
812 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
813 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
815 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
816 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
817 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
821 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
822 10604dce 2021-09-24 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
823 10604dce 2021-09-24 thomas echo "commit $master_commit" >> $testroot/stdout.expected
824 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
825 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
827 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
828 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
829 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
833 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
835 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
836 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
838 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
839 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
840 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
844 10604dce 2021-09-24 thomas # We should have created a merge commit with two parents.
845 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
846 10604dce 2021-09-24 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
847 10604dce 2021-09-24 thomas echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
848 fe3f264b 2023-06-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
850 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
851 fe3f264b 2023-06-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
853 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
856 fe3f264b 2023-06-08 thomas test_merge_continue_new_commit() {
857 fe3f264b 2023-06-08 thomas # "got merge -c" should refuse to run if the current branch tip has
858 fe3f264b 2023-06-08 thomas # changed since the merge was started, to avoid clobbering the changes.
859 fe3f264b 2023-06-08 thomas local testroot=`test_init merge_continue_new_commit`
861 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q -b newbranch)
862 fe3f264b 2023-06-08 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
863 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
865 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q master)
866 fe3f264b 2023-06-08 thomas echo "modified alpha on master" > $testroot/repo/alpha
867 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master"
869 fe3f264b 2023-06-08 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
871 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
872 fe3f264b 2023-06-08 thomas echo "got checkout failed unexpectedly" >&2
873 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
877 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -n newbranch >/dev/null)
879 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
880 fe3f264b 2023-06-08 thomas echo "got merge failed unexpectedly" >&2
881 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
885 fe3f264b 2023-06-08 thomas echo "modified alpha again on master" > $testroot/repo/alpha
886 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master again"
888 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
890 fe3f264b 2023-06-08 thomas if [ $ret -eq 0 ]; then
891 fe3f264b 2023-06-08 thomas echo "got merge succeeded unexpectedly" >&2
892 fe3f264b 2023-06-08 thomas test_done "$testroot" "1"
896 fe3f264b 2023-06-08 thomas echo -n > $testroot/stdout.expected
897 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
899 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
900 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
901 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
905 fe3f264b 2023-06-08 thomas echo -n "got: merging cannot proceed because the work tree is no " \
906 fe3f264b 2023-06-08 thomas > $testroot/stderr.expected
907 fe3f264b 2023-06-08 thomas echo "longer up-to-date; merge must be aborted and retried" \
908 fe3f264b 2023-06-08 thomas >> $testroot/stderr.expected
909 fe3f264b 2023-06-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
911 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
912 fe3f264b 2023-06-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
914 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
917 10604dce 2021-09-24 thomas test_merge_abort() {
918 10604dce 2021-09-24 thomas local testroot=`test_init merge_abort`
919 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
920 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
922 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
923 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
924 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
925 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
927 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
928 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
929 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
930 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
931 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
932 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
933 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
934 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
935 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
936 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
937 10604dce 2021-09-24 thomas (cd $testroot/repo && ln -s alpha symlink && git add symlink)
938 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding symlink on newbranch"
939 10604dce 2021-09-24 thomas local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
941 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
943 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
944 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
945 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
949 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
950 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
952 10604dce 2021-09-24 thomas # create a conflicting commit
953 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
954 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
955 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
956 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
958 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
959 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
961 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
962 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
963 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
967 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
968 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
970 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
971 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
972 10604dce 2021-09-24 thomas test_done "$testroot" "1"
976 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
977 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
978 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
979 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
980 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
981 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
982 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
984 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
985 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
986 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
990 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
991 10604dce 2021-09-24 thomas > $testroot/stderr.expected
992 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
994 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
995 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
996 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1000 8641a332 2023-04-14 thomas # unrelated added file added during conflict resolution
1001 8641a332 2023-04-14 thomas touch $testroot/wt/added-file
1002 8641a332 2023-04-14 thomas (cd $testroot/wt && got add added-file > /dev/null)
1004 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1006 8641a332 2023-04-14 thomas echo "A added-file" > $testroot/stdout.expected
1007 8641a332 2023-04-14 thomas echo "C alpha" >> $testroot/stdout.expected
1008 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
1009 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
1010 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
1011 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
1012 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
1013 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1015 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1016 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1017 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1018 10604dce 2021-09-24 thomas return 1
1021 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -a > $testroot/stdout)
1023 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1024 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
1025 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1026 10604dce 2021-09-24 thomas return 1
1029 8641a332 2023-04-14 thomas echo "R added-file" > $testroot/stdout.expected
1030 8641a332 2023-04-14 thomas echo "R alpha" >> $testroot/stdout.expected
1031 10604dce 2021-09-24 thomas echo "R beta" >> $testroot/stdout.expected
1032 10604dce 2021-09-24 thomas echo "R epsilon/new" >> $testroot/stdout.expected
1033 10604dce 2021-09-24 thomas echo "R gamma/delta" >> $testroot/stdout.expected
1034 10604dce 2021-09-24 thomas echo "R symlink" >> $testroot/stdout.expected
1035 8641a332 2023-04-14 thomas echo "G added-file" >> $testroot/stdout.expected
1036 10604dce 2021-09-24 thomas echo "Merge of refs/heads/newbranch aborted" \
1037 10604dce 2021-09-24 thomas >> $testroot/stdout.expected
1039 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1041 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1042 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1043 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1044 10604dce 2021-09-24 thomas return 1
1047 10604dce 2021-09-24 thomas echo "delta" > $testroot/content.expected
1048 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
1049 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
1051 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1052 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
1053 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1054 10604dce 2021-09-24 thomas return 1
1057 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/content.expected
1058 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
1059 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
1061 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1062 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
1063 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1064 10604dce 2021-09-24 thomas return 1
1067 10604dce 2021-09-24 thomas echo "beta" > $testroot/content.expected
1068 10604dce 2021-09-24 thomas cat $testroot/wt/beta > $testroot/content
1069 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
1071 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1072 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
1073 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1074 10604dce 2021-09-24 thomas return 1
1077 10604dce 2021-09-24 thomas if [ -e $testroot/wt/epsilon/new ]; then
1078 10604dce 2021-09-24 thomas echo "reverted file epsilon/new still exists on disk" >&2
1079 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1080 10604dce 2021-09-24 thomas return 1
1083 10604dce 2021-09-24 thomas if [ -e $testroot/wt/symlink ]; then
1084 10604dce 2021-09-24 thomas echo "reverted symlink still exists on disk" >&2
1085 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1086 10604dce 2021-09-24 thomas return 1
1089 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1091 8641a332 2023-04-14 thomas echo "? added-file" > $testroot/stdout.expected
1092 8641a332 2023-04-14 thomas echo "? unversioned-file" >> $testroot/stdout.expected
1093 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1095 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1096 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1097 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1098 10604dce 2021-09-24 thomas return 1
1101 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1102 10604dce 2021-09-24 thomas echo "commit $master_commit (master)" > $testroot/stdout.expected
1103 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
1104 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1106 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1107 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1108 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1109 10604dce 2021-09-24 thomas return 1
1112 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
1114 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
1115 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1117 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1118 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1120 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1123 10604dce 2021-09-24 thomas test_merge_in_progress() {
1124 10604dce 2021-09-24 thomas local testroot=`test_init merge_in_progress`
1125 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1126 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1128 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1129 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1130 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1131 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1133 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1135 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1136 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1137 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1138 10604dce 2021-09-24 thomas return 1
1141 10604dce 2021-09-24 thomas # create a conflicting commit
1142 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1143 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1144 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1145 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1147 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1148 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1150 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1151 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1152 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1153 10604dce 2021-09-24 thomas return 1
1156 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1157 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1159 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1160 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1161 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1162 10604dce 2021-09-24 thomas return 1
1165 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1166 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1167 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1169 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1170 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1171 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1172 10604dce 2021-09-24 thomas return 1
1175 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
1176 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1177 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1179 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1180 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1181 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1182 10604dce 2021-09-24 thomas return 1
1185 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1187 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1188 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1190 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1191 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1192 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1193 10604dce 2021-09-24 thomas return 1
1196 10604dce 2021-09-24 thomas for cmd in update commit histedit "rebase newbranch" \
1197 d8a7bd7d 2023-06-01 thomas "integrate newbranch" "merge newbranch" "stage alpha"; do
1198 10604dce 2021-09-24 thomas (cd $testroot/wt && got $cmd > $testroot/stdout \
1199 10604dce 2021-09-24 thomas 2> $testroot/stderr)
1201 d8a7bd7d 2023-06-01 thomas if [ $ret -eq 0 ]; then
1202 d8a7bd7d 2023-06-01 thomas echo "got $cmd succeeded unexpectedly" >&2
1203 d8a7bd7d 2023-06-01 thomas test_done "$testroot" "1"
1204 d8a7bd7d 2023-06-01 thomas return 1
1207 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
1208 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1211 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1212 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1213 10604dce 2021-09-24 thomas return 1
1216 10604dce 2021-09-24 thomas echo -n "got: a merge operation is in progress in this " \
1217 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1218 10604dce 2021-09-24 thomas echo "work tree and must be continued or aborted first" \
1219 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1220 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1222 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1223 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1224 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1225 10604dce 2021-09-24 thomas return 1
1229 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1232 10604dce 2021-09-24 thomas test_merge_path_prefix() {
1233 10604dce 2021-09-24 thomas local testroot=`test_init merge_path_prefix`
1234 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1235 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1237 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1238 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1239 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1240 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1242 10604dce 2021-09-24 thomas got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1243 10604dce 2021-09-24 thomas > /dev/null
1245 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1246 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1247 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1248 10604dce 2021-09-24 thomas return 1
1251 10604dce 2021-09-24 thomas # create a conflicting commit
1252 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1253 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1254 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1255 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1257 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1258 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1260 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1261 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1262 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1263 10604dce 2021-09-24 thomas return 1
1266 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1267 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1269 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1270 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1271 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1272 10604dce 2021-09-24 thomas return 1
1275 10604dce 2021-09-24 thomas echo -n "got: cannot merge branch which contains changes outside " \
1276 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1277 10604dce 2021-09-24 thomas echo "of this work tree's path prefix" >> $testroot/stderr.expected
1278 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1280 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1281 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1283 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1286 10604dce 2021-09-24 thomas test_merge_missing_file() {
1287 10604dce 2021-09-24 thomas local testroot=`test_init merge_missing_file`
1288 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1289 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1291 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1292 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1293 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1294 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha and delta"
1295 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1297 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1299 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1300 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1301 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1302 10604dce 2021-09-24 thomas return 1
1305 10604dce 2021-09-24 thomas # create a conflicting commit which renames alpha
1306 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1307 10604dce 2021-09-24 thomas (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1308 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "moving alpha on master"
1309 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1311 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1312 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1314 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1315 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1316 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1317 10604dce 2021-09-24 thomas return 1
1320 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1321 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1323 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1324 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1325 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1326 10604dce 2021-09-24 thomas return 1
1329 10604dce 2021-09-24 thomas echo "! alpha" > $testroot/stdout.expected
1330 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1331 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1332 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1333 0ef68859 2021-09-28 thomas echo "in the work tree: 1" >> $testroot/stdout.expected
1334 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1336 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1337 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1338 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1339 10604dce 2021-09-24 thomas return 1
1342 ba162991 2021-09-28 thomas echo -n "got: changes destined for some files " \
1343 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1344 10604dce 2021-09-24 thomas echo -n "were not yet merged and should be merged manually if " \
1345 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1346 10604dce 2021-09-24 thomas echo "required before the merge operation is continued" \
1347 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1348 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1350 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1351 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1352 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1353 10604dce 2021-09-24 thomas return 1
1356 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1358 10604dce 2021-09-24 thomas echo "M gamma/delta" > $testroot/stdout.expected
1359 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1361 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1362 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1363 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1364 2d7ce510 2021-09-24 thomas return 1
1367 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1370 2d7ce510 2021-09-24 thomas test_merge_no_op() {
1371 2d7ce510 2021-09-24 thomas local testroot=`test_init merge_no_op`
1372 2d7ce510 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1373 2d7ce510 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1375 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1376 2d7ce510 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1377 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1378 1678610c 2023-04-22 thomas local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1380 2d7ce510 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1382 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1383 2d7ce510 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1384 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1385 2d7ce510 2021-09-24 thomas return 1
1388 2d7ce510 2021-09-24 thomas # create a conflicting commit
1389 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1390 2d7ce510 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1391 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1392 2d7ce510 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1394 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1395 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1397 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1398 2d7ce510 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1399 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1400 2d7ce510 2021-09-24 thomas return 1
1403 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1404 2d7ce510 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1406 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1407 2d7ce510 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1408 2d7ce510 2021-09-24 thomas test_done "$testroot" "1"
1409 2d7ce510 2021-09-24 thomas return 1
1412 2d7ce510 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1413 2d7ce510 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1414 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1416 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1417 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1418 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1419 2d7ce510 2021-09-24 thomas return 1
1422 2d7ce510 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
1423 2d7ce510 2021-09-24 thomas > $testroot/stderr.expected
1424 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1426 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1427 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1428 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1429 2d7ce510 2021-09-24 thomas return 1
1432 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1434 2d7ce510 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1435 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1437 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1438 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1439 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1440 10604dce 2021-09-24 thomas return 1
1443 2d7ce510 2021-09-24 thomas # resolve the conflict by reverting all changes; now it is no-op merge
1444 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got revert alpha > /dev/null)
1446 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1447 2d7ce510 2021-09-24 thomas echo "got revert failed unexpectedly" >&2
1448 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1449 2d7ce510 2021-09-24 thomas return 1
1452 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout \
1453 2d7ce510 2021-09-24 thomas 2> $testroot/stderr)
1455 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1456 1678610c 2023-04-22 thomas echo "got merge failed unexpectedly" >&2
1457 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1458 2d7ce510 2021-09-24 thomas return 1
1461 1678610c 2023-04-22 thomas echo -n '' > $testroot/stderr.expected
1462 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1465 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1466 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1467 1678610c 2023-04-22 thomas return 1
1470 1678610c 2023-04-22 thomas local merge_commit=`git_show_head $testroot/repo`
1471 1678610c 2023-04-22 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1472 1678610c 2023-04-22 thomas > $testroot/stdout.expected
1473 1678610c 2023-04-22 thomas echo $merge_commit >> $testroot/stdout.expected
1475 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1477 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1478 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1479 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1480 2d7ce510 2021-09-24 thomas return 1
1483 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1485 2d7ce510 2021-09-24 thomas echo -n "" > $testroot/stdout.expected
1486 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1488 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1489 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1490 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1491 1678610c 2023-04-22 thomas return 1
1494 1678610c 2023-04-22 thomas # We should have created a merge commit with two parents.
1495 1678610c 2023-04-22 thomas got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1496 1678610c 2023-04-22 thomas > $testroot/stdout
1497 1678610c 2023-04-22 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1498 1678610c 2023-04-22 thomas echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1499 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1501 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1502 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1504 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1507 768705e3 2021-09-27 thomas test_merge_imported_branch() {
1508 768705e3 2021-09-27 thomas local testroot=`test_init merge_import`
1509 768705e3 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1510 768705e3 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1512 768705e3 2021-09-27 thomas # import a new sub-tree to the 'files' branch such that
1513 768705e3 2021-09-27 thomas # none of the files added here collide with existing ones
1514 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/there
1515 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/be/lots
1516 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/files
1517 768705e3 2021-09-27 thomas echo "there should" > $testroot/tree/there/should
1518 768705e3 2021-09-27 thomas echo "be lots of" > $testroot/tree/be/lots/of
1519 768705e3 2021-09-27 thomas echo "files here" > $testroot/tree/files/here
1520 768705e3 2021-09-27 thomas got import -r $testroot/repo -b files -m 'import files' \
1521 768705e3 2021-09-27 thomas $testroot/tree > /dev/null
1523 768705e3 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1525 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1526 768705e3 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1527 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1528 768705e3 2021-09-27 thomas return 1
1531 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1533 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1534 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1535 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1536 768705e3 2021-09-27 thomas return 1
1539 768705e3 2021-09-27 thomas local merge_commit0=`git_show_head $testroot/repo`
1540 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1541 768705e3 2021-09-27 thomas A be/lots/of
1542 768705e3 2021-09-27 thomas A files/here
1543 768705e3 2021-09-27 thomas A there/should
1544 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit0
1546 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1548 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1549 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1550 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1551 768705e3 2021-09-27 thomas return 1
1554 768705e3 2021-09-27 thomas # try to merge again while no new changes are available
1555 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1557 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1558 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1559 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1560 768705e3 2021-09-27 thomas return 1
1562 768705e3 2021-09-27 thomas echo "Already up-to-date" > $testroot/stdout.expected
1563 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1565 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1566 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1567 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1568 768705e3 2021-09-27 thomas return 1
1571 768705e3 2021-09-27 thomas # update the 'files' branch
1572 768705e3 2021-09-27 thomas (cd $testroot/repo && git reset -q --hard master)
1573 768705e3 2021-09-27 thomas (cd $testroot/repo && git checkout -q files)
1574 768705e3 2021-09-27 thomas echo "indeed" > $testroot/repo/indeed
1575 768705e3 2021-09-27 thomas (cd $testroot/repo && git add indeed)
1576 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "adding another file indeed"
1577 768705e3 2021-09-27 thomas echo "be lots and lots of" > $testroot/repo/be/lots/of
1578 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "lots of changes"
1580 768705e3 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1582 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1583 768705e3 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1584 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1585 768705e3 2021-09-27 thomas return 1
1588 768705e3 2021-09-27 thomas # we should now be able to merge more changes from files branch
1589 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1591 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1592 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1593 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1594 768705e3 2021-09-27 thomas return 1
1597 768705e3 2021-09-27 thomas local merge_commit1=`git_show_branch_head $testroot/repo master`
1598 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1599 768705e3 2021-09-27 thomas G be/lots/of
1600 768705e3 2021-09-27 thomas A indeed
1601 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit1
1604 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1606 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1607 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1609 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1612 ba34626b 2021-09-27 thomas test_merge_interrupt() {
1613 ba34626b 2021-09-27 thomas local testroot=`test_init merge_interrupt`
1614 ba34626b 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1615 ba34626b 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1617 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1618 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1619 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1620 ba34626b 2021-09-27 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1622 ba34626b 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1624 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1625 ba34626b 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1626 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1627 ba34626b 2021-09-27 thomas return 1
1630 ba34626b 2021-09-27 thomas # create a non-conflicting commit
1631 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q master)
1632 ba34626b 2021-09-27 thomas echo "modified beta on master" > $testroot/repo/beta
1633 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to beta on master"
1634 ba34626b 2021-09-27 thomas local master_commit=`git_show_head $testroot/repo`
1636 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1637 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1639 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1640 ba34626b 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1641 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1642 ba34626b 2021-09-27 thomas return 1
1645 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -n newbranch \
1646 ba34626b 2021-09-27 thomas > $testroot/stdout 2> $testroot/stderr)
1648 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1649 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1650 ba34626b 2021-09-27 thomas test_done "$testroot" "1"
1651 ba34626b 2021-09-27 thomas return 1
1654 ba34626b 2021-09-27 thomas echo "G alpha" > $testroot/stdout.expected
1655 ba34626b 2021-09-27 thomas echo "Merge of refs/heads/newbranch interrupted on request" \
1656 ba34626b 2021-09-27 thomas >> $testroot/stdout.expected
1657 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1659 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1660 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1661 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1662 ba34626b 2021-09-27 thomas return 1
1665 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1667 ba34626b 2021-09-27 thomas echo "M alpha" > $testroot/stdout.expected
1668 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1670 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1671 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1672 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1673 ba34626b 2021-09-27 thomas return 1
1676 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/content.expected
1677 ba34626b 2021-09-27 thomas cat $testroot/wt/alpha > $testroot/content
1678 ba34626b 2021-09-27 thomas cmp -s $testroot/content.expected $testroot/content
1680 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1681 ba34626b 2021-09-27 thomas diff -u $testroot/content.expected $testroot/content
1682 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1683 ba34626b 2021-09-27 thomas return 1
1686 ba34626b 2021-09-27 thomas # adjust merge result
1687 ba34626b 2021-09-27 thomas echo "adjusted merge result" > $testroot/wt/alpha
1689 ba34626b 2021-09-27 thomas # continue the merge
1690 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
1692 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1693 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1694 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1695 ba34626b 2021-09-27 thomas return 1
1698 ba34626b 2021-09-27 thomas local merge_commit=`git_show_head $testroot/repo`
1700 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
1701 ba34626b 2021-09-27 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1702 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
1703 ba34626b 2021-09-27 thomas echo $merge_commit >> $testroot/stdout.expected
1705 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1707 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1708 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1709 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1710 ba34626b 2021-09-27 thomas return 1
1713 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1715 ba34626b 2021-09-27 thomas echo -n > $testroot/stdout.expected
1716 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1718 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1719 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1720 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1721 ba34626b 2021-09-27 thomas return 1
1724 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1725 ba34626b 2021-09-27 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
1726 ba34626b 2021-09-27 thomas echo "commit $master_commit" >> $testroot/stdout.expected
1727 ba34626b 2021-09-27 thomas echo "commit $commit0" >> $testroot/stdout.expected
1728 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1730 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1731 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1732 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1733 ba34626b 2021-09-27 thomas return 1
1736 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > $testroot/stdout)
1738 ba34626b 2021-09-27 thomas echo 'Already up-to-date' > $testroot/stdout.expected
1739 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1741 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1742 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1743 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1744 ba34626b 2021-09-27 thomas return 1
1747 ba34626b 2021-09-27 thomas # We should have created a merge commit with two parents.
1748 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1749 ba34626b 2021-09-27 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1750 ba34626b 2021-09-27 thomas echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1751 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1753 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1754 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1756 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1759 a2c162eb 2022-10-30 thomas test_merge_umask() {
1760 a2c162eb 2022-10-30 thomas local testroot=`test_init merge_umask`
1762 a2c162eb 2022-10-30 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1763 a2c162eb 2022-10-30 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1764 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1765 a2c162eb 2022-10-30 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1766 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1768 a2c162eb 2022-10-30 thomas # diverge from newbranch
1769 a2c162eb 2022-10-30 thomas (cd "$testroot/repo" && git checkout -q master)
1770 a2c162eb 2022-10-30 thomas echo "modified beta on master" >$testroot/repo/beta
1771 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1773 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1775 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
1776 a2c162eb 2022-10-30 thomas (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1778 a2c162eb 2022-10-30 thomas for f in alpha gamma/delta; do
1779 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1780 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
1781 a2c162eb 2022-10-30 thomas echo "$f is not 0600 after merge" >&2
1782 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" >&2
1783 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
1787 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
1790 b16f1832 2023-02-21 thomas test_merge_gitconfig_author() {
1791 b16f1832 2023-02-21 thomas local testroot=`test_init merge_gitconfig_author`
1793 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.name 'Flan Luck')
1794 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1796 b16f1832 2023-02-21 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1797 b16f1832 2023-02-21 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1798 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1799 b16f1832 2023-02-21 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1800 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1802 b16f1832 2023-02-21 thomas # diverge from newbranch
1803 b16f1832 2023-02-21 thomas (cd "$testroot/repo" && git checkout -q master)
1804 b16f1832 2023-02-21 thomas echo "modified beta on master" >$testroot/repo/beta
1805 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1807 b16f1832 2023-02-21 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1809 b16f1832 2023-02-21 thomas # unset in a subshell to avoid affecting our environment
1810 b16f1832 2023-02-21 thomas (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1811 b16f1832 2023-02-21 thomas got merge newbranch > /dev/null)
1813 b16f1832 2023-02-21 thomas (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1815 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1816 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1817 b16f1832 2023-02-21 thomas return 1
1820 b16f1832 2023-02-21 thomas echo "from: Flan Luck <flan_luck@openbsd.org>" \
1821 b16f1832 2023-02-21 thomas > $testroot/stdout.expected
1822 b16f1832 2023-02-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1824 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1825 b16f1832 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1827 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1830 4434a15a 2023-06-22 thomas test_merge_fetched_branch() {
1831 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch`
1832 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1833 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1835 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1837 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1838 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1839 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1840 4434a15a 2023-06-22 thomas return 1
1843 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1844 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1845 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1847 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1849 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1850 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1851 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1852 4434a15a 2023-06-22 thomas return 1
1855 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1857 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1859 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1860 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1861 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1862 4434a15a 2023-06-22 thomas return 1
1865 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1867 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1868 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1869 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1870 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1871 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1872 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1874 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1876 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1877 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1878 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1879 4434a15a 2023-06-22 thomas return 1
1882 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1884 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1885 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1886 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1888 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update > /dev/null)
1889 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge origin/master > $testroot/stdout)
1890 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1892 4434a15a 2023-06-22 thomas cat > $testroot/stdout.expected <<EOF
1894 4434a15a 2023-06-22 thomas Merged refs/remotes/origin/master into refs/heads/master: $merge_commit_id
1897 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1899 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1900 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1902 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1905 4434a15a 2023-06-22 thomas test_merge_fetched_branch_remote() {
1906 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch_remote`
1907 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1908 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1910 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1912 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1913 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1914 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1915 4434a15a 2023-06-22 thomas return 1
1918 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1919 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1920 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1922 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1924 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1925 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1926 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1927 4434a15a 2023-06-22 thomas return 1
1930 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1932 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1934 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1935 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1936 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1937 4434a15a 2023-06-22 thomas return 1
1940 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1942 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1943 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1944 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1945 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1946 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1947 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1949 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1951 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1952 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1953 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1954 4434a15a 2023-06-22 thomas return 1
1957 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1959 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1960 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1961 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1963 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update -b origin/master > /dev/null)
1964 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge master > \
1965 4434a15a 2023-06-22 thomas $testroot/stdout 2> $testroot/stderr)
1966 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1968 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1970 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1972 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1973 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1974 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1975 4434a15a 2023-06-22 thomas return 1
1978 4434a15a 2023-06-22 thomas echo -n "got: work tree's current branch refs/remotes/origin/master " \
1979 4434a15a 2023-06-22 thomas > $testroot/stderr.expected
1980 4434a15a 2023-06-22 thomas echo -n 'is outside the "refs/heads/" reference namespace; ' \
1981 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1982 4434a15a 2023-06-22 thomas echo -n "update -b required: will not commit to a branch " \
1983 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1984 4434a15a 2023-06-22 thomas echo 'outside the "refs/heads/" reference namespace' \
1985 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1987 4434a15a 2023-06-22 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1989 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1990 4434a15a 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
1992 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1995 10604dce 2021-09-24 thomas test_parseargs "$@"
1996 10604dce 2021-09-24 thomas run_test test_merge_basic
1997 2b72f32d 2023-06-22 thomas run_test test_merge_forward
1998 31009ade 2023-07-05 thomas run_test test_merge_forward_commit
1999 31009ade 2023-07-05 thomas run_test test_merge_forward_interrupt
2000 2b72f32d 2023-06-22 thomas run_test test_merge_backward
2001 10604dce 2021-09-24 thomas run_test test_merge_continue
2002 fe3f264b 2023-06-08 thomas run_test test_merge_continue_new_commit
2003 10604dce 2021-09-24 thomas run_test test_merge_abort
2004 10604dce 2021-09-24 thomas run_test test_merge_in_progress
2005 10604dce 2021-09-24 thomas run_test test_merge_path_prefix
2006 10604dce 2021-09-24 thomas run_test test_merge_missing_file
2007 2d7ce510 2021-09-24 thomas run_test test_merge_no_op
2008 768705e3 2021-09-27 thomas run_test test_merge_imported_branch
2009 ba34626b 2021-09-27 thomas run_test test_merge_interrupt
2010 a2c162eb 2022-10-30 thomas run_test test_merge_umask
2011 b16f1832 2023-02-21 thomas run_test test_merge_gitconfig_author
2012 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch
2013 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch_remote