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 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
465 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
466 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
467 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
470 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
473 2b72f32d 2023-06-22 thomas test_merge_backward() {
474 2b72f32d 2023-06-22 thomas local testroot=`test_init merge_backward`
475 2b72f32d 2023-06-22 thomas local commit0=`git_show_head $testroot/repo`
477 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
478 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q master)
479 2b72f32d 2023-06-22 thomas echo "modified alpha on master" > $testroot/repo/alpha
480 2b72f32d 2023-06-22 thomas git_commit $testroot/repo -m "committing to alpha on master"
482 2b72f32d 2023-06-22 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
484 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
485 2b72f32d 2023-06-22 thomas echo "got checkout failed unexpectedly" >&2
486 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
490 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
491 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
493 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
494 2b72f32d 2023-06-22 thomas echo "got merge failed unexpectedly" >&2
495 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
498 2b72f32d 2023-06-22 thomas echo "Already up-to-date" > $testroot/stdout.expected
499 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
501 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
502 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
503 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
506 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
509 10604dce 2021-09-24 thomas test_merge_continue() {
510 10604dce 2021-09-24 thomas local testroot=`test_init merge_continue`
511 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
512 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
514 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
515 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
516 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
517 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
519 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
520 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
521 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
522 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
523 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
524 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
525 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
526 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
527 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
528 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
530 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
532 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
533 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
534 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
538 10604dce 2021-09-24 thomas # create a conflicting commit
539 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
540 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
541 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
542 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
544 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
545 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
547 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
548 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
549 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
553 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
554 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
556 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
557 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
558 10604dce 2021-09-24 thomas test_done "$testroot" "1"
562 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
563 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
564 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
565 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
566 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
567 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
569 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
570 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
571 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
575 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
576 10604dce 2021-09-24 thomas > $testroot/stderr.expected
577 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
579 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
580 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
581 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
585 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
587 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
588 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
589 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
590 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
591 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
593 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
594 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
595 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
599 10604dce 2021-09-24 thomas echo '<<<<<<<' > $testroot/content.expected
600 10604dce 2021-09-24 thomas echo "modified alpha on master" >> $testroot/content.expected
601 10604dce 2021-09-24 thomas echo "||||||| 3-way merge base: commit $commit0" \
602 10604dce 2021-09-24 thomas >> $testroot/content.expected
603 10604dce 2021-09-24 thomas echo "alpha" >> $testroot/content.expected
604 10604dce 2021-09-24 thomas echo "=======" >> $testroot/content.expected
605 10604dce 2021-09-24 thomas echo "modified alpha on branch" >> $testroot/content.expected
606 10604dce 2021-09-24 thomas echo ">>>>>>> merged change: commit $branch_commit3" \
607 10604dce 2021-09-24 thomas >> $testroot/content.expected
608 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
609 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
611 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
612 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
613 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
617 10604dce 2021-09-24 thomas # resolve the conflict
618 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/wt/alpha
620 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
622 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
623 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
624 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
628 10604dce 2021-09-24 thomas local merge_commit=`git_show_head $testroot/repo`
630 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
631 ae1e948a 2021-09-28 thomas echo "D beta" >> $testroot/stdout.expected
632 ae1e948a 2021-09-28 thomas echo "A epsilon/new" >> $testroot/stdout.expected
633 ae1e948a 2021-09-28 thomas echo "M gamma/delta" >> $testroot/stdout.expected
634 10604dce 2021-09-24 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
635 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
636 10604dce 2021-09-24 thomas echo $merge_commit >> $testroot/stdout.expected
638 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
640 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
641 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
642 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
646 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/content.expected
647 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
648 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
650 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
651 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
652 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
656 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/content.expected
657 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
658 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
660 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
661 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
662 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
666 10604dce 2021-09-24 thomas if [ -e $testroot/wt/beta ]; then
667 10604dce 2021-09-24 thomas echo "removed file beta still exists on disk" >&2
668 10604dce 2021-09-24 thomas test_done "$testroot" "1"
672 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/content.expected
673 10604dce 2021-09-24 thomas cat $testroot/wt/epsilon/new > $testroot/content
674 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
676 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
677 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
678 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
682 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
684 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
685 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
687 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
688 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
689 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
693 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
694 10604dce 2021-09-24 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
695 10604dce 2021-09-24 thomas echo "commit $master_commit" >> $testroot/stdout.expected
696 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
697 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
699 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
700 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
701 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
705 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
707 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
708 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
710 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
711 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
712 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
716 10604dce 2021-09-24 thomas # We should have created a merge commit with two parents.
717 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
718 10604dce 2021-09-24 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
719 10604dce 2021-09-24 thomas echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
720 fe3f264b 2023-06-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
722 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
723 fe3f264b 2023-06-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
725 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
728 fe3f264b 2023-06-08 thomas test_merge_continue_new_commit() {
729 fe3f264b 2023-06-08 thomas # "got merge -c" should refuse to run if the current branch tip has
730 fe3f264b 2023-06-08 thomas # changed since the merge was started, to avoid clobbering the changes.
731 fe3f264b 2023-06-08 thomas local testroot=`test_init merge_continue_new_commit`
733 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q -b newbranch)
734 fe3f264b 2023-06-08 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
735 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
737 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q master)
738 fe3f264b 2023-06-08 thomas echo "modified alpha on master" > $testroot/repo/alpha
739 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master"
741 fe3f264b 2023-06-08 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
743 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
744 fe3f264b 2023-06-08 thomas echo "got checkout failed unexpectedly" >&2
745 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
749 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -n newbranch >/dev/null)
751 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
752 fe3f264b 2023-06-08 thomas echo "got merge failed unexpectedly" >&2
753 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
757 fe3f264b 2023-06-08 thomas echo "modified alpha again on master" > $testroot/repo/alpha
758 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master again"
760 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
762 fe3f264b 2023-06-08 thomas if [ $ret -eq 0 ]; then
763 fe3f264b 2023-06-08 thomas echo "got merge succeeded unexpectedly" >&2
764 fe3f264b 2023-06-08 thomas test_done "$testroot" "1"
768 fe3f264b 2023-06-08 thomas echo -n > $testroot/stdout.expected
769 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
771 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
772 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
773 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
777 fe3f264b 2023-06-08 thomas echo -n "got: merging cannot proceed because the work tree is no " \
778 fe3f264b 2023-06-08 thomas > $testroot/stderr.expected
779 fe3f264b 2023-06-08 thomas echo "longer up-to-date; merge must be aborted and retried" \
780 fe3f264b 2023-06-08 thomas >> $testroot/stderr.expected
781 fe3f264b 2023-06-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
783 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
784 fe3f264b 2023-06-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
786 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
789 10604dce 2021-09-24 thomas test_merge_abort() {
790 10604dce 2021-09-24 thomas local testroot=`test_init merge_abort`
791 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
792 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
794 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
795 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
796 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
797 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
799 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
800 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
801 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
802 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
803 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
804 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
805 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
806 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
807 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
808 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
809 10604dce 2021-09-24 thomas (cd $testroot/repo && ln -s alpha symlink && git add symlink)
810 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding symlink on newbranch"
811 10604dce 2021-09-24 thomas local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
813 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
815 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
816 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
817 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
821 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
822 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
824 10604dce 2021-09-24 thomas # create a conflicting commit
825 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
826 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
827 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
828 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
830 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
831 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
833 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
834 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
835 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
839 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
840 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
842 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
843 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
844 10604dce 2021-09-24 thomas test_done "$testroot" "1"
848 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
849 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
850 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
851 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
852 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
853 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
854 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
856 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
857 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
858 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
862 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
863 10604dce 2021-09-24 thomas > $testroot/stderr.expected
864 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
866 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
867 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
868 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
872 8641a332 2023-04-14 thomas # unrelated added file added during conflict resolution
873 8641a332 2023-04-14 thomas touch $testroot/wt/added-file
874 8641a332 2023-04-14 thomas (cd $testroot/wt && got add added-file > /dev/null)
876 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
878 8641a332 2023-04-14 thomas echo "A added-file" > $testroot/stdout.expected
879 8641a332 2023-04-14 thomas echo "C alpha" >> $testroot/stdout.expected
880 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
881 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
882 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
883 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
884 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
885 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
887 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
888 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
889 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
893 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -a > $testroot/stdout)
895 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
896 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
897 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
901 8641a332 2023-04-14 thomas echo "R added-file" > $testroot/stdout.expected
902 8641a332 2023-04-14 thomas echo "R alpha" >> $testroot/stdout.expected
903 10604dce 2021-09-24 thomas echo "R beta" >> $testroot/stdout.expected
904 10604dce 2021-09-24 thomas echo "R epsilon/new" >> $testroot/stdout.expected
905 10604dce 2021-09-24 thomas echo "R gamma/delta" >> $testroot/stdout.expected
906 10604dce 2021-09-24 thomas echo "R symlink" >> $testroot/stdout.expected
907 8641a332 2023-04-14 thomas echo "G added-file" >> $testroot/stdout.expected
908 10604dce 2021-09-24 thomas echo "Merge of refs/heads/newbranch aborted" \
909 10604dce 2021-09-24 thomas >> $testroot/stdout.expected
911 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
913 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
914 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
915 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
919 10604dce 2021-09-24 thomas echo "delta" > $testroot/content.expected
920 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
921 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
923 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
924 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
925 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
929 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/content.expected
930 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
931 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
933 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
934 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
935 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
939 10604dce 2021-09-24 thomas echo "beta" > $testroot/content.expected
940 10604dce 2021-09-24 thomas cat $testroot/wt/beta > $testroot/content
941 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
943 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
944 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
945 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
949 10604dce 2021-09-24 thomas if [ -e $testroot/wt/epsilon/new ]; then
950 10604dce 2021-09-24 thomas echo "reverted file epsilon/new still exists on disk" >&2
951 10604dce 2021-09-24 thomas test_done "$testroot" "1"
955 10604dce 2021-09-24 thomas if [ -e $testroot/wt/symlink ]; then
956 10604dce 2021-09-24 thomas echo "reverted symlink still exists on disk" >&2
957 10604dce 2021-09-24 thomas test_done "$testroot" "1"
961 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
963 8641a332 2023-04-14 thomas echo "? added-file" > $testroot/stdout.expected
964 8641a332 2023-04-14 thomas echo "? unversioned-file" >> $testroot/stdout.expected
965 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
967 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
968 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
969 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
973 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
974 10604dce 2021-09-24 thomas echo "commit $master_commit (master)" > $testroot/stdout.expected
975 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
976 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
978 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
979 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
980 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
984 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
986 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
987 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
989 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
990 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
992 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
995 10604dce 2021-09-24 thomas test_merge_in_progress() {
996 10604dce 2021-09-24 thomas local testroot=`test_init merge_in_progress`
997 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
998 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1000 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1001 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1002 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1003 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1005 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1008 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1009 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1010 10604dce 2021-09-24 thomas return 1
1013 10604dce 2021-09-24 thomas # create a conflicting commit
1014 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1015 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1016 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1017 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1019 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1020 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1022 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1023 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1024 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1025 10604dce 2021-09-24 thomas return 1
1028 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1029 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1031 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1032 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1033 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1034 10604dce 2021-09-24 thomas return 1
1037 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1038 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $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 "got: conflicts must be resolved before merging can continue" \
1048 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1049 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1051 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1052 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1053 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1054 10604dce 2021-09-24 thomas return 1
1057 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1059 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1060 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1062 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1063 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1064 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1065 10604dce 2021-09-24 thomas return 1
1068 10604dce 2021-09-24 thomas for cmd in update commit histedit "rebase newbranch" \
1069 d8a7bd7d 2023-06-01 thomas "integrate newbranch" "merge newbranch" "stage alpha"; do
1070 10604dce 2021-09-24 thomas (cd $testroot/wt && got $cmd > $testroot/stdout \
1071 10604dce 2021-09-24 thomas 2> $testroot/stderr)
1073 d8a7bd7d 2023-06-01 thomas if [ $ret -eq 0 ]; then
1074 d8a7bd7d 2023-06-01 thomas echo "got $cmd succeeded unexpectedly" >&2
1075 d8a7bd7d 2023-06-01 thomas test_done "$testroot" "1"
1076 d8a7bd7d 2023-06-01 thomas return 1
1079 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
1080 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1082 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1083 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1084 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1085 10604dce 2021-09-24 thomas return 1
1088 10604dce 2021-09-24 thomas echo -n "got: a merge operation is in progress in this " \
1089 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1090 10604dce 2021-09-24 thomas echo "work tree and must be continued or aborted first" \
1091 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1092 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1094 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1095 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1096 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1097 10604dce 2021-09-24 thomas return 1
1101 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1104 10604dce 2021-09-24 thomas test_merge_path_prefix() {
1105 10604dce 2021-09-24 thomas local testroot=`test_init merge_path_prefix`
1106 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1107 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1109 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1110 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1111 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1112 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1114 10604dce 2021-09-24 thomas got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1115 10604dce 2021-09-24 thomas > /dev/null
1117 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1118 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1119 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1120 10604dce 2021-09-24 thomas return 1
1123 10604dce 2021-09-24 thomas # create a conflicting commit
1124 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1125 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1126 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1127 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1129 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1130 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1132 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1133 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1134 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1135 10604dce 2021-09-24 thomas return 1
1138 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1139 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1141 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1142 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1143 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1144 10604dce 2021-09-24 thomas return 1
1147 10604dce 2021-09-24 thomas echo -n "got: cannot merge branch which contains changes outside " \
1148 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1149 10604dce 2021-09-24 thomas echo "of this work tree's path prefix" >> $testroot/stderr.expected
1150 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1152 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1153 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1155 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1158 10604dce 2021-09-24 thomas test_merge_missing_file() {
1159 10604dce 2021-09-24 thomas local testroot=`test_init merge_missing_file`
1160 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1161 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1163 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1164 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1165 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1166 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha and delta"
1167 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1169 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1171 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1172 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1173 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1174 10604dce 2021-09-24 thomas return 1
1177 10604dce 2021-09-24 thomas # create a conflicting commit which renames alpha
1178 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1179 10604dce 2021-09-24 thomas (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1180 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "moving alpha on master"
1181 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1183 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1184 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1186 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1187 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1188 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1189 10604dce 2021-09-24 thomas return 1
1192 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1193 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1195 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1196 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1197 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1198 10604dce 2021-09-24 thomas return 1
1201 10604dce 2021-09-24 thomas echo "! alpha" > $testroot/stdout.expected
1202 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1203 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1204 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1205 0ef68859 2021-09-28 thomas echo "in the work tree: 1" >> $testroot/stdout.expected
1206 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1208 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1209 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1210 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1211 10604dce 2021-09-24 thomas return 1
1214 ba162991 2021-09-28 thomas echo -n "got: changes destined for some files " \
1215 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1216 10604dce 2021-09-24 thomas echo -n "were not yet merged and should be merged manually if " \
1217 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1218 10604dce 2021-09-24 thomas echo "required before the merge operation is continued" \
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
1228 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1230 10604dce 2021-09-24 thomas echo "M gamma/delta" > $testroot/stdout.expected
1231 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1233 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1234 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1235 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1236 2d7ce510 2021-09-24 thomas return 1
1239 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1242 2d7ce510 2021-09-24 thomas test_merge_no_op() {
1243 2d7ce510 2021-09-24 thomas local testroot=`test_init merge_no_op`
1244 2d7ce510 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1245 2d7ce510 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1247 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1248 2d7ce510 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1249 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1250 1678610c 2023-04-22 thomas local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1252 2d7ce510 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1254 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1255 2d7ce510 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1256 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1257 2d7ce510 2021-09-24 thomas return 1
1260 2d7ce510 2021-09-24 thomas # create a conflicting commit
1261 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1262 2d7ce510 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1263 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1264 2d7ce510 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1266 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1267 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1269 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1270 2d7ce510 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1271 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1272 2d7ce510 2021-09-24 thomas return 1
1275 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1276 2d7ce510 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1278 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1279 2d7ce510 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1280 2d7ce510 2021-09-24 thomas test_done "$testroot" "1"
1281 2d7ce510 2021-09-24 thomas return 1
1284 2d7ce510 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1285 2d7ce510 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1286 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1288 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1289 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1290 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1291 2d7ce510 2021-09-24 thomas return 1
1294 2d7ce510 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
1295 2d7ce510 2021-09-24 thomas > $testroot/stderr.expected
1296 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1298 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1299 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1300 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1301 2d7ce510 2021-09-24 thomas return 1
1304 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1306 2d7ce510 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1307 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1309 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1310 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1311 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1312 10604dce 2021-09-24 thomas return 1
1315 2d7ce510 2021-09-24 thomas # resolve the conflict by reverting all changes; now it is no-op merge
1316 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got revert alpha > /dev/null)
1318 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1319 2d7ce510 2021-09-24 thomas echo "got revert failed unexpectedly" >&2
1320 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1321 2d7ce510 2021-09-24 thomas return 1
1324 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout \
1325 2d7ce510 2021-09-24 thomas 2> $testroot/stderr)
1327 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1328 1678610c 2023-04-22 thomas echo "got merge failed unexpectedly" >&2
1329 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1330 2d7ce510 2021-09-24 thomas return 1
1333 1678610c 2023-04-22 thomas echo -n '' > $testroot/stderr.expected
1334 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1336 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1337 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1338 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1339 1678610c 2023-04-22 thomas return 1
1342 1678610c 2023-04-22 thomas local merge_commit=`git_show_head $testroot/repo`
1343 1678610c 2023-04-22 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1344 1678610c 2023-04-22 thomas > $testroot/stdout.expected
1345 1678610c 2023-04-22 thomas echo $merge_commit >> $testroot/stdout.expected
1347 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1349 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1350 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1351 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1352 2d7ce510 2021-09-24 thomas return 1
1355 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1357 2d7ce510 2021-09-24 thomas echo -n "" > $testroot/stdout.expected
1358 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1360 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1361 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1362 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1363 1678610c 2023-04-22 thomas return 1
1366 1678610c 2023-04-22 thomas # We should have created a merge commit with two parents.
1367 1678610c 2023-04-22 thomas got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1368 1678610c 2023-04-22 thomas > $testroot/stdout
1369 1678610c 2023-04-22 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1370 1678610c 2023-04-22 thomas echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1371 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1373 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1374 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1376 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1379 768705e3 2021-09-27 thomas test_merge_imported_branch() {
1380 768705e3 2021-09-27 thomas local testroot=`test_init merge_import`
1381 768705e3 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1382 768705e3 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1384 768705e3 2021-09-27 thomas # import a new sub-tree to the 'files' branch such that
1385 768705e3 2021-09-27 thomas # none of the files added here collide with existing ones
1386 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/there
1387 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/be/lots
1388 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/files
1389 768705e3 2021-09-27 thomas echo "there should" > $testroot/tree/there/should
1390 768705e3 2021-09-27 thomas echo "be lots of" > $testroot/tree/be/lots/of
1391 768705e3 2021-09-27 thomas echo "files here" > $testroot/tree/files/here
1392 768705e3 2021-09-27 thomas got import -r $testroot/repo -b files -m 'import files' \
1393 768705e3 2021-09-27 thomas $testroot/tree > /dev/null
1395 768705e3 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1397 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1398 768705e3 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1399 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1400 768705e3 2021-09-27 thomas return 1
1403 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1405 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1406 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1407 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1408 768705e3 2021-09-27 thomas return 1
1411 768705e3 2021-09-27 thomas local merge_commit0=`git_show_head $testroot/repo`
1412 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1413 768705e3 2021-09-27 thomas A be/lots/of
1414 768705e3 2021-09-27 thomas A files/here
1415 768705e3 2021-09-27 thomas A there/should
1416 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit0
1418 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1420 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1421 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1422 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1423 768705e3 2021-09-27 thomas return 1
1426 768705e3 2021-09-27 thomas # try to merge again while no new changes are available
1427 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1429 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1430 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1431 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1432 768705e3 2021-09-27 thomas return 1
1434 768705e3 2021-09-27 thomas echo "Already up-to-date" > $testroot/stdout.expected
1435 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1437 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1438 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1439 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1440 768705e3 2021-09-27 thomas return 1
1443 768705e3 2021-09-27 thomas # update the 'files' branch
1444 768705e3 2021-09-27 thomas (cd $testroot/repo && git reset -q --hard master)
1445 768705e3 2021-09-27 thomas (cd $testroot/repo && git checkout -q files)
1446 768705e3 2021-09-27 thomas echo "indeed" > $testroot/repo/indeed
1447 768705e3 2021-09-27 thomas (cd $testroot/repo && git add indeed)
1448 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "adding another file indeed"
1449 768705e3 2021-09-27 thomas echo "be lots and lots of" > $testroot/repo/be/lots/of
1450 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "lots of changes"
1452 768705e3 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1454 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1455 768705e3 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1456 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1457 768705e3 2021-09-27 thomas return 1
1460 768705e3 2021-09-27 thomas # we should now be able to merge more changes from files branch
1461 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1463 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1464 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1465 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1466 768705e3 2021-09-27 thomas return 1
1469 768705e3 2021-09-27 thomas local merge_commit1=`git_show_branch_head $testroot/repo master`
1470 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1471 768705e3 2021-09-27 thomas G be/lots/of
1472 768705e3 2021-09-27 thomas A indeed
1473 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit1
1476 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1478 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1479 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1481 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1484 ba34626b 2021-09-27 thomas test_merge_interrupt() {
1485 ba34626b 2021-09-27 thomas local testroot=`test_init merge_interrupt`
1486 ba34626b 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1487 ba34626b 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1489 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1490 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1491 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1492 ba34626b 2021-09-27 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1494 ba34626b 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1496 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1497 ba34626b 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1498 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1499 ba34626b 2021-09-27 thomas return 1
1502 ba34626b 2021-09-27 thomas # create a non-conflicting commit
1503 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q master)
1504 ba34626b 2021-09-27 thomas echo "modified beta on master" > $testroot/repo/beta
1505 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to beta on master"
1506 ba34626b 2021-09-27 thomas local master_commit=`git_show_head $testroot/repo`
1508 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1509 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1511 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1512 ba34626b 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1513 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1514 ba34626b 2021-09-27 thomas return 1
1517 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -n newbranch \
1518 ba34626b 2021-09-27 thomas > $testroot/stdout 2> $testroot/stderr)
1520 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1521 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1522 ba34626b 2021-09-27 thomas test_done "$testroot" "1"
1523 ba34626b 2021-09-27 thomas return 1
1526 ba34626b 2021-09-27 thomas echo "G alpha" > $testroot/stdout.expected
1527 ba34626b 2021-09-27 thomas echo "Merge of refs/heads/newbranch interrupted on request" \
1528 ba34626b 2021-09-27 thomas >> $testroot/stdout.expected
1529 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1531 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1532 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1533 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1534 ba34626b 2021-09-27 thomas return 1
1537 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1539 ba34626b 2021-09-27 thomas echo "M alpha" > $testroot/stdout.expected
1540 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1542 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1543 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1544 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1545 ba34626b 2021-09-27 thomas return 1
1548 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/content.expected
1549 ba34626b 2021-09-27 thomas cat $testroot/wt/alpha > $testroot/content
1550 ba34626b 2021-09-27 thomas cmp -s $testroot/content.expected $testroot/content
1552 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1553 ba34626b 2021-09-27 thomas diff -u $testroot/content.expected $testroot/content
1554 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1555 ba34626b 2021-09-27 thomas return 1
1558 ba34626b 2021-09-27 thomas # adjust merge result
1559 ba34626b 2021-09-27 thomas echo "adjusted merge result" > $testroot/wt/alpha
1561 ba34626b 2021-09-27 thomas # continue the merge
1562 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
1564 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1565 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1566 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1567 ba34626b 2021-09-27 thomas return 1
1570 ba34626b 2021-09-27 thomas local merge_commit=`git_show_head $testroot/repo`
1572 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
1573 ba34626b 2021-09-27 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1574 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
1575 ba34626b 2021-09-27 thomas echo $merge_commit >> $testroot/stdout.expected
1577 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1579 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1580 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1581 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1582 ba34626b 2021-09-27 thomas return 1
1585 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1587 ba34626b 2021-09-27 thomas echo -n > $testroot/stdout.expected
1588 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1590 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1591 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1592 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1593 ba34626b 2021-09-27 thomas return 1
1596 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1597 ba34626b 2021-09-27 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
1598 ba34626b 2021-09-27 thomas echo "commit $master_commit" >> $testroot/stdout.expected
1599 ba34626b 2021-09-27 thomas echo "commit $commit0" >> $testroot/stdout.expected
1600 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1602 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1603 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1604 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1605 ba34626b 2021-09-27 thomas return 1
1608 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > $testroot/stdout)
1610 ba34626b 2021-09-27 thomas echo 'Already up-to-date' > $testroot/stdout.expected
1611 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1613 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1614 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1615 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1616 ba34626b 2021-09-27 thomas return 1
1619 ba34626b 2021-09-27 thomas # We should have created a merge commit with two parents.
1620 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1621 ba34626b 2021-09-27 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1622 ba34626b 2021-09-27 thomas echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1623 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1625 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1626 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1628 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1631 a2c162eb 2022-10-30 thomas test_merge_umask() {
1632 a2c162eb 2022-10-30 thomas local testroot=`test_init merge_umask`
1634 a2c162eb 2022-10-30 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1635 a2c162eb 2022-10-30 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1636 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1637 a2c162eb 2022-10-30 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1638 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1640 a2c162eb 2022-10-30 thomas # diverge from newbranch
1641 a2c162eb 2022-10-30 thomas (cd "$testroot/repo" && git checkout -q master)
1642 a2c162eb 2022-10-30 thomas echo "modified beta on master" >$testroot/repo/beta
1643 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1645 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1647 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
1648 a2c162eb 2022-10-30 thomas (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1650 a2c162eb 2022-10-30 thomas for f in alpha gamma/delta; do
1651 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1652 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
1653 a2c162eb 2022-10-30 thomas echo "$f is not 0600 after merge" >&2
1654 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" >&2
1655 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
1659 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
1662 b16f1832 2023-02-21 thomas test_merge_gitconfig_author() {
1663 b16f1832 2023-02-21 thomas local testroot=`test_init merge_gitconfig_author`
1665 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.name 'Flan Luck')
1666 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1668 b16f1832 2023-02-21 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1669 b16f1832 2023-02-21 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1670 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1671 b16f1832 2023-02-21 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1672 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1674 b16f1832 2023-02-21 thomas # diverge from newbranch
1675 b16f1832 2023-02-21 thomas (cd "$testroot/repo" && git checkout -q master)
1676 b16f1832 2023-02-21 thomas echo "modified beta on master" >$testroot/repo/beta
1677 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1679 b16f1832 2023-02-21 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1681 b16f1832 2023-02-21 thomas # unset in a subshell to avoid affecting our environment
1682 b16f1832 2023-02-21 thomas (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1683 b16f1832 2023-02-21 thomas got merge newbranch > /dev/null)
1685 b16f1832 2023-02-21 thomas (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1687 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1688 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1689 b16f1832 2023-02-21 thomas return 1
1692 b16f1832 2023-02-21 thomas echo "from: Flan Luck <flan_luck@openbsd.org>" \
1693 b16f1832 2023-02-21 thomas > $testroot/stdout.expected
1694 b16f1832 2023-02-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1696 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1697 b16f1832 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1699 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1702 4434a15a 2023-06-22 thomas test_merge_fetched_branch() {
1703 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch`
1704 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1705 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1707 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1709 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1710 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1711 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1712 4434a15a 2023-06-22 thomas return 1
1715 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1716 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1717 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1719 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1721 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1722 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1723 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1724 4434a15a 2023-06-22 thomas return 1
1727 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1729 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1731 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1732 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1733 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1734 4434a15a 2023-06-22 thomas return 1
1737 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1739 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1740 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1741 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1742 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1743 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1744 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1746 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1748 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1749 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1750 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1751 4434a15a 2023-06-22 thomas return 1
1754 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1756 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1757 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1758 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1760 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update > /dev/null)
1761 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge origin/master > $testroot/stdout)
1762 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1764 4434a15a 2023-06-22 thomas cat > $testroot/stdout.expected <<EOF
1766 4434a15a 2023-06-22 thomas Merged refs/remotes/origin/master into refs/heads/master: $merge_commit_id
1769 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1771 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1772 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1774 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1777 4434a15a 2023-06-22 thomas test_merge_fetched_branch_remote() {
1778 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch_remote`
1779 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1780 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1782 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1784 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1785 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1786 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1787 4434a15a 2023-06-22 thomas return 1
1790 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1791 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1792 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1794 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1796 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1797 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1798 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1799 4434a15a 2023-06-22 thomas return 1
1802 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1804 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1806 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1807 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1808 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1809 4434a15a 2023-06-22 thomas return 1
1812 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1814 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1815 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1816 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1817 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1818 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1819 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1821 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1823 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1824 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1825 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1826 4434a15a 2023-06-22 thomas return 1
1829 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1831 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1832 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1833 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1835 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update -b origin/master > /dev/null)
1836 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge master > \
1837 4434a15a 2023-06-22 thomas $testroot/stdout 2> $testroot/stderr)
1838 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1840 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1842 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1844 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1845 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1846 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1847 4434a15a 2023-06-22 thomas return 1
1850 4434a15a 2023-06-22 thomas echo -n "got: work tree's current branch refs/remotes/origin/master " \
1851 4434a15a 2023-06-22 thomas > $testroot/stderr.expected
1852 4434a15a 2023-06-22 thomas echo -n 'is outside the "refs/heads/" reference namespace; ' \
1853 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1854 4434a15a 2023-06-22 thomas echo -n "update -b required: will not commit to a branch " \
1855 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1856 4434a15a 2023-06-22 thomas echo 'outside the "refs/heads/" reference namespace' \
1857 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1859 4434a15a 2023-06-22 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1861 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1862 4434a15a 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
1864 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1867 10604dce 2021-09-24 thomas test_parseargs "$@"
1868 10604dce 2021-09-24 thomas run_test test_merge_basic
1869 2b72f32d 2023-06-22 thomas run_test test_merge_forward
1870 2b72f32d 2023-06-22 thomas run_test test_merge_backward
1871 10604dce 2021-09-24 thomas run_test test_merge_continue
1872 fe3f264b 2023-06-08 thomas run_test test_merge_continue_new_commit
1873 10604dce 2021-09-24 thomas run_test test_merge_abort
1874 10604dce 2021-09-24 thomas run_test test_merge_in_progress
1875 10604dce 2021-09-24 thomas run_test test_merge_path_prefix
1876 10604dce 2021-09-24 thomas run_test test_merge_missing_file
1877 2d7ce510 2021-09-24 thomas run_test test_merge_no_op
1878 768705e3 2021-09-27 thomas run_test test_merge_imported_branch
1879 ba34626b 2021-09-27 thomas run_test test_merge_interrupt
1880 a2c162eb 2022-10-30 thomas run_test test_merge_umask
1881 b16f1832 2023-02-21 thomas run_test test_merge_gitconfig_author
1882 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch
1883 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch_remote