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"
418 2b72f32d 2023-06-22 thomas echo -n "got: merge is a fast-forward; " > $testroot/stderr.expected
419 2b72f32d 2023-06-22 thomas echo "this is incompatible with got merge -n" \
420 2b72f32d 2023-06-22 thomas >> $testroot/stderr.expected
421 2b72f32d 2023-06-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
423 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
424 2b72f32d 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
425 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
429 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
430 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
432 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
433 2b72f32d 2023-06-22 thomas echo "got merge failed unexpectedly" >&2
434 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
438 2b72f32d 2023-06-22 thomas echo "Forwarding refs/heads/master to refs/heads/newbranch" \
439 2b72f32d 2023-06-22 thomas > $testroot/stdout.expected
440 2b72f32d 2023-06-22 thomas echo "U beta" >> $testroot/stdout.expected
441 2b72f32d 2023-06-22 thomas echo "Updated to commit $commit2" \
442 2b72f32d 2023-06-22 thomas >> $testroot/stdout.expected
443 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
445 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
446 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
447 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
451 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
452 2b72f32d 2023-06-22 thomas echo -n "commit $commit2 " > $testroot/stdout.expected
453 2b72f32d 2023-06-22 thomas echo "(master, newbranch)" >> $testroot/stdout.expected
454 2b72f32d 2023-06-22 thomas echo "commit $commit1" >> $testroot/stdout.expected
455 2b72f32d 2023-06-22 thomas echo "commit $commit0" >> $testroot/stdout.expected
456 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
458 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
459 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
460 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
463 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
466 2b72f32d 2023-06-22 thomas test_merge_backward() {
467 2b72f32d 2023-06-22 thomas local testroot=`test_init merge_backward`
468 2b72f32d 2023-06-22 thomas local commit0=`git_show_head $testroot/repo`
470 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
471 2b72f32d 2023-06-22 thomas (cd $testroot/repo && git checkout -q master)
472 2b72f32d 2023-06-22 thomas echo "modified alpha on master" > $testroot/repo/alpha
473 2b72f32d 2023-06-22 thomas git_commit $testroot/repo -m "committing to alpha on master"
475 2b72f32d 2023-06-22 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
477 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
478 2b72f32d 2023-06-22 thomas echo "got checkout failed unexpectedly" >&2
479 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
483 2b72f32d 2023-06-22 thomas (cd $testroot/wt && got merge newbranch \
484 2b72f32d 2023-06-22 thomas > $testroot/stdout 2> $testroot/stderr)
486 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
487 2b72f32d 2023-06-22 thomas echo "got merge failed unexpectedly" >&2
488 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
491 2b72f32d 2023-06-22 thomas echo "Already up-to-date" > $testroot/stdout.expected
492 2b72f32d 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
494 2b72f32d 2023-06-22 thomas if [ $ret -ne 0 ]; then
495 2b72f32d 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
496 2b72f32d 2023-06-22 thomas test_done "$testroot" "$ret"
499 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
502 10604dce 2021-09-24 thomas test_merge_continue() {
503 10604dce 2021-09-24 thomas local testroot=`test_init merge_continue`
504 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
505 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
507 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
508 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
509 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
510 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
512 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
513 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
514 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
515 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
516 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
517 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
518 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
519 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
520 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
521 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
523 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
525 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
526 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
527 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
531 10604dce 2021-09-24 thomas # create a conflicting commit
532 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
533 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
534 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
535 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
537 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
538 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
540 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
541 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
542 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
546 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
547 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
549 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
550 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
551 10604dce 2021-09-24 thomas test_done "$testroot" "1"
555 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
556 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
557 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
558 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
559 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
560 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
562 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
563 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
564 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
568 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
569 10604dce 2021-09-24 thomas > $testroot/stderr.expected
570 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
572 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
573 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
574 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
578 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
580 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
581 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
582 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
583 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
584 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
586 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
587 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
588 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
592 10604dce 2021-09-24 thomas echo '<<<<<<<' > $testroot/content.expected
593 10604dce 2021-09-24 thomas echo "modified alpha on master" >> $testroot/content.expected
594 10604dce 2021-09-24 thomas echo "||||||| 3-way merge base: commit $commit0" \
595 10604dce 2021-09-24 thomas >> $testroot/content.expected
596 10604dce 2021-09-24 thomas echo "alpha" >> $testroot/content.expected
597 10604dce 2021-09-24 thomas echo "=======" >> $testroot/content.expected
598 10604dce 2021-09-24 thomas echo "modified alpha on branch" >> $testroot/content.expected
599 10604dce 2021-09-24 thomas echo ">>>>>>> merged change: commit $branch_commit3" \
600 10604dce 2021-09-24 thomas >> $testroot/content.expected
601 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
602 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
604 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
605 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
606 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
610 10604dce 2021-09-24 thomas # resolve the conflict
611 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/wt/alpha
613 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
615 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
616 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
617 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
621 10604dce 2021-09-24 thomas local merge_commit=`git_show_head $testroot/repo`
623 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
624 ae1e948a 2021-09-28 thomas echo "D beta" >> $testroot/stdout.expected
625 ae1e948a 2021-09-28 thomas echo "A epsilon/new" >> $testroot/stdout.expected
626 ae1e948a 2021-09-28 thomas echo "M gamma/delta" >> $testroot/stdout.expected
627 10604dce 2021-09-24 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
628 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
629 10604dce 2021-09-24 thomas echo $merge_commit >> $testroot/stdout.expected
631 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
633 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
634 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
635 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
639 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/content.expected
640 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
641 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
643 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
644 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
645 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
649 10604dce 2021-09-24 thomas echo "modified alpha by both branches" > $testroot/content.expected
650 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
651 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
653 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
654 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
655 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
659 10604dce 2021-09-24 thomas if [ -e $testroot/wt/beta ]; then
660 10604dce 2021-09-24 thomas echo "removed file beta still exists on disk" >&2
661 10604dce 2021-09-24 thomas test_done "$testroot" "1"
665 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/content.expected
666 10604dce 2021-09-24 thomas cat $testroot/wt/epsilon/new > $testroot/content
667 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
669 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
670 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
671 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
675 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
677 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
678 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
680 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
681 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
682 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
686 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
687 10604dce 2021-09-24 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
688 10604dce 2021-09-24 thomas echo "commit $master_commit" >> $testroot/stdout.expected
689 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
690 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
692 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
693 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
694 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
698 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
700 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
701 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
703 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
704 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
705 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
709 10604dce 2021-09-24 thomas # We should have created a merge commit with two parents.
710 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
711 10604dce 2021-09-24 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
712 10604dce 2021-09-24 thomas echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
713 fe3f264b 2023-06-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
715 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
716 fe3f264b 2023-06-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
718 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
721 fe3f264b 2023-06-08 thomas test_merge_continue_new_commit() {
722 fe3f264b 2023-06-08 thomas # "got merge -c" should refuse to run if the current branch tip has
723 fe3f264b 2023-06-08 thomas # changed since the merge was started, to avoid clobbering the changes.
724 fe3f264b 2023-06-08 thomas local testroot=`test_init merge_continue_new_commit`
726 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q -b newbranch)
727 fe3f264b 2023-06-08 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
728 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
730 fe3f264b 2023-06-08 thomas (cd $testroot/repo && git checkout -q master)
731 fe3f264b 2023-06-08 thomas echo "modified alpha on master" > $testroot/repo/alpha
732 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master"
734 fe3f264b 2023-06-08 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
736 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
737 fe3f264b 2023-06-08 thomas echo "got checkout failed unexpectedly" >&2
738 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
742 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -n newbranch >/dev/null)
744 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
745 fe3f264b 2023-06-08 thomas echo "got merge failed unexpectedly" >&2
746 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
750 fe3f264b 2023-06-08 thomas echo "modified alpha again on master" > $testroot/repo/alpha
751 fe3f264b 2023-06-08 thomas git_commit $testroot/repo -m "committing to alpha on master again"
753 fe3f264b 2023-06-08 thomas (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
755 fe3f264b 2023-06-08 thomas if [ $ret -eq 0 ]; then
756 fe3f264b 2023-06-08 thomas echo "got merge succeeded unexpectedly" >&2
757 fe3f264b 2023-06-08 thomas test_done "$testroot" "1"
761 fe3f264b 2023-06-08 thomas echo -n > $testroot/stdout.expected
762 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
764 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
765 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
766 fe3f264b 2023-06-08 thomas test_done "$testroot" "$ret"
770 fe3f264b 2023-06-08 thomas echo -n "got: merging cannot proceed because the work tree is no " \
771 fe3f264b 2023-06-08 thomas > $testroot/stderr.expected
772 fe3f264b 2023-06-08 thomas echo "longer up-to-date; merge must be aborted and retried" \
773 fe3f264b 2023-06-08 thomas >> $testroot/stderr.expected
774 fe3f264b 2023-06-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
776 fe3f264b 2023-06-08 thomas if [ $ret -ne 0 ]; then
777 fe3f264b 2023-06-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
779 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
782 10604dce 2021-09-24 thomas test_merge_abort() {
783 10604dce 2021-09-24 thomas local testroot=`test_init merge_abort`
784 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
785 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
787 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
788 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
789 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
790 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
792 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
793 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
794 10604dce 2021-09-24 thomas local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
795 10604dce 2021-09-24 thomas (cd $testroot/repo && git rm -q beta)
796 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "removing beta on newbranch"
797 10604dce 2021-09-24 thomas local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
798 10604dce 2021-09-24 thomas echo "new file on branch" > $testroot/repo/epsilon/new
799 10604dce 2021-09-24 thomas (cd $testroot/repo && git add epsilon/new)
800 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding new file on newbranch"
801 10604dce 2021-09-24 thomas local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
802 10604dce 2021-09-24 thomas (cd $testroot/repo && ln -s alpha symlink && git add symlink)
803 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "adding symlink on newbranch"
804 10604dce 2021-09-24 thomas local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
806 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
808 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
809 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
810 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
814 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
815 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
817 10604dce 2021-09-24 thomas # create a conflicting commit
818 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
819 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
820 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
821 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
823 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
824 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
826 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
827 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
828 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
832 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
833 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
835 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
836 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
837 10604dce 2021-09-24 thomas test_done "$testroot" "1"
841 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
842 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
843 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
844 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
845 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
846 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
847 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
849 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
850 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
851 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
855 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
856 10604dce 2021-09-24 thomas > $testroot/stderr.expected
857 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
859 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
860 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
861 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
865 8641a332 2023-04-14 thomas # unrelated added file added during conflict resolution
866 8641a332 2023-04-14 thomas touch $testroot/wt/added-file
867 8641a332 2023-04-14 thomas (cd $testroot/wt && got add added-file > /dev/null)
869 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
871 8641a332 2023-04-14 thomas echo "A added-file" > $testroot/stdout.expected
872 8641a332 2023-04-14 thomas echo "C alpha" >> $testroot/stdout.expected
873 10604dce 2021-09-24 thomas echo "D beta" >> $testroot/stdout.expected
874 10604dce 2021-09-24 thomas echo "A epsilon/new" >> $testroot/stdout.expected
875 10604dce 2021-09-24 thomas echo "M gamma/delta" >> $testroot/stdout.expected
876 10604dce 2021-09-24 thomas echo "A symlink" >> $testroot/stdout.expected
877 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
878 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
880 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
881 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
882 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
886 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge -a > $testroot/stdout)
888 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
889 10604dce 2021-09-24 thomas echo "got merge failed unexpectedly" >&2
890 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
894 8641a332 2023-04-14 thomas echo "R added-file" > $testroot/stdout.expected
895 8641a332 2023-04-14 thomas echo "R alpha" >> $testroot/stdout.expected
896 10604dce 2021-09-24 thomas echo "R beta" >> $testroot/stdout.expected
897 10604dce 2021-09-24 thomas echo "R epsilon/new" >> $testroot/stdout.expected
898 10604dce 2021-09-24 thomas echo "R gamma/delta" >> $testroot/stdout.expected
899 10604dce 2021-09-24 thomas echo "R symlink" >> $testroot/stdout.expected
900 8641a332 2023-04-14 thomas echo "G added-file" >> $testroot/stdout.expected
901 10604dce 2021-09-24 thomas echo "Merge of refs/heads/newbranch aborted" \
902 10604dce 2021-09-24 thomas >> $testroot/stdout.expected
904 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
906 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
907 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
908 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
912 10604dce 2021-09-24 thomas echo "delta" > $testroot/content.expected
913 10604dce 2021-09-24 thomas cat $testroot/wt/gamma/delta > $testroot/content
914 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
916 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
917 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
918 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
922 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/content.expected
923 10604dce 2021-09-24 thomas cat $testroot/wt/alpha > $testroot/content
924 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
926 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
927 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
928 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
932 10604dce 2021-09-24 thomas echo "beta" > $testroot/content.expected
933 10604dce 2021-09-24 thomas cat $testroot/wt/beta > $testroot/content
934 10604dce 2021-09-24 thomas cmp -s $testroot/content.expected $testroot/content
936 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
937 10604dce 2021-09-24 thomas diff -u $testroot/content.expected $testroot/content
938 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
942 10604dce 2021-09-24 thomas if [ -e $testroot/wt/epsilon/new ]; then
943 10604dce 2021-09-24 thomas echo "reverted file epsilon/new still exists on disk" >&2
944 10604dce 2021-09-24 thomas test_done "$testroot" "1"
948 10604dce 2021-09-24 thomas if [ -e $testroot/wt/symlink ]; then
949 10604dce 2021-09-24 thomas echo "reverted symlink still exists on disk" >&2
950 10604dce 2021-09-24 thomas test_done "$testroot" "1"
954 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
956 8641a332 2023-04-14 thomas echo "? added-file" > $testroot/stdout.expected
957 8641a332 2023-04-14 thomas echo "? unversioned-file" >> $testroot/stdout.expected
958 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
960 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
961 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
962 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
966 10604dce 2021-09-24 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
967 10604dce 2021-09-24 thomas echo "commit $master_commit (master)" > $testroot/stdout.expected
968 10604dce 2021-09-24 thomas echo "commit $commit0" >> $testroot/stdout.expected
969 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
971 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
972 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
973 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
977 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > $testroot/stdout)
979 10604dce 2021-09-24 thomas echo 'Already up-to-date' > $testroot/stdout.expected
980 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
982 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
983 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
985 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
988 10604dce 2021-09-24 thomas test_merge_in_progress() {
989 10604dce 2021-09-24 thomas local testroot=`test_init merge_in_progress`
990 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
991 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
993 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
994 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
995 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
996 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
998 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1000 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1001 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1002 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1003 10604dce 2021-09-24 thomas return 1
1006 10604dce 2021-09-24 thomas # create a conflicting commit
1007 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1008 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1009 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1010 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1012 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1013 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1015 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1016 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
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 newbranch \
1022 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1024 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1025 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1026 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1027 10604dce 2021-09-24 thomas return 1
1030 10604dce 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1031 10604dce 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1032 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1034 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1035 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1036 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1037 10604dce 2021-09-24 thomas return 1
1040 10604dce 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
1041 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1042 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1044 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1045 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1046 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1047 10604dce 2021-09-24 thomas return 1
1050 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1052 10604dce 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1053 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1055 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1056 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1057 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1058 10604dce 2021-09-24 thomas return 1
1061 10604dce 2021-09-24 thomas for cmd in update commit histedit "rebase newbranch" \
1062 d8a7bd7d 2023-06-01 thomas "integrate newbranch" "merge newbranch" "stage alpha"; do
1063 10604dce 2021-09-24 thomas (cd $testroot/wt && got $cmd > $testroot/stdout \
1064 10604dce 2021-09-24 thomas 2> $testroot/stderr)
1066 d8a7bd7d 2023-06-01 thomas if [ $ret -eq 0 ]; then
1067 d8a7bd7d 2023-06-01 thomas echo "got $cmd succeeded unexpectedly" >&2
1068 d8a7bd7d 2023-06-01 thomas test_done "$testroot" "1"
1069 d8a7bd7d 2023-06-01 thomas return 1
1072 10604dce 2021-09-24 thomas echo -n > $testroot/stdout.expected
1073 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1075 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1076 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1077 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1078 10604dce 2021-09-24 thomas return 1
1081 10604dce 2021-09-24 thomas echo -n "got: a merge operation is in progress in this " \
1082 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1083 10604dce 2021-09-24 thomas echo "work tree and must be continued or aborted first" \
1084 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1085 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1087 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1088 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1089 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1090 10604dce 2021-09-24 thomas return 1
1094 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1097 10604dce 2021-09-24 thomas test_merge_path_prefix() {
1098 10604dce 2021-09-24 thomas local testroot=`test_init merge_path_prefix`
1099 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1100 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1102 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1103 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1104 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1105 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1107 10604dce 2021-09-24 thomas got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1108 10604dce 2021-09-24 thomas > /dev/null
1110 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1111 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1112 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1113 10604dce 2021-09-24 thomas return 1
1116 10604dce 2021-09-24 thomas # create a conflicting commit
1117 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1118 10604dce 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1119 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1120 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1122 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1123 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1125 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1126 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1127 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1128 10604dce 2021-09-24 thomas return 1
1131 10604dce 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1132 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1134 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1135 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1136 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1137 10604dce 2021-09-24 thomas return 1
1140 10604dce 2021-09-24 thomas echo -n "got: cannot merge branch which contains changes outside " \
1141 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1142 10604dce 2021-09-24 thomas echo "of this work tree's path prefix" >> $testroot/stderr.expected
1143 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1145 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1146 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1148 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1151 10604dce 2021-09-24 thomas test_merge_missing_file() {
1152 10604dce 2021-09-24 thomas local testroot=`test_init merge_missing_file`
1153 10604dce 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1154 10604dce 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1156 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1157 10604dce 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1158 10604dce 2021-09-24 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1159 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha and delta"
1160 10604dce 2021-09-24 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1162 10604dce 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1164 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1165 10604dce 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1166 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1167 10604dce 2021-09-24 thomas return 1
1170 10604dce 2021-09-24 thomas # create a conflicting commit which renames alpha
1171 10604dce 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1172 10604dce 2021-09-24 thomas (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1173 10604dce 2021-09-24 thomas git_commit $testroot/repo -m "moving alpha on master"
1174 10604dce 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1176 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1177 10604dce 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1179 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1180 10604dce 2021-09-24 thomas echo "got update failed unexpectedly" >&2
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 merge newbranch \
1186 10604dce 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1188 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1189 10604dce 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1190 10604dce 2021-09-24 thomas test_done "$testroot" "1"
1191 10604dce 2021-09-24 thomas return 1
1194 10604dce 2021-09-24 thomas echo "! alpha" > $testroot/stdout.expected
1195 10604dce 2021-09-24 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1196 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1197 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1198 0ef68859 2021-09-28 thomas echo "in the work tree: 1" >> $testroot/stdout.expected
1199 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1201 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1202 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1203 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1204 10604dce 2021-09-24 thomas return 1
1207 ba162991 2021-09-28 thomas echo -n "got: changes destined for some files " \
1208 10604dce 2021-09-24 thomas > $testroot/stderr.expected
1209 10604dce 2021-09-24 thomas echo -n "were not yet merged and should be merged manually if " \
1210 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1211 10604dce 2021-09-24 thomas echo "required before the merge operation is continued" \
1212 10604dce 2021-09-24 thomas >> $testroot/stderr.expected
1213 10604dce 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1215 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1216 10604dce 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1217 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1218 10604dce 2021-09-24 thomas return 1
1221 10604dce 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1223 10604dce 2021-09-24 thomas echo "M gamma/delta" > $testroot/stdout.expected
1224 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1226 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1227 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1228 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1229 2d7ce510 2021-09-24 thomas return 1
1232 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1235 2d7ce510 2021-09-24 thomas test_merge_no_op() {
1236 2d7ce510 2021-09-24 thomas local testroot=`test_init merge_no_op`
1237 2d7ce510 2021-09-24 thomas local commit0=`git_show_head $testroot/repo`
1238 2d7ce510 2021-09-24 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1240 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1241 2d7ce510 2021-09-24 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1242 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1243 1678610c 2023-04-22 thomas local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1245 2d7ce510 2021-09-24 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1247 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1248 2d7ce510 2021-09-24 thomas echo "got checkout failed unexpectedly" >&2
1249 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1250 2d7ce510 2021-09-24 thomas return 1
1253 2d7ce510 2021-09-24 thomas # create a conflicting commit
1254 2d7ce510 2021-09-24 thomas (cd $testroot/repo && git checkout -q master)
1255 2d7ce510 2021-09-24 thomas echo "modified alpha on master" > $testroot/repo/alpha
1256 2d7ce510 2021-09-24 thomas git_commit $testroot/repo -m "committing to alpha on master"
1257 2d7ce510 2021-09-24 thomas local master_commit=`git_show_head $testroot/repo`
1259 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1260 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got update > /dev/null)
1262 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1263 2d7ce510 2021-09-24 thomas echo "got update failed unexpectedly" >&2
1264 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1265 2d7ce510 2021-09-24 thomas return 1
1268 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge newbranch \
1269 2d7ce510 2021-09-24 thomas > $testroot/stdout 2> $testroot/stderr)
1271 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1272 2d7ce510 2021-09-24 thomas echo "got merge succeeded unexpectedly" >&2
1273 2d7ce510 2021-09-24 thomas test_done "$testroot" "1"
1274 2d7ce510 2021-09-24 thomas return 1
1277 2d7ce510 2021-09-24 thomas echo "C alpha" >> $testroot/stdout.expected
1278 2d7ce510 2021-09-24 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1279 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1281 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1282 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1283 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1284 2d7ce510 2021-09-24 thomas return 1
1287 2d7ce510 2021-09-24 thomas echo "got: conflicts must be resolved before merging can continue" \
1288 2d7ce510 2021-09-24 thomas > $testroot/stderr.expected
1289 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1291 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1292 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1293 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1294 2d7ce510 2021-09-24 thomas return 1
1297 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1299 2d7ce510 2021-09-24 thomas echo "C alpha" > $testroot/stdout.expected
1300 10604dce 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1302 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1303 10604dce 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1304 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1305 10604dce 2021-09-24 thomas return 1
1308 2d7ce510 2021-09-24 thomas # resolve the conflict by reverting all changes; now it is no-op merge
1309 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got revert alpha > /dev/null)
1311 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1312 2d7ce510 2021-09-24 thomas echo "got revert failed unexpectedly" >&2
1313 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1314 2d7ce510 2021-09-24 thomas return 1
1317 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got merge -c > $testroot/stdout \
1318 2d7ce510 2021-09-24 thomas 2> $testroot/stderr)
1320 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1321 1678610c 2023-04-22 thomas echo "got merge failed unexpectedly" >&2
1322 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1323 2d7ce510 2021-09-24 thomas return 1
1326 1678610c 2023-04-22 thomas echo -n '' > $testroot/stderr.expected
1327 2d7ce510 2021-09-24 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1329 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1330 2d7ce510 2021-09-24 thomas diff -u $testroot/stderr.expected $testroot/stderr
1331 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1332 1678610c 2023-04-22 thomas return 1
1335 1678610c 2023-04-22 thomas local merge_commit=`git_show_head $testroot/repo`
1336 1678610c 2023-04-22 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1337 1678610c 2023-04-22 thomas > $testroot/stdout.expected
1338 1678610c 2023-04-22 thomas echo $merge_commit >> $testroot/stdout.expected
1340 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1342 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1343 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1344 2d7ce510 2021-09-24 thomas test_done "$testroot" "$ret"
1345 2d7ce510 2021-09-24 thomas return 1
1348 2d7ce510 2021-09-24 thomas (cd $testroot/wt && got status > $testroot/stdout)
1350 2d7ce510 2021-09-24 thomas echo -n "" > $testroot/stdout.expected
1351 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1353 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1354 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1355 1678610c 2023-04-22 thomas test_done "$testroot" "$ret"
1356 1678610c 2023-04-22 thomas return 1
1359 1678610c 2023-04-22 thomas # We should have created a merge commit with two parents.
1360 1678610c 2023-04-22 thomas got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1361 1678610c 2023-04-22 thomas > $testroot/stdout
1362 1678610c 2023-04-22 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1363 1678610c 2023-04-22 thomas echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1364 1678610c 2023-04-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1366 1678610c 2023-04-22 thomas if [ $ret -ne 0 ]; then
1367 1678610c 2023-04-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1369 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1372 768705e3 2021-09-27 thomas test_merge_imported_branch() {
1373 768705e3 2021-09-27 thomas local testroot=`test_init merge_import`
1374 768705e3 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1375 768705e3 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1377 768705e3 2021-09-27 thomas # import a new sub-tree to the 'files' branch such that
1378 768705e3 2021-09-27 thomas # none of the files added here collide with existing ones
1379 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/there
1380 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/be/lots
1381 768705e3 2021-09-27 thomas mkdir -p $testroot/tree/files
1382 768705e3 2021-09-27 thomas echo "there should" > $testroot/tree/there/should
1383 768705e3 2021-09-27 thomas echo "be lots of" > $testroot/tree/be/lots/of
1384 768705e3 2021-09-27 thomas echo "files here" > $testroot/tree/files/here
1385 768705e3 2021-09-27 thomas got import -r $testroot/repo -b files -m 'import files' \
1386 768705e3 2021-09-27 thomas $testroot/tree > /dev/null
1388 768705e3 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1391 768705e3 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1392 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1393 768705e3 2021-09-27 thomas return 1
1396 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1398 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1399 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1400 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1401 768705e3 2021-09-27 thomas return 1
1404 768705e3 2021-09-27 thomas local merge_commit0=`git_show_head $testroot/repo`
1405 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1406 768705e3 2021-09-27 thomas A be/lots/of
1407 768705e3 2021-09-27 thomas A files/here
1408 768705e3 2021-09-27 thomas A there/should
1409 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit0
1411 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1413 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1414 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1415 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1416 768705e3 2021-09-27 thomas return 1
1419 768705e3 2021-09-27 thomas # try to merge again while no new changes are available
1420 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1422 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1423 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1424 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1425 768705e3 2021-09-27 thomas return 1
1427 768705e3 2021-09-27 thomas echo "Already up-to-date" > $testroot/stdout.expected
1428 2d7ce510 2021-09-24 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1430 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1431 2d7ce510 2021-09-24 thomas diff -u $testroot/stdout.expected $testroot/stdout
1432 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1433 768705e3 2021-09-27 thomas return 1
1436 768705e3 2021-09-27 thomas # update the 'files' branch
1437 768705e3 2021-09-27 thomas (cd $testroot/repo && git reset -q --hard master)
1438 768705e3 2021-09-27 thomas (cd $testroot/repo && git checkout -q files)
1439 768705e3 2021-09-27 thomas echo "indeed" > $testroot/repo/indeed
1440 768705e3 2021-09-27 thomas (cd $testroot/repo && git add indeed)
1441 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "adding another file indeed"
1442 768705e3 2021-09-27 thomas echo "be lots and lots of" > $testroot/repo/be/lots/of
1443 768705e3 2021-09-27 thomas git_commit $testroot/repo -m "lots of changes"
1445 768705e3 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1447 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1448 768705e3 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1449 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1450 768705e3 2021-09-27 thomas return 1
1453 768705e3 2021-09-27 thomas # we should now be able to merge more changes from files branch
1454 768705e3 2021-09-27 thomas (cd $testroot/wt && got merge files > $testroot/stdout)
1456 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1457 768705e3 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1458 768705e3 2021-09-27 thomas test_done "$testroot" "$ret"
1459 768705e3 2021-09-27 thomas return 1
1462 768705e3 2021-09-27 thomas local merge_commit1=`git_show_branch_head $testroot/repo master`
1463 768705e3 2021-09-27 thomas cat > $testroot/stdout.expected <<EOF
1464 768705e3 2021-09-27 thomas G be/lots/of
1465 768705e3 2021-09-27 thomas A indeed
1466 768705e3 2021-09-27 thomas Merged refs/heads/files into refs/heads/master: $merge_commit1
1469 768705e3 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1471 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1472 768705e3 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1474 10604dce 2021-09-24 thomas test_done "$testroot" "$ret"
1477 ba34626b 2021-09-27 thomas test_merge_interrupt() {
1478 ba34626b 2021-09-27 thomas local testroot=`test_init merge_interrupt`
1479 ba34626b 2021-09-27 thomas local commit0=`git_show_head $testroot/repo`
1480 ba34626b 2021-09-27 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1482 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1483 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1484 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to alpha on newbranch"
1485 ba34626b 2021-09-27 thomas local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1487 ba34626b 2021-09-27 thomas got checkout -b master $testroot/repo $testroot/wt > /dev/null
1489 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1490 ba34626b 2021-09-27 thomas echo "got checkout failed unexpectedly" >&2
1491 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1492 ba34626b 2021-09-27 thomas return 1
1495 ba34626b 2021-09-27 thomas # create a non-conflicting commit
1496 ba34626b 2021-09-27 thomas (cd $testroot/repo && git checkout -q master)
1497 ba34626b 2021-09-27 thomas echo "modified beta on master" > $testroot/repo/beta
1498 ba34626b 2021-09-27 thomas git_commit $testroot/repo -m "committing to beta on master"
1499 ba34626b 2021-09-27 thomas local master_commit=`git_show_head $testroot/repo`
1501 b6b86fd1 2022-08-30 thomas # need an up-to-date work tree for 'got merge'
1502 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > /dev/null)
1504 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1505 ba34626b 2021-09-27 thomas echo "got update failed unexpectedly" >&2
1506 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1507 ba34626b 2021-09-27 thomas return 1
1510 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -n newbranch \
1511 ba34626b 2021-09-27 thomas > $testroot/stdout 2> $testroot/stderr)
1513 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1514 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1515 ba34626b 2021-09-27 thomas test_done "$testroot" "1"
1516 ba34626b 2021-09-27 thomas return 1
1519 ba34626b 2021-09-27 thomas echo "G alpha" > $testroot/stdout.expected
1520 ba34626b 2021-09-27 thomas echo "Merge of refs/heads/newbranch interrupted on request" \
1521 ba34626b 2021-09-27 thomas >> $testroot/stdout.expected
1522 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1524 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1525 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1526 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1527 ba34626b 2021-09-27 thomas return 1
1530 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1532 ba34626b 2021-09-27 thomas echo "M alpha" > $testroot/stdout.expected
1533 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1535 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1536 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1537 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1538 ba34626b 2021-09-27 thomas return 1
1541 ba34626b 2021-09-27 thomas echo "modified alpha on branch" > $testroot/content.expected
1542 ba34626b 2021-09-27 thomas cat $testroot/wt/alpha > $testroot/content
1543 ba34626b 2021-09-27 thomas cmp -s $testroot/content.expected $testroot/content
1545 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1546 ba34626b 2021-09-27 thomas diff -u $testroot/content.expected $testroot/content
1547 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1548 ba34626b 2021-09-27 thomas return 1
1551 ba34626b 2021-09-27 thomas # adjust merge result
1552 ba34626b 2021-09-27 thomas echo "adjusted merge result" > $testroot/wt/alpha
1554 ba34626b 2021-09-27 thomas # continue the merge
1555 ba34626b 2021-09-27 thomas (cd $testroot/wt && got merge -c > $testroot/stdout)
1557 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1558 ba34626b 2021-09-27 thomas echo "got merge failed unexpectedly" >&2
1559 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1560 ba34626b 2021-09-27 thomas return 1
1563 ba34626b 2021-09-27 thomas local merge_commit=`git_show_head $testroot/repo`
1565 ae1e948a 2021-09-28 thomas echo "M alpha" > $testroot/stdout.expected
1566 ba34626b 2021-09-27 thomas echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1567 ae1e948a 2021-09-28 thomas >> $testroot/stdout.expected
1568 ba34626b 2021-09-27 thomas echo $merge_commit >> $testroot/stdout.expected
1570 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1572 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1573 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1574 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1575 ba34626b 2021-09-27 thomas return 1
1578 ba34626b 2021-09-27 thomas (cd $testroot/wt && got status > $testroot/stdout)
1580 ba34626b 2021-09-27 thomas echo -n > $testroot/stdout.expected
1581 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1583 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1584 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1585 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1586 ba34626b 2021-09-27 thomas return 1
1589 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1590 ba34626b 2021-09-27 thomas echo "commit $merge_commit (master)" > $testroot/stdout.expected
1591 ba34626b 2021-09-27 thomas echo "commit $master_commit" >> $testroot/stdout.expected
1592 ba34626b 2021-09-27 thomas echo "commit $commit0" >> $testroot/stdout.expected
1593 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1595 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1596 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1597 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1598 ba34626b 2021-09-27 thomas return 1
1601 ba34626b 2021-09-27 thomas (cd $testroot/wt && got update > $testroot/stdout)
1603 ba34626b 2021-09-27 thomas echo 'Already up-to-date' > $testroot/stdout.expected
1604 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1606 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1607 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1608 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1609 ba34626b 2021-09-27 thomas return 1
1612 ba34626b 2021-09-27 thomas # We should have created a merge commit with two parents.
1613 ba34626b 2021-09-27 thomas (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1614 ba34626b 2021-09-27 thomas echo "parent 1: $master_commit" > $testroot/stdout.expected
1615 ba34626b 2021-09-27 thomas echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1616 ba34626b 2021-09-27 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1618 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1619 ba34626b 2021-09-27 thomas diff -u $testroot/stdout.expected $testroot/stdout
1621 ba34626b 2021-09-27 thomas test_done "$testroot" "$ret"
1624 a2c162eb 2022-10-30 thomas test_merge_umask() {
1625 a2c162eb 2022-10-30 thomas local testroot=`test_init merge_umask`
1627 a2c162eb 2022-10-30 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1628 a2c162eb 2022-10-30 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1629 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1630 a2c162eb 2022-10-30 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1631 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1633 a2c162eb 2022-10-30 thomas # diverge from newbranch
1634 a2c162eb 2022-10-30 thomas (cd "$testroot/repo" && git checkout -q master)
1635 a2c162eb 2022-10-30 thomas echo "modified beta on master" >$testroot/repo/beta
1636 a2c162eb 2022-10-30 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1638 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1640 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
1641 a2c162eb 2022-10-30 thomas (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1643 a2c162eb 2022-10-30 thomas for f in alpha gamma/delta; do
1644 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1645 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
1646 a2c162eb 2022-10-30 thomas echo "$f is not 0600 after merge" >&2
1647 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" >&2
1648 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
1652 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
1655 b16f1832 2023-02-21 thomas test_merge_gitconfig_author() {
1656 b16f1832 2023-02-21 thomas local testroot=`test_init merge_gitconfig_author`
1658 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.name 'Flan Luck')
1659 b16f1832 2023-02-21 thomas (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1661 b16f1832 2023-02-21 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1662 b16f1832 2023-02-21 thomas echo "modified alpha on branch" >$testroot/repo/alpha
1663 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing alpha on newbranch"
1664 b16f1832 2023-02-21 thomas echo "modified delta on branch" >$testroot/repo/gamma/delta
1665 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing delta on newbranch"
1667 b16f1832 2023-02-21 thomas # diverge from newbranch
1668 b16f1832 2023-02-21 thomas (cd "$testroot/repo" && git checkout -q master)
1669 b16f1832 2023-02-21 thomas echo "modified beta on master" >$testroot/repo/beta
1670 b16f1832 2023-02-21 thomas git_commit "$testroot/repo" -m "committing zeto no master"
1672 b16f1832 2023-02-21 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1674 b16f1832 2023-02-21 thomas # unset in a subshell to avoid affecting our environment
1675 b16f1832 2023-02-21 thomas (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1676 b16f1832 2023-02-21 thomas got merge newbranch > /dev/null)
1678 b16f1832 2023-02-21 thomas (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1680 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1681 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1682 b16f1832 2023-02-21 thomas return 1
1685 b16f1832 2023-02-21 thomas echo "from: Flan Luck <flan_luck@openbsd.org>" \
1686 b16f1832 2023-02-21 thomas > $testroot/stdout.expected
1687 b16f1832 2023-02-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1689 b16f1832 2023-02-21 thomas if [ $ret -ne 0 ]; then
1690 b16f1832 2023-02-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1692 b16f1832 2023-02-21 thomas test_done "$testroot" "$ret"
1695 4434a15a 2023-06-22 thomas test_merge_fetched_branch() {
1696 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch`
1697 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1698 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1700 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1702 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1703 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1704 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1705 4434a15a 2023-06-22 thomas return 1
1708 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1709 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1710 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1712 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1714 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1715 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1716 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1717 4434a15a 2023-06-22 thomas return 1
1720 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1722 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1724 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1725 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1726 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1727 4434a15a 2023-06-22 thomas return 1
1730 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1732 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1733 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1734 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1735 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1736 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1737 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1739 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1741 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1742 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1743 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1744 4434a15a 2023-06-22 thomas return 1
1747 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1749 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1750 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1751 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1753 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update > /dev/null)
1754 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge origin/master > $testroot/stdout)
1755 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1757 4434a15a 2023-06-22 thomas cat > $testroot/stdout.expected <<EOF
1759 4434a15a 2023-06-22 thomas Merged refs/remotes/origin/master into refs/heads/master: $merge_commit_id
1762 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1764 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1765 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1767 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1770 4434a15a 2023-06-22 thomas test_merge_fetched_branch_remote() {
1771 4434a15a 2023-06-22 thomas local testroot=`test_init merge_fetched_branch_remote`
1772 4434a15a 2023-06-22 thomas local testurl=ssh://127.0.0.1/$testroot
1773 4434a15a 2023-06-22 thomas local commit_id=`git_show_head $testroot/repo`
1775 4434a15a 2023-06-22 thomas got clone -q $testurl/repo $testroot/repo-clone
1777 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1778 4434a15a 2023-06-22 thomas echo "got clone command failed unexpectedly" >&2
1779 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1780 4434a15a 2023-06-22 thomas return 1
1783 4434a15a 2023-06-22 thomas echo "modified alpha" > $testroot/repo/alpha
1784 4434a15a 2023-06-22 thomas git_commit $testroot/repo -m "modified alpha"
1785 4434a15a 2023-06-22 thomas local commit_id2=`git_show_head $testroot/repo`
1787 4434a15a 2023-06-22 thomas got fetch -q -r $testroot/repo-clone > $testroot/stdout
1789 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1790 4434a15a 2023-06-22 thomas echo "got fetch command failed unexpectedly" >&2
1791 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1792 4434a15a 2023-06-22 thomas return 1
1795 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1797 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1799 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1800 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1801 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1802 4434a15a 2023-06-22 thomas return 1
1805 4434a15a 2023-06-22 thomas got ref -l -r $testroot/repo-clone > $testroot/stdout
1807 4434a15a 2023-06-22 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1808 4434a15a 2023-06-22 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1809 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1810 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1811 4434a15a 2023-06-22 thomas echo "refs/remotes/origin/master: $commit_id2" \
1812 4434a15a 2023-06-22 thomas >> $testroot/stdout.expected
1814 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1816 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1817 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1818 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1819 4434a15a 2023-06-22 thomas return 1
1822 4434a15a 2023-06-22 thomas got checkout $testroot/repo-clone $testroot/wt > /dev/null
1824 4434a15a 2023-06-22 thomas echo "modified beta" > $testroot/wt/beta
1825 4434a15a 2023-06-22 thomas (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1826 4434a15a 2023-06-22 thomas local commit_id3=`git_show_head $testroot/repo-clone`
1828 4434a15a 2023-06-22 thomas (cd $testroot/wt && got update -b origin/master > /dev/null)
1829 4434a15a 2023-06-22 thomas (cd $testroot/wt && got merge master > \
1830 4434a15a 2023-06-22 thomas $testroot/stdout 2> $testroot/stderr)
1831 4434a15a 2023-06-22 thomas local merge_commit_id=`git_show_head $testroot/repo-clone`
1833 4434a15a 2023-06-22 thomas echo -n > $testroot/stdout.expected
1835 4434a15a 2023-06-22 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1837 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1838 4434a15a 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
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 -n "got: work tree's current branch refs/remotes/origin/master " \
1844 4434a15a 2023-06-22 thomas > $testroot/stderr.expected
1845 4434a15a 2023-06-22 thomas echo -n 'is outside the "refs/heads/" reference namespace; ' \
1846 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1847 4434a15a 2023-06-22 thomas echo -n "update -b required: will not commit to a branch " \
1848 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1849 4434a15a 2023-06-22 thomas echo 'outside the "refs/heads/" reference namespace' \
1850 4434a15a 2023-06-22 thomas >> $testroot/stderr.expected
1852 4434a15a 2023-06-22 thomas cmp -s $testroot/stderr $testroot/stderr.expected
1854 4434a15a 2023-06-22 thomas if [ $ret -ne 0 ]; then
1855 4434a15a 2023-06-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
1857 4434a15a 2023-06-22 thomas test_done "$testroot" "$ret"
1860 10604dce 2021-09-24 thomas test_parseargs "$@"
1861 10604dce 2021-09-24 thomas run_test test_merge_basic
1862 2b72f32d 2023-06-22 thomas run_test test_merge_forward
1863 2b72f32d 2023-06-22 thomas run_test test_merge_backward
1864 10604dce 2021-09-24 thomas run_test test_merge_continue
1865 fe3f264b 2023-06-08 thomas run_test test_merge_continue_new_commit
1866 10604dce 2021-09-24 thomas run_test test_merge_abort
1867 10604dce 2021-09-24 thomas run_test test_merge_in_progress
1868 10604dce 2021-09-24 thomas run_test test_merge_path_prefix
1869 10604dce 2021-09-24 thomas run_test test_merge_missing_file
1870 2d7ce510 2021-09-24 thomas run_test test_merge_no_op
1871 768705e3 2021-09-27 thomas run_test test_merge_imported_branch
1872 ba34626b 2021-09-27 thomas run_test test_merge_interrupt
1873 a2c162eb 2022-10-30 thomas run_test test_merge_umask
1874 b16f1832 2023-02-21 thomas run_test test_merge_gitconfig_author
1875 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch
1876 4434a15a 2023-06-22 thomas run_test test_merge_fetched_branch_remote