Blame


1 f259c4c1 2021-09-24 stsp #!/bin/sh
2 f259c4c1 2021-09-24 stsp #
3 f259c4c1 2021-09-24 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 f259c4c1 2021-09-24 stsp #
5 f259c4c1 2021-09-24 stsp # Permission to use, copy, modify, and distribute this software for any
6 f259c4c1 2021-09-24 stsp # purpose with or without fee is hereby granted, provided that the above
7 f259c4c1 2021-09-24 stsp # copyright notice and this permission notice appear in all copies.
8 f259c4c1 2021-09-24 stsp #
9 f259c4c1 2021-09-24 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f259c4c1 2021-09-24 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f259c4c1 2021-09-24 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f259c4c1 2021-09-24 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f259c4c1 2021-09-24 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f259c4c1 2021-09-24 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f259c4c1 2021-09-24 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f259c4c1 2021-09-24 stsp
17 f259c4c1 2021-09-24 stsp . ./common.sh
18 f259c4c1 2021-09-24 stsp
19 f259c4c1 2021-09-24 stsp test_merge_basic() {
20 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_basic`
21 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
22 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
23 f259c4c1 2021-09-24 stsp
24 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
27 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
28 f259c4c1 2021-09-24 stsp
29 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
30 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
31 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
32 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
33 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
34 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
35 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
36 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
37 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
38 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
39 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
40 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
41 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
42 5267b9e4 2021-09-26 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
43 5267b9e4 2021-09-26 stsp (cd $testroot/repo && git add dotgotbar.link)
44 5267b9e4 2021-09-26 stsp git_commit $testroot/repo -m "adding a bad symlink on newbranch"
45 5267b9e4 2021-09-26 stsp local branch_commit5=`git_show_branch_head $testroot/repo newbranch`
46 f259c4c1 2021-09-24 stsp
47 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
48 49c543a6 2022-03-31 naddy ret=$?
49 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
50 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
51 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
52 f259c4c1 2021-09-24 stsp return 1
53 f259c4c1 2021-09-24 stsp fi
54 f259c4c1 2021-09-24 stsp
55 5e91dae4 2022-08-30 stsp # need a divergant commit on the main branch for 'got merge'
56 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
57 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
58 49c543a6 2022-03-31 naddy ret=$?
59 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
60 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
61 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
62 f259c4c1 2021-09-24 stsp return 1
63 f259c4c1 2021-09-24 stsp fi
64 f259c4c1 2021-09-24 stsp echo -n "got: cannot create a merge commit because " \
65 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
66 f259c4c1 2021-09-24 stsp echo -n "refs/heads/newbranch is based on refs/heads/master; " \
67 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
68 f259c4c1 2021-09-24 stsp echo -n "refs/heads/newbranch can be integrated with " \
69 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
70 f259c4c1 2021-09-24 stsp echo "'got integrate' instead" >> $testroot/stderr.expected
71 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
72 49c543a6 2022-03-31 naddy ret=$?
73 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
74 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
75 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
76 f259c4c1 2021-09-24 stsp return 1
77 f259c4c1 2021-09-24 stsp fi
78 f259c4c1 2021-09-24 stsp
79 f259c4c1 2021-09-24 stsp # create the required dirvergant commit
80 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
81 f259c4c1 2021-09-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
82 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
83 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
84 f259c4c1 2021-09-24 stsp
85 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
86 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
87 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
88 49c543a6 2022-03-31 naddy ret=$?
89 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
90 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
91 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
92 f259c4c1 2021-09-24 stsp return 1
93 f259c4c1 2021-09-24 stsp fi
94 f259c4c1 2021-09-24 stsp echo -n "got: work tree must be updated before it can be used " \
95 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
96 f259c4c1 2021-09-24 stsp echo "to merge a branch" >> $testroot/stderr.expected
97 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
98 49c543a6 2022-03-31 naddy ret=$?
99 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
100 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
101 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
102 f259c4c1 2021-09-24 stsp return 1
103 f259c4c1 2021-09-24 stsp fi
104 f259c4c1 2021-09-24 stsp
105 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
106 49c543a6 2022-03-31 naddy ret=$?
107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
108 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
109 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
110 f259c4c1 2021-09-24 stsp return 1
111 f259c4c1 2021-09-24 stsp fi
112 f259c4c1 2021-09-24 stsp
113 5e91dae4 2022-08-30 stsp # must not use a mixed-commit work tree with 'got merge'
114 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
115 49c543a6 2022-03-31 naddy ret=$?
116 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
117 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
118 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
119 f259c4c1 2021-09-24 stsp return 1
120 f259c4c1 2021-09-24 stsp fi
121 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
122 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
123 49c543a6 2022-03-31 naddy ret=$?
124 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
125 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
126 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
127 f259c4c1 2021-09-24 stsp return 1
128 f259c4c1 2021-09-24 stsp fi
129 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains files from multiple base commits; " \
130 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
131 f259c4c1 2021-09-24 stsp echo "the entire work tree must be updated first" \
132 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
133 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
134 49c543a6 2022-03-31 naddy ret=$?
135 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
136 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
137 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
138 f259c4c1 2021-09-24 stsp return 1
139 f259c4c1 2021-09-24 stsp fi
140 f259c4c1 2021-09-24 stsp
141 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
142 49c543a6 2022-03-31 naddy ret=$?
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
145 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
146 f259c4c1 2021-09-24 stsp return 1
147 f259c4c1 2021-09-24 stsp fi
148 f259c4c1 2021-09-24 stsp
149 5e91dae4 2022-08-30 stsp # must not have staged files with 'got merge'
150 f259c4c1 2021-09-24 stsp echo "modified file alpha" > $testroot/wt/alpha
151 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got stage alpha > /dev/null)
152 49c543a6 2022-03-31 naddy ret=$?
153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
154 f259c4c1 2021-09-24 stsp echo "got stage failed unexpectedly" >&2
155 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
156 f259c4c1 2021-09-24 stsp return 1
157 f259c4c1 2021-09-24 stsp fi
158 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
159 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
160 49c543a6 2022-03-31 naddy ret=$?
161 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
162 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
163 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
164 f259c4c1 2021-09-24 stsp return 1
165 f259c4c1 2021-09-24 stsp fi
166 f259c4c1 2021-09-24 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
167 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
168 49c543a6 2022-03-31 naddy ret=$?
169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
170 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
171 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
172 f259c4c1 2021-09-24 stsp return 1
173 f259c4c1 2021-09-24 stsp fi
174 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
175 49c543a6 2022-03-31 naddy ret=$?
176 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
177 f259c4c1 2021-09-24 stsp echo "got unstage failed unexpectedly" >&2
178 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
179 f259c4c1 2021-09-24 stsp return 1
180 f259c4c1 2021-09-24 stsp fi
181 f259c4c1 2021-09-24 stsp
182 5e91dae4 2022-08-30 stsp # must not have local changes with 'got merge'
183 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
184 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
185 49c543a6 2022-03-31 naddy ret=$?
186 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
187 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
188 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
189 f259c4c1 2021-09-24 stsp return 1
190 f259c4c1 2021-09-24 stsp fi
191 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains local changes; " \
192 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
193 f259c4c1 2021-09-24 stsp echo "these changes must be committed or reverted first" \
194 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
195 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
196 49c543a6 2022-03-31 naddy ret=$?
197 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
198 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
199 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
200 f259c4c1 2021-09-24 stsp return 1
201 f259c4c1 2021-09-24 stsp fi
202 f259c4c1 2021-09-24 stsp
203 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
204 49c543a6 2022-03-31 naddy ret=$?
205 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
206 f259c4c1 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
207 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
208 f259c4c1 2021-09-24 stsp return 1
209 f259c4c1 2021-09-24 stsp fi
210 f259c4c1 2021-09-24 stsp
211 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch > $testroot/stdout)
212 49c543a6 2022-03-31 naddy ret=$?
213 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
214 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
215 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
216 f259c4c1 2021-09-24 stsp return 1
217 f259c4c1 2021-09-24 stsp fi
218 f259c4c1 2021-09-24 stsp
219 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
220 f259c4c1 2021-09-24 stsp
221 f259c4c1 2021-09-24 stsp echo "G alpha" >> $testroot/stdout.expected
222 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
223 5267b9e4 2021-09-26 stsp echo "A dotgotbar.link" >> $testroot/stdout.expected
224 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
225 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
226 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
227 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
228 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
229 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
230 f259c4c1 2021-09-24 stsp
231 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
232 49c543a6 2022-03-31 naddy ret=$?
233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
234 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
235 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
236 f259c4c1 2021-09-24 stsp return 1
237 f259c4c1 2021-09-24 stsp fi
238 f259c4c1 2021-09-24 stsp
239 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
240 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
241 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
242 49c543a6 2022-03-31 naddy ret=$?
243 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
244 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
245 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
246 f259c4c1 2021-09-24 stsp return 1
247 f259c4c1 2021-09-24 stsp fi
248 f259c4c1 2021-09-24 stsp
249 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/content.expected
250 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
251 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
252 49c543a6 2022-03-31 naddy ret=$?
253 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
254 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
255 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
256 f259c4c1 2021-09-24 stsp return 1
257 f259c4c1 2021-09-24 stsp fi
258 f259c4c1 2021-09-24 stsp
259 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
260 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
261 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
262 f259c4c1 2021-09-24 stsp return 1
263 f259c4c1 2021-09-24 stsp fi
264 f259c4c1 2021-09-24 stsp
265 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
266 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
267 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
268 49c543a6 2022-03-31 naddy ret=$?
269 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
270 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
271 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
272 f259c4c1 2021-09-24 stsp return 1
273 f259c4c1 2021-09-24 stsp fi
274 f259c4c1 2021-09-24 stsp
275 5267b9e4 2021-09-26 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
276 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is not a symlink"
277 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
278 5267b9e4 2021-09-26 stsp return 1
279 5267b9e4 2021-09-26 stsp fi
280 5267b9e4 2021-09-26 stsp
281 f259c4c1 2021-09-24 stsp readlink $testroot/wt/symlink > $testroot/stdout
282 f259c4c1 2021-09-24 stsp echo "alpha" > $testroot/stdout.expected
283 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 49c543a6 2022-03-31 naddy ret=$?
285 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
286 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
288 f259c4c1 2021-09-24 stsp return 1
289 f259c4c1 2021-09-24 stsp fi
290 f259c4c1 2021-09-24 stsp
291 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
292 f259c4c1 2021-09-24 stsp
293 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
294 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
295 49c543a6 2022-03-31 naddy ret=$?
296 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
297 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
298 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
299 f259c4c1 2021-09-24 stsp return 1
300 f259c4c1 2021-09-24 stsp fi
301 f259c4c1 2021-09-24 stsp
302 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
303 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
304 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
305 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
306 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
307 49c543a6 2022-03-31 naddy ret=$?
308 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
309 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
310 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
311 f259c4c1 2021-09-24 stsp return 1
312 f259c4c1 2021-09-24 stsp fi
313 f259c4c1 2021-09-24 stsp
314 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
315 f259c4c1 2021-09-24 stsp
316 5267b9e4 2021-09-26 stsp echo 'U dotgotbar.link' > $testroot/stdout.expected
317 5267b9e4 2021-09-26 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
318 5267b9e4 2021-09-26 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
319 5267b9e4 2021-09-26 stsp echo >> $testroot/stdout.expected
320 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
321 49c543a6 2022-03-31 naddy ret=$?
322 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
323 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
324 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
325 f259c4c1 2021-09-24 stsp return 1
326 f259c4c1 2021-09-24 stsp fi
327 f259c4c1 2021-09-24 stsp
328 5267b9e4 2021-09-26 stsp # update has changed the bad symlink into a regular file
329 5267b9e4 2021-09-26 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
330 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is a symlink"
331 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
332 5267b9e4 2021-09-26 stsp return 1
333 5267b9e4 2021-09-26 stsp fi
334 5267b9e4 2021-09-26 stsp
335 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
336 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
337 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
338 5267b9e4 2021-09-26 stsp echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
339 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
340 49c543a6 2022-03-31 naddy ret=$?
341 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
342 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
343 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
344 5267b9e4 2021-09-26 stsp return 1
345 5267b9e4 2021-09-26 stsp fi
346 5267b9e4 2021-09-26 stsp
347 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
348 49c543a6 2022-03-31 naddy ret=$?
349 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
350 5267b9e4 2021-09-26 stsp echo "got tree failed unexpectedly" >&2
351 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
352 5267b9e4 2021-09-26 stsp return 1
353 5267b9e4 2021-09-26 stsp fi
354 5267b9e4 2021-09-26 stsp
355 5267b9e4 2021-09-26 stsp # bad symlink dotgotbar.link appears as a symlink in the merge commit:
356 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
357 5267b9e4 2021-09-26 stsp alpha
358 5267b9e4 2021-09-26 stsp dotgotbar.link@ -> .got/bar
359 5267b9e4 2021-09-26 stsp epsilon/
360 5267b9e4 2021-09-26 stsp epsilon/new
361 5267b9e4 2021-09-26 stsp epsilon/zeta
362 5267b9e4 2021-09-26 stsp gamma/
363 5267b9e4 2021-09-26 stsp gamma/delta
364 5267b9e4 2021-09-26 stsp symlink@ -> alpha
365 5267b9e4 2021-09-26 stsp EOF
366 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
367 49c543a6 2022-03-31 naddy ret=$?
368 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
369 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
370 f259c4c1 2021-09-24 stsp fi
371 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
372 f259c4c1 2021-09-24 stsp }
373 f259c4c1 2021-09-24 stsp
374 f259c4c1 2021-09-24 stsp test_merge_continue() {
375 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
376 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
377 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
378 f259c4c1 2021-09-24 stsp
379 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
380 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
381 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
382 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
383 f259c4c1 2021-09-24 stsp
384 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
385 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
386 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
387 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
388 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
389 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
390 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
391 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
392 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
393 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
394 f259c4c1 2021-09-24 stsp
395 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
396 49c543a6 2022-03-31 naddy ret=$?
397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
398 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
399 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
400 f259c4c1 2021-09-24 stsp return 1
401 f259c4c1 2021-09-24 stsp fi
402 f259c4c1 2021-09-24 stsp
403 f259c4c1 2021-09-24 stsp # create a conflicting commit
404 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
405 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
406 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
407 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
408 f259c4c1 2021-09-24 stsp
409 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
410 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
411 49c543a6 2022-03-31 naddy ret=$?
412 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
413 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
414 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
415 f259c4c1 2021-09-24 stsp return 1
416 f259c4c1 2021-09-24 stsp fi
417 f259c4c1 2021-09-24 stsp
418 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
419 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
420 49c543a6 2022-03-31 naddy ret=$?
421 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
422 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
423 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
424 f259c4c1 2021-09-24 stsp return 1
425 f259c4c1 2021-09-24 stsp fi
426 f259c4c1 2021-09-24 stsp
427 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
428 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
429 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
430 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
431 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
432 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
433 49c543a6 2022-03-31 naddy ret=$?
434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
435 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
436 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
437 f259c4c1 2021-09-24 stsp return 1
438 f259c4c1 2021-09-24 stsp fi
439 f259c4c1 2021-09-24 stsp
440 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
441 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
442 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
443 49c543a6 2022-03-31 naddy ret=$?
444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
445 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
446 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
447 f259c4c1 2021-09-24 stsp return 1
448 f259c4c1 2021-09-24 stsp fi
449 f259c4c1 2021-09-24 stsp
450 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
451 f259c4c1 2021-09-24 stsp
452 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
453 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
454 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
455 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
456 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
457 49c543a6 2022-03-31 naddy ret=$?
458 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
459 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
460 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
461 f259c4c1 2021-09-24 stsp return 1
462 f259c4c1 2021-09-24 stsp fi
463 f259c4c1 2021-09-24 stsp
464 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
465 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
466 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
467 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
468 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
469 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
470 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
471 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
472 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
473 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
474 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
475 49c543a6 2022-03-31 naddy ret=$?
476 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
477 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
478 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
479 f259c4c1 2021-09-24 stsp return 1
480 f259c4c1 2021-09-24 stsp fi
481 f259c4c1 2021-09-24 stsp
482 f259c4c1 2021-09-24 stsp # resolve the conflict
483 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
484 f259c4c1 2021-09-24 stsp
485 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
486 49c543a6 2022-03-31 naddy ret=$?
487 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
488 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
489 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
490 f259c4c1 2021-09-24 stsp return 1
491 f259c4c1 2021-09-24 stsp fi
492 f259c4c1 2021-09-24 stsp
493 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
494 f259c4c1 2021-09-24 stsp
495 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
496 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
497 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
498 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
499 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
500 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
501 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
502 f259c4c1 2021-09-24 stsp
503 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
504 49c543a6 2022-03-31 naddy ret=$?
505 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
506 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
507 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
508 f259c4c1 2021-09-24 stsp return 1
509 f259c4c1 2021-09-24 stsp fi
510 f259c4c1 2021-09-24 stsp
511 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
512 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
513 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
514 49c543a6 2022-03-31 naddy ret=$?
515 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
516 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
517 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
518 f259c4c1 2021-09-24 stsp return 1
519 f259c4c1 2021-09-24 stsp fi
520 f259c4c1 2021-09-24 stsp
521 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
522 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
523 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
524 49c543a6 2022-03-31 naddy ret=$?
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
527 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
528 f259c4c1 2021-09-24 stsp return 1
529 f259c4c1 2021-09-24 stsp fi
530 f259c4c1 2021-09-24 stsp
531 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
532 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
533 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
534 f259c4c1 2021-09-24 stsp return 1
535 f259c4c1 2021-09-24 stsp fi
536 f259c4c1 2021-09-24 stsp
537 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
538 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
539 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
540 49c543a6 2022-03-31 naddy ret=$?
541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
542 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
543 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
544 f259c4c1 2021-09-24 stsp return 1
545 f259c4c1 2021-09-24 stsp fi
546 f259c4c1 2021-09-24 stsp
547 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
548 f259c4c1 2021-09-24 stsp
549 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
550 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
551 49c543a6 2022-03-31 naddy ret=$?
552 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
553 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
555 f259c4c1 2021-09-24 stsp return 1
556 f259c4c1 2021-09-24 stsp fi
557 f259c4c1 2021-09-24 stsp
558 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
559 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
560 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
561 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
562 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
563 49c543a6 2022-03-31 naddy ret=$?
564 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
565 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
566 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
567 f259c4c1 2021-09-24 stsp return 1
568 f259c4c1 2021-09-24 stsp fi
569 f259c4c1 2021-09-24 stsp
570 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
571 f259c4c1 2021-09-24 stsp
572 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
573 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 49c543a6 2022-03-31 naddy ret=$?
575 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
576 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
578 f259c4c1 2021-09-24 stsp return 1
579 f259c4c1 2021-09-24 stsp fi
580 f259c4c1 2021-09-24 stsp
581 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
582 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
583 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
584 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
585 6b5246e4 2023-06-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
586 6b5246e4 2023-06-05 stsp ret=$?
587 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
588 6b5246e4 2023-06-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
589 6b5246e4 2023-06-05 stsp fi
590 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
591 6b5246e4 2023-06-05 stsp }
592 6b5246e4 2023-06-05 stsp
593 6b5246e4 2023-06-05 stsp test_merge_continue_new_commit() {
594 6b5246e4 2023-06-05 stsp # "got merge -c" should refuse to run if the current branch tip has
595 6b5246e4 2023-06-05 stsp # changed since the merge was started, to avoid clobbering the changes.
596 6b5246e4 2023-06-05 stsp local testroot=`test_init merge_continue_new_commit`
597 6b5246e4 2023-06-05 stsp
598 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q -b newbranch)
599 6b5246e4 2023-06-05 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
600 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
601 6b5246e4 2023-06-05 stsp
602 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q master)
603 6b5246e4 2023-06-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
604 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master"
605 6b5246e4 2023-06-05 stsp
606 6b5246e4 2023-06-05 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
607 6b5246e4 2023-06-05 stsp ret=$?
608 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
609 6b5246e4 2023-06-05 stsp echo "got checkout failed unexpectedly" >&2
610 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
611 6b5246e4 2023-06-05 stsp return 1
612 6b5246e4 2023-06-05 stsp fi
613 6b5246e4 2023-06-05 stsp
614 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -n newbranch >/dev/null)
615 6b5246e4 2023-06-05 stsp ret=$?
616 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
617 6b5246e4 2023-06-05 stsp echo "got merge failed unexpectedly" >&2
618 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
619 6b5246e4 2023-06-05 stsp return 1
620 6b5246e4 2023-06-05 stsp fi
621 6b5246e4 2023-06-05 stsp
622 6b5246e4 2023-06-05 stsp echo "modified alpha again on master" > $testroot/repo/alpha
623 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master again"
624 6b5246e4 2023-06-05 stsp
625 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
626 6b5246e4 2023-06-05 stsp ret=$?
627 6b5246e4 2023-06-05 stsp if [ $ret -eq 0 ]; then
628 6b5246e4 2023-06-05 stsp echo "got merge succeeded unexpectedly" >&2
629 6b5246e4 2023-06-05 stsp test_done "$testroot" "1"
630 6b5246e4 2023-06-05 stsp return 1
631 6b5246e4 2023-06-05 stsp fi
632 6b5246e4 2023-06-05 stsp
633 6b5246e4 2023-06-05 stsp echo -n > $testroot/stdout.expected
634 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
635 49c543a6 2022-03-31 naddy ret=$?
636 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
637 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
638 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
639 6b5246e4 2023-06-05 stsp return 1
640 6b5246e4 2023-06-05 stsp fi
641 6b5246e4 2023-06-05 stsp
642 6b5246e4 2023-06-05 stsp echo -n "got: merging cannot proceed because the work tree is no " \
643 6b5246e4 2023-06-05 stsp > $testroot/stderr.expected
644 6b5246e4 2023-06-05 stsp echo "longer up-to-date; merge must be aborted and retried" \
645 6b5246e4 2023-06-05 stsp >> $testroot/stderr.expected
646 6b5246e4 2023-06-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
647 6b5246e4 2023-06-05 stsp ret=$?
648 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
649 6b5246e4 2023-06-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
650 f259c4c1 2021-09-24 stsp fi
651 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
652 f259c4c1 2021-09-24 stsp }
653 f259c4c1 2021-09-24 stsp
654 f259c4c1 2021-09-24 stsp test_merge_abort() {
655 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
656 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
657 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
658 f259c4c1 2021-09-24 stsp
659 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
660 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
661 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
662 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
663 f259c4c1 2021-09-24 stsp
664 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
665 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
666 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
667 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
668 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
669 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
670 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
671 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
672 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
673 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
674 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
675 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
676 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
677 f259c4c1 2021-09-24 stsp
678 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
679 49c543a6 2022-03-31 naddy ret=$?
680 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
681 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
682 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
683 f259c4c1 2021-09-24 stsp return 1
684 f259c4c1 2021-09-24 stsp fi
685 41f061b2 2021-10-05 stsp
686 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
687 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
688 f259c4c1 2021-09-24 stsp
689 f259c4c1 2021-09-24 stsp # create a conflicting commit
690 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
691 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
692 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
693 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
694 f259c4c1 2021-09-24 stsp
695 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
696 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
697 49c543a6 2022-03-31 naddy ret=$?
698 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
699 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
700 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
701 f259c4c1 2021-09-24 stsp return 1
702 f259c4c1 2021-09-24 stsp fi
703 f259c4c1 2021-09-24 stsp
704 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
705 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
706 49c543a6 2022-03-31 naddy ret=$?
707 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
708 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
709 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
710 f259c4c1 2021-09-24 stsp return 1
711 f259c4c1 2021-09-24 stsp fi
712 f259c4c1 2021-09-24 stsp
713 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
714 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
715 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
716 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
717 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
718 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
719 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
720 49c543a6 2022-03-31 naddy ret=$?
721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
722 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
724 f259c4c1 2021-09-24 stsp return 1
725 f259c4c1 2021-09-24 stsp fi
726 f259c4c1 2021-09-24 stsp
727 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
728 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
729 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
730 49c543a6 2022-03-31 naddy ret=$?
731 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
732 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
733 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
734 f259c4c1 2021-09-24 stsp return 1
735 f259c4c1 2021-09-24 stsp fi
736 af179be7 2023-04-14 stsp
737 af179be7 2023-04-14 stsp # unrelated added file added during conflict resolution
738 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
739 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
740 f259c4c1 2021-09-24 stsp
741 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
742 f259c4c1 2021-09-24 stsp
743 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
744 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
745 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
746 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
747 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
748 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
749 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
750 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
751 49c543a6 2022-03-31 naddy ret=$?
752 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
753 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
754 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
755 f259c4c1 2021-09-24 stsp return 1
756 f259c4c1 2021-09-24 stsp fi
757 f259c4c1 2021-09-24 stsp
758 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
759 49c543a6 2022-03-31 naddy ret=$?
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
762 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
763 f259c4c1 2021-09-24 stsp return 1
764 f259c4c1 2021-09-24 stsp fi
765 f259c4c1 2021-09-24 stsp
766 af179be7 2023-04-14 stsp echo "R added-file" > $testroot/stdout.expected
767 af179be7 2023-04-14 stsp echo "R alpha" >> $testroot/stdout.expected
768 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
769 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
770 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
771 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
772 af179be7 2023-04-14 stsp echo "G added-file" >> $testroot/stdout.expected
773 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
774 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
775 f259c4c1 2021-09-24 stsp
776 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
777 49c543a6 2022-03-31 naddy ret=$?
778 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
779 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
781 f259c4c1 2021-09-24 stsp return 1
782 f259c4c1 2021-09-24 stsp fi
783 f259c4c1 2021-09-24 stsp
784 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
785 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
786 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
787 49c543a6 2022-03-31 naddy ret=$?
788 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
789 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
790 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
791 f259c4c1 2021-09-24 stsp return 1
792 f259c4c1 2021-09-24 stsp fi
793 f259c4c1 2021-09-24 stsp
794 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
795 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
796 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
797 49c543a6 2022-03-31 naddy ret=$?
798 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
799 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
800 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
801 f259c4c1 2021-09-24 stsp return 1
802 f259c4c1 2021-09-24 stsp fi
803 f259c4c1 2021-09-24 stsp
804 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
805 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
806 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
807 49c543a6 2022-03-31 naddy ret=$?
808 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
809 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
810 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
811 f259c4c1 2021-09-24 stsp return 1
812 f259c4c1 2021-09-24 stsp fi
813 f259c4c1 2021-09-24 stsp
814 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
815 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
816 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
817 f259c4c1 2021-09-24 stsp return 1
818 f259c4c1 2021-09-24 stsp fi
819 f259c4c1 2021-09-24 stsp
820 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
821 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
822 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
823 f259c4c1 2021-09-24 stsp return 1
824 f259c4c1 2021-09-24 stsp fi
825 f259c4c1 2021-09-24 stsp
826 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
827 f259c4c1 2021-09-24 stsp
828 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
829 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
830 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
831 49c543a6 2022-03-31 naddy ret=$?
832 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
833 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
834 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
835 f259c4c1 2021-09-24 stsp return 1
836 f259c4c1 2021-09-24 stsp fi
837 f259c4c1 2021-09-24 stsp
838 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
839 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
840 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
841 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
842 49c543a6 2022-03-31 naddy ret=$?
843 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
844 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
845 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
846 f259c4c1 2021-09-24 stsp return 1
847 f259c4c1 2021-09-24 stsp fi
848 f259c4c1 2021-09-24 stsp
849 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
850 f259c4c1 2021-09-24 stsp
851 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
852 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
853 49c543a6 2022-03-31 naddy ret=$?
854 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
855 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
856 f259c4c1 2021-09-24 stsp fi
857 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
858 f259c4c1 2021-09-24 stsp }
859 f259c4c1 2021-09-24 stsp
860 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
861 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
862 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
863 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
864 f259c4c1 2021-09-24 stsp
865 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
866 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
867 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
868 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
869 f259c4c1 2021-09-24 stsp
870 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
871 49c543a6 2022-03-31 naddy ret=$?
872 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
873 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
874 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
875 f259c4c1 2021-09-24 stsp return 1
876 f259c4c1 2021-09-24 stsp fi
877 f259c4c1 2021-09-24 stsp
878 f259c4c1 2021-09-24 stsp # create a conflicting commit
879 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
880 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
881 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
882 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
883 f259c4c1 2021-09-24 stsp
884 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
885 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
886 49c543a6 2022-03-31 naddy ret=$?
887 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
888 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
889 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
890 f259c4c1 2021-09-24 stsp return 1
891 f259c4c1 2021-09-24 stsp fi
892 f259c4c1 2021-09-24 stsp
893 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
894 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
895 49c543a6 2022-03-31 naddy ret=$?
896 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
897 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
898 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
899 f259c4c1 2021-09-24 stsp return 1
900 f259c4c1 2021-09-24 stsp fi
901 f259c4c1 2021-09-24 stsp
902 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
903 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
904 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
905 49c543a6 2022-03-31 naddy ret=$?
906 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
907 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
909 f259c4c1 2021-09-24 stsp return 1
910 f259c4c1 2021-09-24 stsp fi
911 f259c4c1 2021-09-24 stsp
912 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
913 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
914 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
915 49c543a6 2022-03-31 naddy ret=$?
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
918 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
919 f259c4c1 2021-09-24 stsp return 1
920 f259c4c1 2021-09-24 stsp fi
921 f259c4c1 2021-09-24 stsp
922 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
923 f259c4c1 2021-09-24 stsp
924 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
925 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
926 49c543a6 2022-03-31 naddy ret=$?
927 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
928 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
929 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
930 f259c4c1 2021-09-24 stsp return 1
931 f259c4c1 2021-09-24 stsp fi
932 f259c4c1 2021-09-24 stsp
933 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
934 42761529 2023-06-01 stsp "integrate newbranch" "merge newbranch" "stage alpha"; do
935 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
936 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
937 42761529 2023-06-01 stsp ret=$?
938 42761529 2023-06-01 stsp if [ $ret -eq 0 ]; then
939 42761529 2023-06-01 stsp echo "got $cmd succeeded unexpectedly" >&2
940 42761529 2023-06-01 stsp test_done "$testroot" "1"
941 42761529 2023-06-01 stsp return 1
942 42761529 2023-06-01 stsp fi
943 f259c4c1 2021-09-24 stsp
944 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
945 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
949 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
950 f259c4c1 2021-09-24 stsp return 1
951 f259c4c1 2021-09-24 stsp fi
952 f259c4c1 2021-09-24 stsp
953 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
954 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
955 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
956 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
957 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
958 49c543a6 2022-03-31 naddy ret=$?
959 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
960 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
961 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
962 f259c4c1 2021-09-24 stsp return 1
963 f259c4c1 2021-09-24 stsp fi
964 f259c4c1 2021-09-24 stsp done
965 f259c4c1 2021-09-24 stsp
966 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
967 f259c4c1 2021-09-24 stsp }
968 f259c4c1 2021-09-24 stsp
969 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
970 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
971 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
972 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
973 f259c4c1 2021-09-24 stsp
974 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
975 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
976 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
977 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
978 f259c4c1 2021-09-24 stsp
979 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
980 f259c4c1 2021-09-24 stsp > /dev/null
981 49c543a6 2022-03-31 naddy ret=$?
982 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
983 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
984 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
985 f259c4c1 2021-09-24 stsp return 1
986 f259c4c1 2021-09-24 stsp fi
987 f259c4c1 2021-09-24 stsp
988 f259c4c1 2021-09-24 stsp # create a conflicting commit
989 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
990 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
991 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
992 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
993 f259c4c1 2021-09-24 stsp
994 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
995 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
996 49c543a6 2022-03-31 naddy ret=$?
997 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
998 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
999 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1000 f259c4c1 2021-09-24 stsp return 1
1001 f259c4c1 2021-09-24 stsp fi
1002 f259c4c1 2021-09-24 stsp
1003 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1004 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1005 49c543a6 2022-03-31 naddy ret=$?
1006 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1007 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1008 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1009 f259c4c1 2021-09-24 stsp return 1
1010 f259c4c1 2021-09-24 stsp fi
1011 f259c4c1 2021-09-24 stsp
1012 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
1013 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1014 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
1015 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1016 49c543a6 2022-03-31 naddy ret=$?
1017 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1018 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1019 f259c4c1 2021-09-24 stsp fi
1020 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1021 f259c4c1 2021-09-24 stsp }
1022 f259c4c1 2021-09-24 stsp
1023 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
1024 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
1025 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1026 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1027 f259c4c1 2021-09-24 stsp
1028 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1029 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1030 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1031 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
1032 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1033 f259c4c1 2021-09-24 stsp
1034 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1035 49c543a6 2022-03-31 naddy ret=$?
1036 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1037 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1038 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1039 f259c4c1 2021-09-24 stsp return 1
1040 f259c4c1 2021-09-24 stsp fi
1041 f259c4c1 2021-09-24 stsp
1042 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
1043 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1044 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1045 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
1046 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1047 f259c4c1 2021-09-24 stsp
1048 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1049 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1050 49c543a6 2022-03-31 naddy ret=$?
1051 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1052 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1053 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1054 f259c4c1 2021-09-24 stsp return 1
1055 f259c4c1 2021-09-24 stsp fi
1056 f259c4c1 2021-09-24 stsp
1057 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1058 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1059 49c543a6 2022-03-31 naddy ret=$?
1060 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1061 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1062 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1063 f259c4c1 2021-09-24 stsp return 1
1064 f259c4c1 2021-09-24 stsp fi
1065 f259c4c1 2021-09-24 stsp
1066 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
1067 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1068 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1069 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1070 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1071 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1072 49c543a6 2022-03-31 naddy ret=$?
1073 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1074 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1075 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1076 f259c4c1 2021-09-24 stsp return 1
1077 f259c4c1 2021-09-24 stsp fi
1078 f259c4c1 2021-09-24 stsp
1079 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1080 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1081 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1082 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1083 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1084 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1085 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1086 49c543a6 2022-03-31 naddy ret=$?
1087 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1088 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1089 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1090 f259c4c1 2021-09-24 stsp return 1
1091 f259c4c1 2021-09-24 stsp fi
1092 f259c4c1 2021-09-24 stsp
1093 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1094 f259c4c1 2021-09-24 stsp
1095 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1096 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1097 49c543a6 2022-03-31 naddy ret=$?
1098 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1099 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1100 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1101 a6a8f8bb 2021-09-24 stsp return 1
1102 a6a8f8bb 2021-09-24 stsp fi
1103 a6a8f8bb 2021-09-24 stsp
1104 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1105 a6a8f8bb 2021-09-24 stsp }
1106 a6a8f8bb 2021-09-24 stsp
1107 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1108 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1109 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1110 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1111 a6a8f8bb 2021-09-24 stsp
1112 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1113 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1114 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1115 35d2583f 2023-04-17 stsp local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1116 a6a8f8bb 2021-09-24 stsp
1117 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1118 49c543a6 2022-03-31 naddy ret=$?
1119 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1120 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1121 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1122 a6a8f8bb 2021-09-24 stsp return 1
1123 a6a8f8bb 2021-09-24 stsp fi
1124 a6a8f8bb 2021-09-24 stsp
1125 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1126 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1127 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1128 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1129 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1130 a6a8f8bb 2021-09-24 stsp
1131 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1132 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1133 49c543a6 2022-03-31 naddy ret=$?
1134 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1135 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1136 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1137 a6a8f8bb 2021-09-24 stsp return 1
1138 a6a8f8bb 2021-09-24 stsp fi
1139 a6a8f8bb 2021-09-24 stsp
1140 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1141 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1142 49c543a6 2022-03-31 naddy ret=$?
1143 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1144 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1145 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1146 a6a8f8bb 2021-09-24 stsp return 1
1147 a6a8f8bb 2021-09-24 stsp fi
1148 a6a8f8bb 2021-09-24 stsp
1149 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1150 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1151 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1152 49c543a6 2022-03-31 naddy ret=$?
1153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1154 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1155 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1156 a6a8f8bb 2021-09-24 stsp return 1
1157 a6a8f8bb 2021-09-24 stsp fi
1158 a6a8f8bb 2021-09-24 stsp
1159 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1160 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1161 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1162 49c543a6 2022-03-31 naddy ret=$?
1163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1164 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1165 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1166 a6a8f8bb 2021-09-24 stsp return 1
1167 a6a8f8bb 2021-09-24 stsp fi
1168 a6a8f8bb 2021-09-24 stsp
1169 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1170 a6a8f8bb 2021-09-24 stsp
1171 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1172 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1176 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1177 f259c4c1 2021-09-24 stsp return 1
1178 f259c4c1 2021-09-24 stsp fi
1179 f259c4c1 2021-09-24 stsp
1180 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1181 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1182 49c543a6 2022-03-31 naddy ret=$?
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1185 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1186 a6a8f8bb 2021-09-24 stsp return 1
1187 a6a8f8bb 2021-09-24 stsp fi
1188 a6a8f8bb 2021-09-24 stsp
1189 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1190 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1191 49c543a6 2022-03-31 naddy ret=$?
1192 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1193 35d2583f 2023-04-17 stsp echo "got merge failed unexpectedly" >&2
1194 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1195 a6a8f8bb 2021-09-24 stsp return 1
1196 a6a8f8bb 2021-09-24 stsp fi
1197 a6a8f8bb 2021-09-24 stsp
1198 35d2583f 2023-04-17 stsp echo -n '' > $testroot/stderr.expected
1199 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1200 49c543a6 2022-03-31 naddy ret=$?
1201 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1202 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1203 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1204 35d2583f 2023-04-17 stsp return 1
1205 35d2583f 2023-04-17 stsp fi
1206 35d2583f 2023-04-17 stsp
1207 35d2583f 2023-04-17 stsp local merge_commit=`git_show_head $testroot/repo`
1208 35d2583f 2023-04-17 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1209 35d2583f 2023-04-17 stsp > $testroot/stdout.expected
1210 35d2583f 2023-04-17 stsp echo $merge_commit >> $testroot/stdout.expected
1211 35d2583f 2023-04-17 stsp
1212 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1213 35d2583f 2023-04-17 stsp ret=$?
1214 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1215 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1216 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1217 a6a8f8bb 2021-09-24 stsp return 1
1218 a6a8f8bb 2021-09-24 stsp fi
1219 a6a8f8bb 2021-09-24 stsp
1220 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1221 a6a8f8bb 2021-09-24 stsp
1222 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1223 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1224 49c543a6 2022-03-31 naddy ret=$?
1225 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1226 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1227 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1228 35d2583f 2023-04-17 stsp return 1
1229 4e91ef15 2021-09-26 stsp fi
1230 35d2583f 2023-04-17 stsp
1231 35d2583f 2023-04-17 stsp # We should have created a merge commit with two parents.
1232 35d2583f 2023-04-17 stsp got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1233 35d2583f 2023-04-17 stsp > $testroot/stdout
1234 35d2583f 2023-04-17 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1235 35d2583f 2023-04-17 stsp echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1236 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1237 35d2583f 2023-04-17 stsp ret=$?
1238 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1239 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1240 35d2583f 2023-04-17 stsp fi
1241 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1242 4e91ef15 2021-09-26 stsp }
1243 4e91ef15 2021-09-26 stsp
1244 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1245 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1246 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1247 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1248 4e91ef15 2021-09-26 stsp
1249 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1250 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1251 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1252 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1253 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1254 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1255 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1256 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1257 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1258 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1259 4e91ef15 2021-09-26 stsp
1260 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1261 49c543a6 2022-03-31 naddy ret=$?
1262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1263 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1264 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1265 4e91ef15 2021-09-26 stsp return 1
1266 4e91ef15 2021-09-26 stsp fi
1267 4e91ef15 2021-09-26 stsp
1268 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1269 49c543a6 2022-03-31 naddy ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1272 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1273 4e91ef15 2021-09-26 stsp return 1
1274 4e91ef15 2021-09-26 stsp fi
1275 4e91ef15 2021-09-26 stsp
1276 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1277 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1278 4e91ef15 2021-09-26 stsp A be/lots/of
1279 4e91ef15 2021-09-26 stsp A files/here
1280 4e91ef15 2021-09-26 stsp A there/should
1281 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1282 4e91ef15 2021-09-26 stsp EOF
1283 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1284 49c543a6 2022-03-31 naddy ret=$?
1285 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1286 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1287 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1288 4e91ef15 2021-09-26 stsp return 1
1289 4e91ef15 2021-09-26 stsp fi
1290 4e91ef15 2021-09-26 stsp
1291 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1292 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1293 49c543a6 2022-03-31 naddy ret=$?
1294 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1295 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1296 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1297 4e91ef15 2021-09-26 stsp return 1
1298 4e91ef15 2021-09-26 stsp fi
1299 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1300 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1301 49c543a6 2022-03-31 naddy ret=$?
1302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1303 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1304 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1305 4e91ef15 2021-09-26 stsp return 1
1306 a6a8f8bb 2021-09-24 stsp fi
1307 4e91ef15 2021-09-26 stsp
1308 4e91ef15 2021-09-26 stsp # update the 'files' branch
1309 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1310 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1311 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1312 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1313 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1314 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1315 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1316 4e91ef15 2021-09-26 stsp
1317 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1318 49c543a6 2022-03-31 naddy ret=$?
1319 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1320 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1321 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1322 4e91ef15 2021-09-26 stsp return 1
1323 4e91ef15 2021-09-26 stsp fi
1324 4e91ef15 2021-09-26 stsp
1325 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1326 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1327 49c543a6 2022-03-31 naddy ret=$?
1328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1329 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1330 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1331 4e91ef15 2021-09-26 stsp return 1
1332 4e91ef15 2021-09-26 stsp fi
1333 4e91ef15 2021-09-26 stsp
1334 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1335 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1336 4e91ef15 2021-09-26 stsp G be/lots/of
1337 4e91ef15 2021-09-26 stsp A indeed
1338 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1339 4e91ef15 2021-09-26 stsp EOF
1340 4e91ef15 2021-09-26 stsp
1341 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1342 49c543a6 2022-03-31 naddy ret=$?
1343 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1344 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1345 4e91ef15 2021-09-26 stsp fi
1346 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1347 f259c4c1 2021-09-24 stsp }
1348 088449d3 2021-09-26 stsp
1349 088449d3 2021-09-26 stsp test_merge_interrupt() {
1350 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1351 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1352 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1353 088449d3 2021-09-26 stsp
1354 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1355 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1356 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1357 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1358 088449d3 2021-09-26 stsp
1359 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1360 49c543a6 2022-03-31 naddy ret=$?
1361 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1362 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1363 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1364 088449d3 2021-09-26 stsp return 1
1365 088449d3 2021-09-26 stsp fi
1366 088449d3 2021-09-26 stsp
1367 088449d3 2021-09-26 stsp # create a non-conflicting commit
1368 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1369 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1370 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1371 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1372 f259c4c1 2021-09-24 stsp
1373 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1374 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1375 49c543a6 2022-03-31 naddy ret=$?
1376 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1377 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1378 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1379 088449d3 2021-09-26 stsp return 1
1380 088449d3 2021-09-26 stsp fi
1381 088449d3 2021-09-26 stsp
1382 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1383 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1384 49c543a6 2022-03-31 naddy ret=$?
1385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1386 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1387 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1388 088449d3 2021-09-26 stsp return 1
1389 088449d3 2021-09-26 stsp fi
1390 088449d3 2021-09-26 stsp
1391 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1392 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1393 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1394 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1395 49c543a6 2022-03-31 naddy ret=$?
1396 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1397 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1398 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1399 088449d3 2021-09-26 stsp return 1
1400 088449d3 2021-09-26 stsp fi
1401 088449d3 2021-09-26 stsp
1402 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1403 088449d3 2021-09-26 stsp
1404 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1405 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1406 49c543a6 2022-03-31 naddy ret=$?
1407 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1408 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1409 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1410 088449d3 2021-09-26 stsp return 1
1411 088449d3 2021-09-26 stsp fi
1412 088449d3 2021-09-26 stsp
1413 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1414 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1415 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1416 49c543a6 2022-03-31 naddy ret=$?
1417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1418 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1419 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1420 088449d3 2021-09-26 stsp return 1
1421 088449d3 2021-09-26 stsp fi
1422 088449d3 2021-09-26 stsp
1423 088449d3 2021-09-26 stsp # adjust merge result
1424 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1425 088449d3 2021-09-26 stsp
1426 088449d3 2021-09-26 stsp # continue the merge
1427 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1428 49c543a6 2022-03-31 naddy ret=$?
1429 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1430 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1431 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1432 088449d3 2021-09-26 stsp return 1
1433 088449d3 2021-09-26 stsp fi
1434 088449d3 2021-09-26 stsp
1435 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1436 088449d3 2021-09-26 stsp
1437 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1438 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1439 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1440 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1441 088449d3 2021-09-26 stsp
1442 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1443 49c543a6 2022-03-31 naddy ret=$?
1444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1445 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1446 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1447 088449d3 2021-09-26 stsp return 1
1448 088449d3 2021-09-26 stsp fi
1449 088449d3 2021-09-26 stsp
1450 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1451 088449d3 2021-09-26 stsp
1452 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1453 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1454 49c543a6 2022-03-31 naddy ret=$?
1455 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1456 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1457 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1458 088449d3 2021-09-26 stsp return 1
1459 088449d3 2021-09-26 stsp fi
1460 088449d3 2021-09-26 stsp
1461 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1462 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1463 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1464 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1465 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1466 49c543a6 2022-03-31 naddy ret=$?
1467 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1468 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1469 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1470 088449d3 2021-09-26 stsp return 1
1471 088449d3 2021-09-26 stsp fi
1472 088449d3 2021-09-26 stsp
1473 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1474 088449d3 2021-09-26 stsp
1475 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1476 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1477 49c543a6 2022-03-31 naddy ret=$?
1478 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1479 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1480 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1481 088449d3 2021-09-26 stsp return 1
1482 088449d3 2021-09-26 stsp fi
1483 088449d3 2021-09-26 stsp
1484 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1485 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1486 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1487 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1488 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1489 49c543a6 2022-03-31 naddy ret=$?
1490 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1491 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1492 088449d3 2021-09-26 stsp fi
1493 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1494 b2b3fce1 2022-10-29 op }
1495 b2b3fce1 2022-10-29 op
1496 b2b3fce1 2022-10-29 op test_merge_umask() {
1497 b2b3fce1 2022-10-29 op local testroot=`test_init merge_umask`
1498 b2b3fce1 2022-10-29 op
1499 b2b3fce1 2022-10-29 op (cd $testroot/repo && git checkout -q -b newbranch)
1500 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/repo/alpha
1501 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1502 b2b3fce1 2022-10-29 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1503 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1504 b2b3fce1 2022-10-29 op
1505 b2b3fce1 2022-10-29 op # diverge from newbranch
1506 b2b3fce1 2022-10-29 op (cd "$testroot/repo" && git checkout -q master)
1507 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/repo/beta
1508 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing zeto no master"
1509 b2b3fce1 2022-10-29 op
1510 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1511 b2b3fce1 2022-10-29 op
1512 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1513 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1514 b2b3fce1 2022-10-29 op
1515 b2b3fce1 2022-10-29 op for f in alpha gamma/delta; do
1516 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1517 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1518 b2b3fce1 2022-10-29 op echo "$f is not 0600 after merge" >&2
1519 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
1520 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1521 b2b3fce1 2022-10-29 op fi
1522 b2b3fce1 2022-10-29 op done
1523 b2b3fce1 2022-10-29 op
1524 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1525 088449d3 2021-09-26 stsp }
1526 d51d11be 2023-02-21 op
1527 d51d11be 2023-02-21 op test_merge_gitconfig_author() {
1528 d51d11be 2023-02-21 op local testroot=`test_init merge_gitconfig_author`
1529 d51d11be 2023-02-21 op
1530 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.name 'Flan Luck')
1531 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1532 d51d11be 2023-02-21 op
1533 d51d11be 2023-02-21 op (cd $testroot/repo && git checkout -q -b newbranch)
1534 d51d11be 2023-02-21 op echo "modified alpha on branch" >$testroot/repo/alpha
1535 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1536 d51d11be 2023-02-21 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1537 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1538 088449d3 2021-09-26 stsp
1539 d51d11be 2023-02-21 op # diverge from newbranch
1540 d51d11be 2023-02-21 op (cd "$testroot/repo" && git checkout -q master)
1541 d51d11be 2023-02-21 op echo "modified beta on master" >$testroot/repo/beta
1542 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing zeto no master"
1543 d51d11be 2023-02-21 op
1544 d51d11be 2023-02-21 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1545 d51d11be 2023-02-21 op
1546 d51d11be 2023-02-21 op # unset in a subshell to avoid affecting our environment
1547 d51d11be 2023-02-21 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1548 d51d11be 2023-02-21 op got merge newbranch > /dev/null)
1549 d51d11be 2023-02-21 op
1550 d51d11be 2023-02-21 op (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1551 d51d11be 2023-02-21 op ret=$?
1552 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1553 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1554 d51d11be 2023-02-21 op return 1
1555 d51d11be 2023-02-21 op fi
1556 d51d11be 2023-02-21 op
1557 d51d11be 2023-02-21 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1558 d51d11be 2023-02-21 op > $testroot/stdout.expected
1559 d51d11be 2023-02-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1560 d51d11be 2023-02-21 op ret=$?
1561 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1562 d51d11be 2023-02-21 op diff -u $testroot/stdout.expected $testroot/stdout
1563 d51d11be 2023-02-21 op fi
1564 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1565 d51d11be 2023-02-21 op }
1566 d51d11be 2023-02-21 op
1567 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1568 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1569 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1570 6b5246e4 2023-06-05 stsp run_test test_merge_continue_new_commit
1571 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1572 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1573 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1574 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1575 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
1576 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
1577 088449d3 2021-09-26 stsp run_test test_merge_interrupt
1578 b2b3fce1 2022-10-29 op run_test test_merge_umask
1579 d51d11be 2023-02-21 op run_test test_merge_gitconfig_author