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 179f9db0 2023-06-20 falsifian # create a divergent commit
56 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
57 f259c4c1 2021-09-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
58 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
59 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
60 f259c4c1 2021-09-24 stsp
61 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
62 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
63 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
64 49c543a6 2022-03-31 naddy ret=$?
65 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
66 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
67 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
68 f259c4c1 2021-09-24 stsp return 1
69 f259c4c1 2021-09-24 stsp fi
70 f259c4c1 2021-09-24 stsp echo -n "got: work tree must be updated before it can be used " \
71 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
72 f259c4c1 2021-09-24 stsp echo "to merge a branch" >> $testroot/stderr.expected
73 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
74 49c543a6 2022-03-31 naddy ret=$?
75 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
76 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
77 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
78 f259c4c1 2021-09-24 stsp return 1
79 f259c4c1 2021-09-24 stsp fi
80 f259c4c1 2021-09-24 stsp
81 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
82 49c543a6 2022-03-31 naddy ret=$?
83 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
84 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
85 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
86 f259c4c1 2021-09-24 stsp return 1
87 f259c4c1 2021-09-24 stsp fi
88 f259c4c1 2021-09-24 stsp
89 5e91dae4 2022-08-30 stsp # must not use a mixed-commit work tree with 'got merge'
90 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
91 49c543a6 2022-03-31 naddy ret=$?
92 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
93 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
94 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
95 f259c4c1 2021-09-24 stsp return 1
96 f259c4c1 2021-09-24 stsp fi
97 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
98 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
99 49c543a6 2022-03-31 naddy ret=$?
100 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
101 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
102 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
103 f259c4c1 2021-09-24 stsp return 1
104 f259c4c1 2021-09-24 stsp fi
105 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains files from multiple base commits; " \
106 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
107 f259c4c1 2021-09-24 stsp echo "the entire work tree must be updated first" \
108 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
109 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
110 49c543a6 2022-03-31 naddy ret=$?
111 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
112 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
113 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
114 f259c4c1 2021-09-24 stsp return 1
115 f259c4c1 2021-09-24 stsp fi
116 f259c4c1 2021-09-24 stsp
117 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
118 49c543a6 2022-03-31 naddy ret=$?
119 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
120 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
121 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
122 f259c4c1 2021-09-24 stsp return 1
123 f259c4c1 2021-09-24 stsp fi
124 f259c4c1 2021-09-24 stsp
125 5e91dae4 2022-08-30 stsp # must not have staged files with 'got merge'
126 f259c4c1 2021-09-24 stsp echo "modified file alpha" > $testroot/wt/alpha
127 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got stage alpha > /dev/null)
128 49c543a6 2022-03-31 naddy ret=$?
129 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
130 f259c4c1 2021-09-24 stsp echo "got stage failed unexpectedly" >&2
131 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
132 f259c4c1 2021-09-24 stsp return 1
133 f259c4c1 2021-09-24 stsp fi
134 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
135 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
136 49c543a6 2022-03-31 naddy ret=$?
137 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
138 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
139 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
140 f259c4c1 2021-09-24 stsp return 1
141 f259c4c1 2021-09-24 stsp fi
142 f259c4c1 2021-09-24 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
143 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
144 49c543a6 2022-03-31 naddy ret=$?
145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
146 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
147 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
148 f259c4c1 2021-09-24 stsp return 1
149 f259c4c1 2021-09-24 stsp fi
150 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
151 49c543a6 2022-03-31 naddy ret=$?
152 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
153 f259c4c1 2021-09-24 stsp echo "got unstage failed unexpectedly" >&2
154 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
155 f259c4c1 2021-09-24 stsp return 1
156 f259c4c1 2021-09-24 stsp fi
157 f259c4c1 2021-09-24 stsp
158 5e91dae4 2022-08-30 stsp # must not have local changes with 'got merge'
159 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
160 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
161 49c543a6 2022-03-31 naddy ret=$?
162 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
163 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
164 ea4ee74a 2023-06-17 op test_done "$testroot" "1"
165 f259c4c1 2021-09-24 stsp return 1
166 f259c4c1 2021-09-24 stsp fi
167 f259c4c1 2021-09-24 stsp echo -n "got: work tree contains local changes; " \
168 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
169 f259c4c1 2021-09-24 stsp echo "these changes must be committed or reverted first" \
170 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
171 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
172 49c543a6 2022-03-31 naddy ret=$?
173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
174 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
175 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
176 f259c4c1 2021-09-24 stsp return 1
177 f259c4c1 2021-09-24 stsp fi
178 f259c4c1 2021-09-24 stsp
179 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
180 49c543a6 2022-03-31 naddy ret=$?
181 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
182 f259c4c1 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
183 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
184 f259c4c1 2021-09-24 stsp return 1
185 f259c4c1 2021-09-24 stsp fi
186 f259c4c1 2021-09-24 stsp
187 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch > $testroot/stdout)
188 49c543a6 2022-03-31 naddy ret=$?
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
191 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
192 f259c4c1 2021-09-24 stsp return 1
193 f259c4c1 2021-09-24 stsp fi
194 f259c4c1 2021-09-24 stsp
195 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
196 f259c4c1 2021-09-24 stsp
197 f259c4c1 2021-09-24 stsp echo "G alpha" >> $testroot/stdout.expected
198 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
199 5267b9e4 2021-09-26 stsp echo "A dotgotbar.link" >> $testroot/stdout.expected
200 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
201 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
202 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
203 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
204 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
205 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
206 f259c4c1 2021-09-24 stsp
207 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
208 49c543a6 2022-03-31 naddy ret=$?
209 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
210 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
211 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
212 f259c4c1 2021-09-24 stsp return 1
213 f259c4c1 2021-09-24 stsp fi
214 f259c4c1 2021-09-24 stsp
215 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
216 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
217 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
218 49c543a6 2022-03-31 naddy ret=$?
219 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
220 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
221 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
222 f259c4c1 2021-09-24 stsp return 1
223 f259c4c1 2021-09-24 stsp fi
224 f259c4c1 2021-09-24 stsp
225 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/content.expected
226 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
227 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
228 49c543a6 2022-03-31 naddy ret=$?
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
231 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
232 f259c4c1 2021-09-24 stsp return 1
233 f259c4c1 2021-09-24 stsp fi
234 f259c4c1 2021-09-24 stsp
235 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
236 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
237 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
238 f259c4c1 2021-09-24 stsp return 1
239 f259c4c1 2021-09-24 stsp fi
240 f259c4c1 2021-09-24 stsp
241 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
242 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
243 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
244 49c543a6 2022-03-31 naddy ret=$?
245 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
246 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
247 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
248 f259c4c1 2021-09-24 stsp return 1
249 f259c4c1 2021-09-24 stsp fi
250 f259c4c1 2021-09-24 stsp
251 5267b9e4 2021-09-26 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
252 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is not a symlink"
253 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
254 5267b9e4 2021-09-26 stsp return 1
255 5267b9e4 2021-09-26 stsp fi
256 5267b9e4 2021-09-26 stsp
257 f259c4c1 2021-09-24 stsp readlink $testroot/wt/symlink > $testroot/stdout
258 f259c4c1 2021-09-24 stsp echo "alpha" > $testroot/stdout.expected
259 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 49c543a6 2022-03-31 naddy ret=$?
261 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
262 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
264 f259c4c1 2021-09-24 stsp return 1
265 f259c4c1 2021-09-24 stsp fi
266 f259c4c1 2021-09-24 stsp
267 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
268 f259c4c1 2021-09-24 stsp
269 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
270 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
271 49c543a6 2022-03-31 naddy ret=$?
272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
273 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
274 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
275 f259c4c1 2021-09-24 stsp return 1
276 f259c4c1 2021-09-24 stsp fi
277 f259c4c1 2021-09-24 stsp
278 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
279 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
280 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
281 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
282 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
283 49c543a6 2022-03-31 naddy ret=$?
284 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
285 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
286 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
287 f259c4c1 2021-09-24 stsp return 1
288 f259c4c1 2021-09-24 stsp fi
289 f259c4c1 2021-09-24 stsp
290 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
291 f259c4c1 2021-09-24 stsp
292 5267b9e4 2021-09-26 stsp echo 'U dotgotbar.link' > $testroot/stdout.expected
293 5267b9e4 2021-09-26 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
294 5267b9e4 2021-09-26 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
295 5267b9e4 2021-09-26 stsp echo >> $testroot/stdout.expected
296 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
297 49c543a6 2022-03-31 naddy ret=$?
298 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
299 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
300 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
301 f259c4c1 2021-09-24 stsp return 1
302 f259c4c1 2021-09-24 stsp fi
303 f259c4c1 2021-09-24 stsp
304 5267b9e4 2021-09-26 stsp # update has changed the bad symlink into a regular file
305 5267b9e4 2021-09-26 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
306 5267b9e4 2021-09-26 stsp echo "dotgotbar.link is a symlink"
307 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
308 5267b9e4 2021-09-26 stsp return 1
309 5267b9e4 2021-09-26 stsp fi
310 5267b9e4 2021-09-26 stsp
311 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
312 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
313 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
314 5267b9e4 2021-09-26 stsp echo "parent 2: $branch_commit5" >> $testroot/stdout.expected
315 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
316 49c543a6 2022-03-31 naddy ret=$?
317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
318 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
319 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
320 5267b9e4 2021-09-26 stsp return 1
321 5267b9e4 2021-09-26 stsp fi
322 5267b9e4 2021-09-26 stsp
323 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -c $merge_commit -R > $testroot/stdout
324 49c543a6 2022-03-31 naddy ret=$?
325 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
326 5267b9e4 2021-09-26 stsp echo "got tree failed unexpectedly" >&2
327 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
328 5267b9e4 2021-09-26 stsp return 1
329 5267b9e4 2021-09-26 stsp fi
330 5267b9e4 2021-09-26 stsp
331 5267b9e4 2021-09-26 stsp # bad symlink dotgotbar.link appears as a symlink in the merge commit:
332 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
333 5267b9e4 2021-09-26 stsp alpha
334 5267b9e4 2021-09-26 stsp dotgotbar.link@ -> .got/bar
335 5267b9e4 2021-09-26 stsp epsilon/
336 5267b9e4 2021-09-26 stsp epsilon/new
337 5267b9e4 2021-09-26 stsp epsilon/zeta
338 5267b9e4 2021-09-26 stsp gamma/
339 5267b9e4 2021-09-26 stsp gamma/delta
340 5267b9e4 2021-09-26 stsp symlink@ -> alpha
341 5267b9e4 2021-09-26 stsp EOF
342 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
343 179f9db0 2023-06-20 falsifian ret=$?
344 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
345 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
346 179f9db0 2023-06-20 falsifian fi
347 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
348 179f9db0 2023-06-20 falsifian }
349 179f9db0 2023-06-20 falsifian
350 179f9db0 2023-06-20 falsifian test_merge_forward() {
351 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_forward`
352 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
353 179f9db0 2023-06-20 falsifian
354 179f9db0 2023-06-20 falsifian # Create a commit before branching, which will be used to help test
355 179f9db0 2023-06-20 falsifian # preconditions for "got merge".
356 179f9db0 2023-06-20 falsifian echo "modified alpha" > $testroot/repo/alpha
357 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "common commit"
358 179f9db0 2023-06-20 falsifian local commit1=`git_show_head $testroot/repo`
359 179f9db0 2023-06-20 falsifian
360 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
361 179f9db0 2023-06-20 falsifian echo "modified beta on branch" > $testroot/repo/beta
362 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to beta on newbranch"
363 179f9db0 2023-06-20 falsifian local commit2=`git_show_head $testroot/repo`
364 179f9db0 2023-06-20 falsifian
365 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
366 179f9db0 2023-06-20 falsifian ret=$?
367 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
368 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
369 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
370 179f9db0 2023-06-20 falsifian return 1
371 179f9db0 2023-06-20 falsifian fi
372 179f9db0 2023-06-20 falsifian
373 179f9db0 2023-06-20 falsifian # must not use a mixed-commit work tree with 'got merge'
374 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
375 179f9db0 2023-06-20 falsifian ret=$?
376 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
377 179f9db0 2023-06-20 falsifian echo "got update failed unexpectedly" >&2
378 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
379 179f9db0 2023-06-20 falsifian return 1
380 179f9db0 2023-06-20 falsifian fi
381 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
382 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
383 179f9db0 2023-06-20 falsifian ret=$?
384 179f9db0 2023-06-20 falsifian if [ $ret -eq 0 ]; then
385 179f9db0 2023-06-20 falsifian echo "got merge succeeded unexpectedly" >&2
386 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
387 179f9db0 2023-06-20 falsifian return 1
388 179f9db0 2023-06-20 falsifian fi
389 179f9db0 2023-06-20 falsifian echo -n "got: work tree contains files from multiple base commits; " \
390 179f9db0 2023-06-20 falsifian > $testroot/stderr.expected
391 179f9db0 2023-06-20 falsifian echo "the entire work tree must be updated first" \
392 179f9db0 2023-06-20 falsifian >> $testroot/stderr.expected
393 179f9db0 2023-06-20 falsifian cmp -s $testroot/stderr.expected $testroot/stderr
394 179f9db0 2023-06-20 falsifian ret=$?
395 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
396 179f9db0 2023-06-20 falsifian diff -u $testroot/stderr.expected $testroot/stderr
397 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
398 179f9db0 2023-06-20 falsifian return 1
399 179f9db0 2023-06-20 falsifian fi
400 179f9db0 2023-06-20 falsifian
401 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got update > /dev/null)
402 179f9db0 2023-06-20 falsifian ret=$?
403 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
404 179f9db0 2023-06-20 falsifian echo "got update failed unexpectedly" >&2
405 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
406 179f9db0 2023-06-20 falsifian return 1
407 179f9db0 2023-06-20 falsifian fi
408 179f9db0 2023-06-20 falsifian
409 179f9db0 2023-06-20 falsifian # 'got merge -n' refuses to fast-forward
410 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge -n newbranch \
411 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
412 179f9db0 2023-06-20 falsifian ret=$?
413 179f9db0 2023-06-20 falsifian if [ $ret -eq 0 ]; then
414 179f9db0 2023-06-20 falsifian echo "got merge succeeded unexpectedly" >&2
415 179f9db0 2023-06-20 falsifian test_done "$testroot" "1"
416 179f9db0 2023-06-20 falsifian return 1
417 179f9db0 2023-06-20 falsifian fi
418 f25e229e 2023-06-22 stsp
419 f25e229e 2023-06-22 stsp echo -n "got: there are no changes to merge since " \
420 f25e229e 2023-06-22 stsp > $testroot/stderr.expected
421 f25e229e 2023-06-22 stsp echo -n "refs/heads/newbranch is already based on " \
422 179f9db0 2023-06-20 falsifian >> $testroot/stderr.expected
423 f25e229e 2023-06-22 stsp echo -n "refs/heads/master; merge cannot be interrupted " \
424 f25e229e 2023-06-22 stsp >> $testroot/stderr.expected
425 f25e229e 2023-06-22 stsp echo "for amending; -n: option cannot be used" \
426 f25e229e 2023-06-22 stsp >> $testroot/stderr.expected
427 f25e229e 2023-06-22 stsp
428 179f9db0 2023-06-20 falsifian cmp -s $testroot/stderr.expected $testroot/stderr
429 179f9db0 2023-06-20 falsifian ret=$?
430 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
431 179f9db0 2023-06-20 falsifian diff -u $testroot/stderr.expected $testroot/stderr
432 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
433 179f9db0 2023-06-20 falsifian return 1
434 179f9db0 2023-06-20 falsifian fi
435 179f9db0 2023-06-20 falsifian
436 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
437 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
438 179f9db0 2023-06-20 falsifian ret=$?
439 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
440 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
441 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
442 179f9db0 2023-06-20 falsifian return 1
443 179f9db0 2023-06-20 falsifian fi
444 179f9db0 2023-06-20 falsifian
445 179f9db0 2023-06-20 falsifian echo "Forwarding refs/heads/master to refs/heads/newbranch" \
446 179f9db0 2023-06-20 falsifian > $testroot/stdout.expected
447 179f9db0 2023-06-20 falsifian echo "U beta" >> $testroot/stdout.expected
448 179f9db0 2023-06-20 falsifian echo "Updated to commit $commit2" \
449 179f9db0 2023-06-20 falsifian >> $testroot/stdout.expected
450 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
451 49c543a6 2022-03-31 naddy ret=$?
452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
453 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
454 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
455 179f9db0 2023-06-20 falsifian return 1
456 f259c4c1 2021-09-24 stsp fi
457 179f9db0 2023-06-20 falsifian
458 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
459 179f9db0 2023-06-20 falsifian echo -n "commit $commit2 " > $testroot/stdout.expected
460 179f9db0 2023-06-20 falsifian echo "(master, newbranch)" >> $testroot/stdout.expected
461 179f9db0 2023-06-20 falsifian echo "commit $commit1" >> $testroot/stdout.expected
462 179f9db0 2023-06-20 falsifian echo "commit $commit0" >> $testroot/stdout.expected
463 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
464 179f9db0 2023-06-20 falsifian ret=$?
465 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
466 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
467 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
468 179f9db0 2023-06-20 falsifian return 1
469 179f9db0 2023-06-20 falsifian fi
470 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
471 179f9db0 2023-06-20 falsifian }
472 179f9db0 2023-06-20 falsifian
473 179f9db0 2023-06-20 falsifian test_merge_backward() {
474 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_backward`
475 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
476 179f9db0 2023-06-20 falsifian
477 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
478 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q master)
479 179f9db0 2023-06-20 falsifian echo "modified alpha on master" > $testroot/repo/alpha
480 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to alpha on master"
481 179f9db0 2023-06-20 falsifian
482 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
483 179f9db0 2023-06-20 falsifian ret=$?
484 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
485 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
486 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
487 179f9db0 2023-06-20 falsifian return 1
488 179f9db0 2023-06-20 falsifian fi
489 179f9db0 2023-06-20 falsifian
490 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
491 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
492 179f9db0 2023-06-20 falsifian ret=$?
493 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
494 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
495 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
496 179f9db0 2023-06-20 falsifian return 1
497 179f9db0 2023-06-20 falsifian fi
498 179f9db0 2023-06-20 falsifian echo "Already up-to-date" > $testroot/stdout.expected
499 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
500 179f9db0 2023-06-20 falsifian ret=$?
501 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
502 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
503 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
504 179f9db0 2023-06-20 falsifian return 1
505 179f9db0 2023-06-20 falsifian fi
506 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
507 f259c4c1 2021-09-24 stsp }
508 f259c4c1 2021-09-24 stsp
509 f259c4c1 2021-09-24 stsp test_merge_continue() {
510 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
511 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
512 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
513 f259c4c1 2021-09-24 stsp
514 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
515 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
516 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
517 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
518 f259c4c1 2021-09-24 stsp
519 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
520 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
521 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
522 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
523 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
524 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
525 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
526 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
527 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
528 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
529 f259c4c1 2021-09-24 stsp
530 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
531 49c543a6 2022-03-31 naddy ret=$?
532 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
533 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
534 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
535 f259c4c1 2021-09-24 stsp return 1
536 f259c4c1 2021-09-24 stsp fi
537 f259c4c1 2021-09-24 stsp
538 f259c4c1 2021-09-24 stsp # create a conflicting commit
539 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
540 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
541 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
542 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
543 f259c4c1 2021-09-24 stsp
544 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
545 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
546 49c543a6 2022-03-31 naddy ret=$?
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
549 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
550 f259c4c1 2021-09-24 stsp return 1
551 f259c4c1 2021-09-24 stsp fi
552 f259c4c1 2021-09-24 stsp
553 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
554 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
555 49c543a6 2022-03-31 naddy ret=$?
556 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
557 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
558 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
559 f259c4c1 2021-09-24 stsp return 1
560 f259c4c1 2021-09-24 stsp fi
561 f259c4c1 2021-09-24 stsp
562 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
563 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
564 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
565 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
566 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
567 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
568 49c543a6 2022-03-31 naddy ret=$?
569 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
570 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
571 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
572 f259c4c1 2021-09-24 stsp return 1
573 f259c4c1 2021-09-24 stsp fi
574 f259c4c1 2021-09-24 stsp
575 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
576 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
577 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
578 49c543a6 2022-03-31 naddy ret=$?
579 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
580 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
581 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
582 f259c4c1 2021-09-24 stsp return 1
583 f259c4c1 2021-09-24 stsp fi
584 f259c4c1 2021-09-24 stsp
585 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
586 f259c4c1 2021-09-24 stsp
587 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
588 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
589 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
590 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
591 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
592 49c543a6 2022-03-31 naddy ret=$?
593 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
594 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
595 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
596 f259c4c1 2021-09-24 stsp return 1
597 f259c4c1 2021-09-24 stsp fi
598 f259c4c1 2021-09-24 stsp
599 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
600 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
601 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
602 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
603 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
604 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
605 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
606 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
607 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
608 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
609 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
610 49c543a6 2022-03-31 naddy ret=$?
611 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
612 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
613 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
614 f259c4c1 2021-09-24 stsp return 1
615 f259c4c1 2021-09-24 stsp fi
616 f259c4c1 2021-09-24 stsp
617 f259c4c1 2021-09-24 stsp # resolve the conflict
618 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
619 f259c4c1 2021-09-24 stsp
620 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
621 49c543a6 2022-03-31 naddy ret=$?
622 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
623 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
624 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
625 f259c4c1 2021-09-24 stsp return 1
626 f259c4c1 2021-09-24 stsp fi
627 f259c4c1 2021-09-24 stsp
628 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
629 f259c4c1 2021-09-24 stsp
630 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
631 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
632 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
633 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
634 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
635 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
636 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
637 f259c4c1 2021-09-24 stsp
638 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
639 49c543a6 2022-03-31 naddy ret=$?
640 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
641 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
642 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
643 f259c4c1 2021-09-24 stsp return 1
644 f259c4c1 2021-09-24 stsp fi
645 f259c4c1 2021-09-24 stsp
646 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
647 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
648 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
649 49c543a6 2022-03-31 naddy ret=$?
650 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
651 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
652 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
653 f259c4c1 2021-09-24 stsp return 1
654 f259c4c1 2021-09-24 stsp fi
655 f259c4c1 2021-09-24 stsp
656 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
657 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
658 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
659 49c543a6 2022-03-31 naddy ret=$?
660 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
661 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
662 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
663 f259c4c1 2021-09-24 stsp return 1
664 f259c4c1 2021-09-24 stsp fi
665 f259c4c1 2021-09-24 stsp
666 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
667 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
668 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
669 f259c4c1 2021-09-24 stsp return 1
670 f259c4c1 2021-09-24 stsp fi
671 f259c4c1 2021-09-24 stsp
672 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
673 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
674 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
675 49c543a6 2022-03-31 naddy ret=$?
676 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
677 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
678 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
679 f259c4c1 2021-09-24 stsp return 1
680 f259c4c1 2021-09-24 stsp fi
681 f259c4c1 2021-09-24 stsp
682 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
683 f259c4c1 2021-09-24 stsp
684 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
685 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
686 49c543a6 2022-03-31 naddy ret=$?
687 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
688 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
689 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
690 f259c4c1 2021-09-24 stsp return 1
691 f259c4c1 2021-09-24 stsp fi
692 f259c4c1 2021-09-24 stsp
693 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
694 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
695 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
696 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
697 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
698 49c543a6 2022-03-31 naddy ret=$?
699 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
700 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
701 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
702 f259c4c1 2021-09-24 stsp return 1
703 f259c4c1 2021-09-24 stsp fi
704 f259c4c1 2021-09-24 stsp
705 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
706 f259c4c1 2021-09-24 stsp
707 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
708 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
709 49c543a6 2022-03-31 naddy ret=$?
710 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
711 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
712 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
713 f259c4c1 2021-09-24 stsp return 1
714 f259c4c1 2021-09-24 stsp fi
715 f259c4c1 2021-09-24 stsp
716 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
717 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
718 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
719 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
720 6b5246e4 2023-06-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 6b5246e4 2023-06-05 stsp ret=$?
722 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
723 6b5246e4 2023-06-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
724 6b5246e4 2023-06-05 stsp fi
725 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
726 6b5246e4 2023-06-05 stsp }
727 6b5246e4 2023-06-05 stsp
728 6b5246e4 2023-06-05 stsp test_merge_continue_new_commit() {
729 6b5246e4 2023-06-05 stsp # "got merge -c" should refuse to run if the current branch tip has
730 6b5246e4 2023-06-05 stsp # changed since the merge was started, to avoid clobbering the changes.
731 6b5246e4 2023-06-05 stsp local testroot=`test_init merge_continue_new_commit`
732 6b5246e4 2023-06-05 stsp
733 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q -b newbranch)
734 6b5246e4 2023-06-05 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
735 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
736 6b5246e4 2023-06-05 stsp
737 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q master)
738 6b5246e4 2023-06-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
739 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master"
740 6b5246e4 2023-06-05 stsp
741 6b5246e4 2023-06-05 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
742 6b5246e4 2023-06-05 stsp ret=$?
743 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
744 6b5246e4 2023-06-05 stsp echo "got checkout failed unexpectedly" >&2
745 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
746 6b5246e4 2023-06-05 stsp return 1
747 6b5246e4 2023-06-05 stsp fi
748 6b5246e4 2023-06-05 stsp
749 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -n newbranch >/dev/null)
750 6b5246e4 2023-06-05 stsp ret=$?
751 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
752 6b5246e4 2023-06-05 stsp echo "got merge failed unexpectedly" >&2
753 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
754 6b5246e4 2023-06-05 stsp return 1
755 6b5246e4 2023-06-05 stsp fi
756 6b5246e4 2023-06-05 stsp
757 6b5246e4 2023-06-05 stsp echo "modified alpha again on master" > $testroot/repo/alpha
758 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master again"
759 6b5246e4 2023-06-05 stsp
760 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
761 6b5246e4 2023-06-05 stsp ret=$?
762 6b5246e4 2023-06-05 stsp if [ $ret -eq 0 ]; then
763 6b5246e4 2023-06-05 stsp echo "got merge succeeded unexpectedly" >&2
764 6b5246e4 2023-06-05 stsp test_done "$testroot" "1"
765 6b5246e4 2023-06-05 stsp return 1
766 6b5246e4 2023-06-05 stsp fi
767 6b5246e4 2023-06-05 stsp
768 6b5246e4 2023-06-05 stsp echo -n > $testroot/stdout.expected
769 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
770 49c543a6 2022-03-31 naddy ret=$?
771 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
772 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
773 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
774 6b5246e4 2023-06-05 stsp return 1
775 6b5246e4 2023-06-05 stsp fi
776 6b5246e4 2023-06-05 stsp
777 6b5246e4 2023-06-05 stsp echo -n "got: merging cannot proceed because the work tree is no " \
778 6b5246e4 2023-06-05 stsp > $testroot/stderr.expected
779 6b5246e4 2023-06-05 stsp echo "longer up-to-date; merge must be aborted and retried" \
780 6b5246e4 2023-06-05 stsp >> $testroot/stderr.expected
781 6b5246e4 2023-06-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
782 6b5246e4 2023-06-05 stsp ret=$?
783 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
784 6b5246e4 2023-06-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
785 f259c4c1 2021-09-24 stsp fi
786 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
787 f259c4c1 2021-09-24 stsp }
788 f259c4c1 2021-09-24 stsp
789 f259c4c1 2021-09-24 stsp test_merge_abort() {
790 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
791 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
792 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
793 f259c4c1 2021-09-24 stsp
794 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
795 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
796 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
797 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
798 f259c4c1 2021-09-24 stsp
799 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
800 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
801 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
802 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
803 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
804 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
805 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
806 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
807 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
808 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
809 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
810 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
811 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
812 f259c4c1 2021-09-24 stsp
813 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
814 49c543a6 2022-03-31 naddy ret=$?
815 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
816 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
817 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
818 f259c4c1 2021-09-24 stsp return 1
819 f259c4c1 2021-09-24 stsp fi
820 41f061b2 2021-10-05 stsp
821 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
822 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
823 f259c4c1 2021-09-24 stsp
824 f259c4c1 2021-09-24 stsp # create a conflicting commit
825 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
826 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
827 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
828 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
829 f259c4c1 2021-09-24 stsp
830 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
831 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
832 49c543a6 2022-03-31 naddy ret=$?
833 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
834 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
835 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
836 f259c4c1 2021-09-24 stsp return 1
837 f259c4c1 2021-09-24 stsp fi
838 f259c4c1 2021-09-24 stsp
839 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
840 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
841 49c543a6 2022-03-31 naddy ret=$?
842 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
843 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
844 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
845 f259c4c1 2021-09-24 stsp return 1
846 f259c4c1 2021-09-24 stsp fi
847 f259c4c1 2021-09-24 stsp
848 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
849 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
850 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
851 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
852 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
853 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
854 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
855 49c543a6 2022-03-31 naddy ret=$?
856 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
857 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
858 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
859 f259c4c1 2021-09-24 stsp return 1
860 f259c4c1 2021-09-24 stsp fi
861 f259c4c1 2021-09-24 stsp
862 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
863 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
864 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
865 49c543a6 2022-03-31 naddy ret=$?
866 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
867 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
868 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
869 f259c4c1 2021-09-24 stsp return 1
870 f259c4c1 2021-09-24 stsp fi
871 af179be7 2023-04-14 stsp
872 af179be7 2023-04-14 stsp # unrelated added file added during conflict resolution
873 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
874 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
875 f259c4c1 2021-09-24 stsp
876 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
877 f259c4c1 2021-09-24 stsp
878 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
879 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
880 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
881 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
882 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
883 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
884 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
885 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
886 49c543a6 2022-03-31 naddy ret=$?
887 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
888 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 -a > $testroot/stdout)
894 49c543a6 2022-03-31 naddy ret=$?
895 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
896 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
897 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
898 f259c4c1 2021-09-24 stsp return 1
899 f259c4c1 2021-09-24 stsp fi
900 f259c4c1 2021-09-24 stsp
901 af179be7 2023-04-14 stsp echo "R added-file" > $testroot/stdout.expected
902 af179be7 2023-04-14 stsp echo "R alpha" >> $testroot/stdout.expected
903 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
904 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
905 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
906 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
907 af179be7 2023-04-14 stsp echo "G added-file" >> $testroot/stdout.expected
908 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
909 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
910 f259c4c1 2021-09-24 stsp
911 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
912 49c543a6 2022-03-31 naddy ret=$?
913 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
914 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
915 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
916 f259c4c1 2021-09-24 stsp return 1
917 f259c4c1 2021-09-24 stsp fi
918 f259c4c1 2021-09-24 stsp
919 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
920 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
921 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
922 49c543a6 2022-03-31 naddy ret=$?
923 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
924 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
925 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
926 f259c4c1 2021-09-24 stsp return 1
927 f259c4c1 2021-09-24 stsp fi
928 f259c4c1 2021-09-24 stsp
929 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
930 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
931 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
932 49c543a6 2022-03-31 naddy ret=$?
933 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
934 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
935 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
936 f259c4c1 2021-09-24 stsp return 1
937 f259c4c1 2021-09-24 stsp fi
938 f259c4c1 2021-09-24 stsp
939 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
940 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
941 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
942 49c543a6 2022-03-31 naddy ret=$?
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
945 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
946 f259c4c1 2021-09-24 stsp return 1
947 f259c4c1 2021-09-24 stsp fi
948 f259c4c1 2021-09-24 stsp
949 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
950 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
951 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
952 f259c4c1 2021-09-24 stsp return 1
953 f259c4c1 2021-09-24 stsp fi
954 f259c4c1 2021-09-24 stsp
955 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
956 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
957 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
958 f259c4c1 2021-09-24 stsp return 1
959 f259c4c1 2021-09-24 stsp fi
960 f259c4c1 2021-09-24 stsp
961 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
962 f259c4c1 2021-09-24 stsp
963 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
964 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
965 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 49c543a6 2022-03-31 naddy ret=$?
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
970 f259c4c1 2021-09-24 stsp return 1
971 f259c4c1 2021-09-24 stsp fi
972 f259c4c1 2021-09-24 stsp
973 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
974 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
975 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
976 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
977 49c543a6 2022-03-31 naddy ret=$?
978 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
979 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
980 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
981 f259c4c1 2021-09-24 stsp return 1
982 f259c4c1 2021-09-24 stsp fi
983 f259c4c1 2021-09-24 stsp
984 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
985 f259c4c1 2021-09-24 stsp
986 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
987 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
988 49c543a6 2022-03-31 naddy ret=$?
989 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
990 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
991 f259c4c1 2021-09-24 stsp fi
992 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
993 f259c4c1 2021-09-24 stsp }
994 f259c4c1 2021-09-24 stsp
995 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
996 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
997 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
998 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
999 f259c4c1 2021-09-24 stsp
1000 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1001 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1002 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1003 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1004 f259c4c1 2021-09-24 stsp
1005 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1006 49c543a6 2022-03-31 naddy ret=$?
1007 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1008 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1009 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1010 f259c4c1 2021-09-24 stsp return 1
1011 f259c4c1 2021-09-24 stsp fi
1012 f259c4c1 2021-09-24 stsp
1013 f259c4c1 2021-09-24 stsp # create a conflicting commit
1014 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1015 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1016 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1017 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1018 f259c4c1 2021-09-24 stsp
1019 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1020 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1021 49c543a6 2022-03-31 naddy ret=$?
1022 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1023 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1024 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1025 f259c4c1 2021-09-24 stsp return 1
1026 f259c4c1 2021-09-24 stsp fi
1027 f259c4c1 2021-09-24 stsp
1028 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1029 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1030 49c543a6 2022-03-31 naddy ret=$?
1031 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1032 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1033 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1034 f259c4c1 2021-09-24 stsp return 1
1035 f259c4c1 2021-09-24 stsp fi
1036 f259c4c1 2021-09-24 stsp
1037 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1038 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1039 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1040 49c543a6 2022-03-31 naddy ret=$?
1041 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1042 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1043 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1044 f259c4c1 2021-09-24 stsp return 1
1045 f259c4c1 2021-09-24 stsp fi
1046 f259c4c1 2021-09-24 stsp
1047 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1048 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1049 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1050 49c543a6 2022-03-31 naddy ret=$?
1051 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1052 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
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 status > $testroot/stdout)
1058 f259c4c1 2021-09-24 stsp
1059 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1060 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1061 49c543a6 2022-03-31 naddy ret=$?
1062 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1063 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1064 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1065 f259c4c1 2021-09-24 stsp return 1
1066 f259c4c1 2021-09-24 stsp fi
1067 f259c4c1 2021-09-24 stsp
1068 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
1069 42761529 2023-06-01 stsp "integrate newbranch" "merge newbranch" "stage alpha"; do
1070 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
1071 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
1072 42761529 2023-06-01 stsp ret=$?
1073 42761529 2023-06-01 stsp if [ $ret -eq 0 ]; then
1074 42761529 2023-06-01 stsp echo "got $cmd succeeded unexpectedly" >&2
1075 42761529 2023-06-01 stsp test_done "$testroot" "1"
1076 42761529 2023-06-01 stsp return 1
1077 42761529 2023-06-01 stsp fi
1078 f259c4c1 2021-09-24 stsp
1079 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
1080 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1081 49c543a6 2022-03-31 naddy ret=$?
1082 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1083 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1084 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1085 f259c4c1 2021-09-24 stsp return 1
1086 f259c4c1 2021-09-24 stsp fi
1087 f259c4c1 2021-09-24 stsp
1088 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
1089 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1090 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
1091 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1092 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1093 49c543a6 2022-03-31 naddy ret=$?
1094 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1095 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1096 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1097 f259c4c1 2021-09-24 stsp return 1
1098 f259c4c1 2021-09-24 stsp fi
1099 f259c4c1 2021-09-24 stsp done
1100 f259c4c1 2021-09-24 stsp
1101 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1102 f259c4c1 2021-09-24 stsp }
1103 f259c4c1 2021-09-24 stsp
1104 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
1105 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
1106 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1107 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1108 f259c4c1 2021-09-24 stsp
1109 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1110 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1111 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1112 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1113 f259c4c1 2021-09-24 stsp
1114 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1115 f259c4c1 2021-09-24 stsp > /dev/null
1116 49c543a6 2022-03-31 naddy ret=$?
1117 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1118 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1119 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1120 f259c4c1 2021-09-24 stsp return 1
1121 f259c4c1 2021-09-24 stsp fi
1122 f259c4c1 2021-09-24 stsp
1123 f259c4c1 2021-09-24 stsp # create a conflicting commit
1124 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1125 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1126 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1127 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1128 f259c4c1 2021-09-24 stsp
1129 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1130 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1131 49c543a6 2022-03-31 naddy ret=$?
1132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1133 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1134 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1135 f259c4c1 2021-09-24 stsp return 1
1136 f259c4c1 2021-09-24 stsp fi
1137 f259c4c1 2021-09-24 stsp
1138 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1139 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1140 49c543a6 2022-03-31 naddy ret=$?
1141 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1142 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1143 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1144 f259c4c1 2021-09-24 stsp return 1
1145 f259c4c1 2021-09-24 stsp fi
1146 f259c4c1 2021-09-24 stsp
1147 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
1148 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1149 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
1150 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1151 49c543a6 2022-03-31 naddy ret=$?
1152 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1153 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1154 f259c4c1 2021-09-24 stsp fi
1155 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1156 f259c4c1 2021-09-24 stsp }
1157 f259c4c1 2021-09-24 stsp
1158 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
1159 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
1160 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1161 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1162 f259c4c1 2021-09-24 stsp
1163 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1164 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1165 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1166 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
1167 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1168 f259c4c1 2021-09-24 stsp
1169 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1170 49c543a6 2022-03-31 naddy ret=$?
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1173 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1174 f259c4c1 2021-09-24 stsp return 1
1175 f259c4c1 2021-09-24 stsp fi
1176 f259c4c1 2021-09-24 stsp
1177 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
1178 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1179 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1180 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
1181 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1182 f259c4c1 2021-09-24 stsp
1183 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1184 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1185 49c543a6 2022-03-31 naddy ret=$?
1186 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1187 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1188 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1189 f259c4c1 2021-09-24 stsp return 1
1190 f259c4c1 2021-09-24 stsp fi
1191 f259c4c1 2021-09-24 stsp
1192 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1193 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1194 49c543a6 2022-03-31 naddy ret=$?
1195 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1196 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1197 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1198 f259c4c1 2021-09-24 stsp return 1
1199 f259c4c1 2021-09-24 stsp fi
1200 f259c4c1 2021-09-24 stsp
1201 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
1202 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1203 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1204 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1205 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1206 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1207 49c543a6 2022-03-31 naddy ret=$?
1208 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1209 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1210 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1211 f259c4c1 2021-09-24 stsp return 1
1212 f259c4c1 2021-09-24 stsp fi
1213 f259c4c1 2021-09-24 stsp
1214 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1215 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1216 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1217 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1218 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1219 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1220 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1221 49c543a6 2022-03-31 naddy ret=$?
1222 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1223 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1224 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1225 f259c4c1 2021-09-24 stsp return 1
1226 f259c4c1 2021-09-24 stsp fi
1227 f259c4c1 2021-09-24 stsp
1228 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1229 f259c4c1 2021-09-24 stsp
1230 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1231 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1232 49c543a6 2022-03-31 naddy ret=$?
1233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1234 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1236 a6a8f8bb 2021-09-24 stsp return 1
1237 a6a8f8bb 2021-09-24 stsp fi
1238 a6a8f8bb 2021-09-24 stsp
1239 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1240 a6a8f8bb 2021-09-24 stsp }
1241 a6a8f8bb 2021-09-24 stsp
1242 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1243 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1244 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1245 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1246 a6a8f8bb 2021-09-24 stsp
1247 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1248 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1249 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1250 35d2583f 2023-04-17 stsp local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1251 a6a8f8bb 2021-09-24 stsp
1252 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1253 49c543a6 2022-03-31 naddy ret=$?
1254 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1255 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1256 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1257 a6a8f8bb 2021-09-24 stsp return 1
1258 a6a8f8bb 2021-09-24 stsp fi
1259 a6a8f8bb 2021-09-24 stsp
1260 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1261 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1262 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1263 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1264 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1265 a6a8f8bb 2021-09-24 stsp
1266 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1267 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1268 49c543a6 2022-03-31 naddy ret=$?
1269 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1270 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1271 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1272 a6a8f8bb 2021-09-24 stsp return 1
1273 a6a8f8bb 2021-09-24 stsp fi
1274 a6a8f8bb 2021-09-24 stsp
1275 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1276 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1277 49c543a6 2022-03-31 naddy ret=$?
1278 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1279 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1280 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1281 a6a8f8bb 2021-09-24 stsp return 1
1282 a6a8f8bb 2021-09-24 stsp fi
1283 a6a8f8bb 2021-09-24 stsp
1284 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1285 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1286 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1287 49c543a6 2022-03-31 naddy ret=$?
1288 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1289 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1290 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1291 a6a8f8bb 2021-09-24 stsp return 1
1292 a6a8f8bb 2021-09-24 stsp fi
1293 a6a8f8bb 2021-09-24 stsp
1294 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1295 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1296 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1297 49c543a6 2022-03-31 naddy ret=$?
1298 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1299 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1300 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1301 a6a8f8bb 2021-09-24 stsp return 1
1302 a6a8f8bb 2021-09-24 stsp fi
1303 a6a8f8bb 2021-09-24 stsp
1304 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1305 a6a8f8bb 2021-09-24 stsp
1306 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1307 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1308 49c543a6 2022-03-31 naddy ret=$?
1309 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1310 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1311 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1312 f259c4c1 2021-09-24 stsp return 1
1313 f259c4c1 2021-09-24 stsp fi
1314 f259c4c1 2021-09-24 stsp
1315 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1316 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1317 49c543a6 2022-03-31 naddy ret=$?
1318 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1319 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1320 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1321 a6a8f8bb 2021-09-24 stsp return 1
1322 a6a8f8bb 2021-09-24 stsp fi
1323 a6a8f8bb 2021-09-24 stsp
1324 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1325 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1326 49c543a6 2022-03-31 naddy ret=$?
1327 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1328 35d2583f 2023-04-17 stsp echo "got merge failed unexpectedly" >&2
1329 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1330 a6a8f8bb 2021-09-24 stsp return 1
1331 a6a8f8bb 2021-09-24 stsp fi
1332 a6a8f8bb 2021-09-24 stsp
1333 35d2583f 2023-04-17 stsp echo -n '' > $testroot/stderr.expected
1334 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1335 49c543a6 2022-03-31 naddy ret=$?
1336 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1337 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1338 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1339 35d2583f 2023-04-17 stsp return 1
1340 35d2583f 2023-04-17 stsp fi
1341 35d2583f 2023-04-17 stsp
1342 35d2583f 2023-04-17 stsp local merge_commit=`git_show_head $testroot/repo`
1343 35d2583f 2023-04-17 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1344 35d2583f 2023-04-17 stsp > $testroot/stdout.expected
1345 35d2583f 2023-04-17 stsp echo $merge_commit >> $testroot/stdout.expected
1346 35d2583f 2023-04-17 stsp
1347 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1348 35d2583f 2023-04-17 stsp ret=$?
1349 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1350 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1351 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1352 a6a8f8bb 2021-09-24 stsp return 1
1353 a6a8f8bb 2021-09-24 stsp fi
1354 a6a8f8bb 2021-09-24 stsp
1355 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1356 a6a8f8bb 2021-09-24 stsp
1357 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1358 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1359 49c543a6 2022-03-31 naddy ret=$?
1360 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1361 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1362 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1363 35d2583f 2023-04-17 stsp return 1
1364 4e91ef15 2021-09-26 stsp fi
1365 35d2583f 2023-04-17 stsp
1366 35d2583f 2023-04-17 stsp # We should have created a merge commit with two parents.
1367 35d2583f 2023-04-17 stsp got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1368 35d2583f 2023-04-17 stsp > $testroot/stdout
1369 35d2583f 2023-04-17 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1370 35d2583f 2023-04-17 stsp echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1371 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1372 35d2583f 2023-04-17 stsp ret=$?
1373 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1374 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1375 35d2583f 2023-04-17 stsp fi
1376 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1377 4e91ef15 2021-09-26 stsp }
1378 4e91ef15 2021-09-26 stsp
1379 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1380 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1381 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1382 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1383 4e91ef15 2021-09-26 stsp
1384 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1385 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1386 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1387 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1388 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1389 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1390 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1391 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1392 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1393 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1394 4e91ef15 2021-09-26 stsp
1395 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1396 49c543a6 2022-03-31 naddy ret=$?
1397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1398 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1399 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1400 4e91ef15 2021-09-26 stsp return 1
1401 4e91ef15 2021-09-26 stsp fi
1402 4e91ef15 2021-09-26 stsp
1403 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1404 49c543a6 2022-03-31 naddy ret=$?
1405 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1406 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1407 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1408 4e91ef15 2021-09-26 stsp return 1
1409 4e91ef15 2021-09-26 stsp fi
1410 4e91ef15 2021-09-26 stsp
1411 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1412 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1413 4e91ef15 2021-09-26 stsp A be/lots/of
1414 4e91ef15 2021-09-26 stsp A files/here
1415 4e91ef15 2021-09-26 stsp A there/should
1416 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1417 4e91ef15 2021-09-26 stsp EOF
1418 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1419 49c543a6 2022-03-31 naddy ret=$?
1420 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1421 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1422 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1423 4e91ef15 2021-09-26 stsp return 1
1424 4e91ef15 2021-09-26 stsp fi
1425 4e91ef15 2021-09-26 stsp
1426 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1427 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1428 49c543a6 2022-03-31 naddy ret=$?
1429 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1430 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1431 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1432 4e91ef15 2021-09-26 stsp return 1
1433 4e91ef15 2021-09-26 stsp fi
1434 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1435 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1436 49c543a6 2022-03-31 naddy ret=$?
1437 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1438 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1440 4e91ef15 2021-09-26 stsp return 1
1441 a6a8f8bb 2021-09-24 stsp fi
1442 4e91ef15 2021-09-26 stsp
1443 4e91ef15 2021-09-26 stsp # update the 'files' branch
1444 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1445 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1446 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1447 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1448 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1449 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1450 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1451 4e91ef15 2021-09-26 stsp
1452 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1453 49c543a6 2022-03-31 naddy ret=$?
1454 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1455 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1456 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1457 4e91ef15 2021-09-26 stsp return 1
1458 4e91ef15 2021-09-26 stsp fi
1459 4e91ef15 2021-09-26 stsp
1460 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1461 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1462 49c543a6 2022-03-31 naddy ret=$?
1463 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1464 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1465 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1466 4e91ef15 2021-09-26 stsp return 1
1467 4e91ef15 2021-09-26 stsp fi
1468 4e91ef15 2021-09-26 stsp
1469 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1470 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1471 4e91ef15 2021-09-26 stsp G be/lots/of
1472 4e91ef15 2021-09-26 stsp A indeed
1473 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1474 4e91ef15 2021-09-26 stsp EOF
1475 4e91ef15 2021-09-26 stsp
1476 4e91ef15 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 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1480 4e91ef15 2021-09-26 stsp fi
1481 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1482 f259c4c1 2021-09-24 stsp }
1483 088449d3 2021-09-26 stsp
1484 088449d3 2021-09-26 stsp test_merge_interrupt() {
1485 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1486 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1487 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1488 088449d3 2021-09-26 stsp
1489 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1490 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1491 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1492 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1493 088449d3 2021-09-26 stsp
1494 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1495 49c543a6 2022-03-31 naddy ret=$?
1496 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1497 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1498 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1499 088449d3 2021-09-26 stsp return 1
1500 088449d3 2021-09-26 stsp fi
1501 088449d3 2021-09-26 stsp
1502 088449d3 2021-09-26 stsp # create a non-conflicting commit
1503 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1504 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1505 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1506 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1507 f259c4c1 2021-09-24 stsp
1508 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1509 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1510 49c543a6 2022-03-31 naddy ret=$?
1511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1512 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1513 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1514 088449d3 2021-09-26 stsp return 1
1515 088449d3 2021-09-26 stsp fi
1516 088449d3 2021-09-26 stsp
1517 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1518 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1519 49c543a6 2022-03-31 naddy ret=$?
1520 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1521 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1522 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1523 088449d3 2021-09-26 stsp return 1
1524 088449d3 2021-09-26 stsp fi
1525 088449d3 2021-09-26 stsp
1526 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1527 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1528 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1529 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1530 49c543a6 2022-03-31 naddy ret=$?
1531 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1532 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1533 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1534 088449d3 2021-09-26 stsp return 1
1535 088449d3 2021-09-26 stsp fi
1536 088449d3 2021-09-26 stsp
1537 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1538 088449d3 2021-09-26 stsp
1539 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1540 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1541 49c543a6 2022-03-31 naddy ret=$?
1542 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1543 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1544 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1545 088449d3 2021-09-26 stsp return 1
1546 088449d3 2021-09-26 stsp fi
1547 088449d3 2021-09-26 stsp
1548 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1549 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1550 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1551 49c543a6 2022-03-31 naddy ret=$?
1552 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1553 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1554 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1555 088449d3 2021-09-26 stsp return 1
1556 088449d3 2021-09-26 stsp fi
1557 088449d3 2021-09-26 stsp
1558 088449d3 2021-09-26 stsp # adjust merge result
1559 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1560 088449d3 2021-09-26 stsp
1561 088449d3 2021-09-26 stsp # continue the merge
1562 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1563 49c543a6 2022-03-31 naddy ret=$?
1564 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1565 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1566 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1567 088449d3 2021-09-26 stsp return 1
1568 088449d3 2021-09-26 stsp fi
1569 088449d3 2021-09-26 stsp
1570 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1571 088449d3 2021-09-26 stsp
1572 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1573 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1574 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1575 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1576 088449d3 2021-09-26 stsp
1577 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1578 49c543a6 2022-03-31 naddy ret=$?
1579 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1580 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1581 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1582 088449d3 2021-09-26 stsp return 1
1583 088449d3 2021-09-26 stsp fi
1584 088449d3 2021-09-26 stsp
1585 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1586 088449d3 2021-09-26 stsp
1587 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1588 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1589 49c543a6 2022-03-31 naddy ret=$?
1590 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1591 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1592 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1593 088449d3 2021-09-26 stsp return 1
1594 088449d3 2021-09-26 stsp fi
1595 088449d3 2021-09-26 stsp
1596 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1597 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1598 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1599 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1600 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1601 49c543a6 2022-03-31 naddy ret=$?
1602 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1603 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1604 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1605 088449d3 2021-09-26 stsp return 1
1606 088449d3 2021-09-26 stsp fi
1607 088449d3 2021-09-26 stsp
1608 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1609 088449d3 2021-09-26 stsp
1610 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1611 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1612 49c543a6 2022-03-31 naddy ret=$?
1613 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1614 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1615 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1616 088449d3 2021-09-26 stsp return 1
1617 088449d3 2021-09-26 stsp fi
1618 088449d3 2021-09-26 stsp
1619 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1620 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1621 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1622 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1623 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1624 49c543a6 2022-03-31 naddy ret=$?
1625 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1626 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1627 088449d3 2021-09-26 stsp fi
1628 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1629 b2b3fce1 2022-10-29 op }
1630 b2b3fce1 2022-10-29 op
1631 b2b3fce1 2022-10-29 op test_merge_umask() {
1632 b2b3fce1 2022-10-29 op local testroot=`test_init merge_umask`
1633 b2b3fce1 2022-10-29 op
1634 b2b3fce1 2022-10-29 op (cd $testroot/repo && git checkout -q -b newbranch)
1635 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/repo/alpha
1636 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1637 b2b3fce1 2022-10-29 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1638 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1639 b2b3fce1 2022-10-29 op
1640 b2b3fce1 2022-10-29 op # diverge from newbranch
1641 b2b3fce1 2022-10-29 op (cd "$testroot/repo" && git checkout -q master)
1642 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/repo/beta
1643 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing zeto no master"
1644 b2b3fce1 2022-10-29 op
1645 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1646 b2b3fce1 2022-10-29 op
1647 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1648 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1649 b2b3fce1 2022-10-29 op
1650 b2b3fce1 2022-10-29 op for f in alpha gamma/delta; do
1651 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1652 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1653 b2b3fce1 2022-10-29 op echo "$f is not 0600 after merge" >&2
1654 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
1655 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1656 b2b3fce1 2022-10-29 op fi
1657 b2b3fce1 2022-10-29 op done
1658 b2b3fce1 2022-10-29 op
1659 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1660 088449d3 2021-09-26 stsp }
1661 d51d11be 2023-02-21 op
1662 d51d11be 2023-02-21 op test_merge_gitconfig_author() {
1663 d51d11be 2023-02-21 op local testroot=`test_init merge_gitconfig_author`
1664 d51d11be 2023-02-21 op
1665 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.name 'Flan Luck')
1666 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1667 d51d11be 2023-02-21 op
1668 d51d11be 2023-02-21 op (cd $testroot/repo && git checkout -q -b newbranch)
1669 d51d11be 2023-02-21 op echo "modified alpha on branch" >$testroot/repo/alpha
1670 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1671 d51d11be 2023-02-21 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1672 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1673 088449d3 2021-09-26 stsp
1674 d51d11be 2023-02-21 op # diverge from newbranch
1675 d51d11be 2023-02-21 op (cd "$testroot/repo" && git checkout -q master)
1676 d51d11be 2023-02-21 op echo "modified beta on master" >$testroot/repo/beta
1677 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing zeto no master"
1678 d51d11be 2023-02-21 op
1679 d51d11be 2023-02-21 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1680 d51d11be 2023-02-21 op
1681 d51d11be 2023-02-21 op # unset in a subshell to avoid affecting our environment
1682 d51d11be 2023-02-21 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1683 d51d11be 2023-02-21 op got merge newbranch > /dev/null)
1684 d51d11be 2023-02-21 op
1685 d51d11be 2023-02-21 op (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1686 d51d11be 2023-02-21 op ret=$?
1687 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1688 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1689 d51d11be 2023-02-21 op return 1
1690 d51d11be 2023-02-21 op fi
1691 d51d11be 2023-02-21 op
1692 d51d11be 2023-02-21 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1693 d51d11be 2023-02-21 op > $testroot/stdout.expected
1694 d51d11be 2023-02-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1695 d51d11be 2023-02-21 op ret=$?
1696 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1697 d51d11be 2023-02-21 op diff -u $testroot/stdout.expected $testroot/stdout
1698 d51d11be 2023-02-21 op fi
1699 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1700 d51d11be 2023-02-21 op }
1701 13342307 2023-06-21 stsp
1702 13342307 2023-06-21 stsp test_merge_fetched_branch() {
1703 13342307 2023-06-21 stsp local testroot=`test_init merge_fetched_branch`
1704 13342307 2023-06-21 stsp local testurl=ssh://127.0.0.1/$testroot
1705 13342307 2023-06-21 stsp local commit_id=`git_show_head $testroot/repo`
1706 13342307 2023-06-21 stsp
1707 13342307 2023-06-21 stsp got clone -q $testurl/repo $testroot/repo-clone
1708 13342307 2023-06-21 stsp ret=$?
1709 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1710 13342307 2023-06-21 stsp echo "got clone command failed unexpectedly" >&2
1711 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1712 13342307 2023-06-21 stsp return 1
1713 13342307 2023-06-21 stsp fi
1714 d51d11be 2023-02-21 op
1715 13342307 2023-06-21 stsp echo "modified alpha" > $testroot/repo/alpha
1716 13342307 2023-06-21 stsp git_commit $testroot/repo -m "modified alpha"
1717 13342307 2023-06-21 stsp local commit_id2=`git_show_head $testroot/repo`
1718 13342307 2023-06-21 stsp
1719 13342307 2023-06-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout
1720 13342307 2023-06-21 stsp ret=$?
1721 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1722 13342307 2023-06-21 stsp echo "got fetch command failed unexpectedly" >&2
1723 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1724 13342307 2023-06-21 stsp return 1
1725 13342307 2023-06-21 stsp fi
1726 13342307 2023-06-21 stsp
1727 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1728 13342307 2023-06-21 stsp
1729 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1730 13342307 2023-06-21 stsp ret=$?
1731 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1732 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1733 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1734 13342307 2023-06-21 stsp return 1
1735 13342307 2023-06-21 stsp fi
1736 13342307 2023-06-21 stsp
1737 13342307 2023-06-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1738 13342307 2023-06-21 stsp
1739 13342307 2023-06-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1740 13342307 2023-06-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1741 13342307 2023-06-21 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1742 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1743 13342307 2023-06-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
1744 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1745 13342307 2023-06-21 stsp
1746 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1747 13342307 2023-06-21 stsp ret=$?
1748 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1749 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1750 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1751 13342307 2023-06-21 stsp return 1
1752 13342307 2023-06-21 stsp fi
1753 13342307 2023-06-21 stsp
1754 13342307 2023-06-21 stsp got checkout $testroot/repo-clone $testroot/wt > /dev/null
1755 13342307 2023-06-21 stsp
1756 13342307 2023-06-21 stsp echo "modified beta" > $testroot/wt/beta
1757 13342307 2023-06-21 stsp (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1758 13342307 2023-06-21 stsp local commit_id3=`git_show_head $testroot/repo-clone`
1759 13342307 2023-06-21 stsp
1760 13342307 2023-06-21 stsp (cd $testroot/wt && got update > /dev/null)
1761 13342307 2023-06-21 stsp (cd $testroot/wt && got merge origin/master > $testroot/stdout)
1762 13342307 2023-06-21 stsp local merge_commit_id=`git_show_head $testroot/repo-clone`
1763 13342307 2023-06-21 stsp
1764 13342307 2023-06-21 stsp cat > $testroot/stdout.expected <<EOF
1765 13342307 2023-06-21 stsp G alpha
1766 13342307 2023-06-21 stsp Merged refs/remotes/origin/master into refs/heads/master: $merge_commit_id
1767 13342307 2023-06-21 stsp EOF
1768 13342307 2023-06-21 stsp
1769 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1770 13342307 2023-06-21 stsp ret=$?
1771 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1772 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1773 13342307 2023-06-21 stsp fi
1774 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1775 13342307 2023-06-21 stsp }
1776 13342307 2023-06-21 stsp
1777 13342307 2023-06-21 stsp test_merge_fetched_branch_remote() {
1778 13342307 2023-06-21 stsp local testroot=`test_init merge_fetched_branch_remote`
1779 13342307 2023-06-21 stsp local testurl=ssh://127.0.0.1/$testroot
1780 13342307 2023-06-21 stsp local commit_id=`git_show_head $testroot/repo`
1781 13342307 2023-06-21 stsp
1782 13342307 2023-06-21 stsp got clone -q $testurl/repo $testroot/repo-clone
1783 13342307 2023-06-21 stsp ret=$?
1784 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1785 13342307 2023-06-21 stsp echo "got clone command failed unexpectedly" >&2
1786 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1787 13342307 2023-06-21 stsp return 1
1788 13342307 2023-06-21 stsp fi
1789 13342307 2023-06-21 stsp
1790 13342307 2023-06-21 stsp echo "modified alpha" > $testroot/repo/alpha
1791 13342307 2023-06-21 stsp git_commit $testroot/repo -m "modified alpha"
1792 13342307 2023-06-21 stsp local commit_id2=`git_show_head $testroot/repo`
1793 13342307 2023-06-21 stsp
1794 13342307 2023-06-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout
1795 13342307 2023-06-21 stsp ret=$?
1796 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1797 13342307 2023-06-21 stsp echo "got fetch command failed unexpectedly" >&2
1798 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1799 13342307 2023-06-21 stsp return 1
1800 13342307 2023-06-21 stsp fi
1801 13342307 2023-06-21 stsp
1802 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1803 13342307 2023-06-21 stsp
1804 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1805 13342307 2023-06-21 stsp ret=$?
1806 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1807 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1808 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1809 13342307 2023-06-21 stsp return 1
1810 13342307 2023-06-21 stsp fi
1811 13342307 2023-06-21 stsp
1812 13342307 2023-06-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1813 13342307 2023-06-21 stsp
1814 13342307 2023-06-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1815 13342307 2023-06-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1816 13342307 2023-06-21 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1817 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1818 13342307 2023-06-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
1819 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1820 13342307 2023-06-21 stsp
1821 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1822 13342307 2023-06-21 stsp ret=$?
1823 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1824 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1825 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1826 13342307 2023-06-21 stsp return 1
1827 13342307 2023-06-21 stsp fi
1828 13342307 2023-06-21 stsp
1829 13342307 2023-06-21 stsp got checkout $testroot/repo-clone $testroot/wt > /dev/null
1830 13342307 2023-06-21 stsp
1831 13342307 2023-06-21 stsp echo "modified beta" > $testroot/wt/beta
1832 13342307 2023-06-21 stsp (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1833 13342307 2023-06-21 stsp local commit_id3=`git_show_head $testroot/repo-clone`
1834 13342307 2023-06-21 stsp
1835 13342307 2023-06-21 stsp (cd $testroot/wt && got update -b origin/master > /dev/null)
1836 13342307 2023-06-21 stsp (cd $testroot/wt && got merge master > \
1837 13342307 2023-06-21 stsp $testroot/stdout 2> $testroot/stderr)
1838 13342307 2023-06-21 stsp local merge_commit_id=`git_show_head $testroot/repo-clone`
1839 13342307 2023-06-21 stsp
1840 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1841 13342307 2023-06-21 stsp
1842 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1843 13342307 2023-06-21 stsp ret=$?
1844 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1845 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1846 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1847 13342307 2023-06-21 stsp return 1
1848 13342307 2023-06-21 stsp fi
1849 13342307 2023-06-21 stsp
1850 13342307 2023-06-21 stsp echo -n "got: work tree's current branch refs/remotes/origin/master " \
1851 13342307 2023-06-21 stsp > $testroot/stderr.expected
1852 13342307 2023-06-21 stsp echo -n 'is outside the "refs/heads/" reference namespace; ' \
1853 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1854 13342307 2023-06-21 stsp echo -n "update -b required: will not commit to a branch " \
1855 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1856 13342307 2023-06-21 stsp echo 'outside the "refs/heads/" reference namespace' \
1857 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1858 13342307 2023-06-21 stsp
1859 13342307 2023-06-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1860 13342307 2023-06-21 stsp ret=$?
1861 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1862 13342307 2023-06-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1863 13342307 2023-06-21 stsp fi
1864 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1865 13342307 2023-06-21 stsp }
1866 13342307 2023-06-21 stsp
1867 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1868 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1869 179f9db0 2023-06-20 falsifian run_test test_merge_forward
1870 179f9db0 2023-06-20 falsifian run_test test_merge_backward
1871 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1872 6b5246e4 2023-06-05 stsp run_test test_merge_continue_new_commit
1873 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1874 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1875 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1876 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1877 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
1878 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
1879 088449d3 2021-09-26 stsp run_test test_merge_interrupt
1880 b2b3fce1 2022-10-29 op run_test test_merge_umask
1881 d51d11be 2023-02-21 op run_test test_merge_gitconfig_author
1882 13342307 2023-06-21 stsp run_test test_merge_fetched_branch
1883 13342307 2023-06-21 stsp run_test test_merge_fetched_branch_remote