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 481cdc74 2023-07-01 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
464 481cdc74 2023-07-01 falsifian ret=$?
465 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
466 481cdc74 2023-07-01 falsifian diff -u $testroot/stdout.expected $testroot/stdout
467 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
468 481cdc74 2023-07-01 falsifian return 1
469 481cdc74 2023-07-01 falsifian fi
470 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
471 481cdc74 2023-07-01 falsifian }
472 481cdc74 2023-07-01 falsifian
473 481cdc74 2023-07-01 falsifian test_merge_forward_commit() {
474 481cdc74 2023-07-01 falsifian local testroot=`test_init merge_forward_commit`
475 481cdc74 2023-07-01 falsifian local commit0=`git_show_head $testroot/repo`
476 481cdc74 2023-07-01 falsifian
477 481cdc74 2023-07-01 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
478 481cdc74 2023-07-01 falsifian echo "modified alpha on branch" > $testroot/repo/alpha
479 481cdc74 2023-07-01 falsifian git_commit $testroot/repo -m "committing to alpha on newbranch"
480 481cdc74 2023-07-01 falsifian local commit1=`git_show_head $testroot/repo`
481 481cdc74 2023-07-01 falsifian
482 481cdc74 2023-07-01 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
483 481cdc74 2023-07-01 falsifian ret=$?
484 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
485 481cdc74 2023-07-01 falsifian echo "got checkout failed unexpectedly" >&2
486 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
487 481cdc74 2023-07-01 falsifian return 1
488 481cdc74 2023-07-01 falsifian fi
489 481cdc74 2023-07-01 falsifian
490 481cdc74 2023-07-01 falsifian (cd $testroot/wt && got merge -M newbranch > $testroot/stdout)
491 481cdc74 2023-07-01 falsifian ret=$?
492 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
493 481cdc74 2023-07-01 falsifian echo "got merge failed unexpectedly" >&2
494 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
495 481cdc74 2023-07-01 falsifian return 1
496 481cdc74 2023-07-01 falsifian fi
497 481cdc74 2023-07-01 falsifian
498 481cdc74 2023-07-01 falsifian local merge_commit=`git_show_branch_head $testroot/repo master`
499 481cdc74 2023-07-01 falsifian
500 481cdc74 2023-07-01 falsifian echo "G alpha" >> $testroot/stdout.expected
501 481cdc74 2023-07-01 falsifian echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
502 481cdc74 2023-07-01 falsifian >> $testroot/stdout.expected
503 481cdc74 2023-07-01 falsifian echo $merge_commit >> $testroot/stdout.expected
504 481cdc74 2023-07-01 falsifian
505 481cdc74 2023-07-01 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
506 481cdc74 2023-07-01 falsifian ret=$?
507 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
508 481cdc74 2023-07-01 falsifian diff -u $testroot/stdout.expected $testroot/stdout
509 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
510 481cdc74 2023-07-01 falsifian return 1
511 481cdc74 2023-07-01 falsifian fi
512 481cdc74 2023-07-01 falsifian
513 481cdc74 2023-07-01 falsifian # We should have created a merge commit with two parents.
514 481cdc74 2023-07-01 falsifian (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
515 481cdc74 2023-07-01 falsifian echo "parent 1: $commit0" > $testroot/stdout.expected
516 481cdc74 2023-07-01 falsifian echo "parent 2: $commit1" >> $testroot/stdout.expected
517 481cdc74 2023-07-01 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
518 481cdc74 2023-07-01 falsifian ret=$?
519 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
520 481cdc74 2023-07-01 falsifian diff -u $testroot/stdout.expected $testroot/stdout
521 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
522 481cdc74 2023-07-01 falsifian return 1
523 481cdc74 2023-07-01 falsifian fi
524 481cdc74 2023-07-01 falsifian
525 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
526 481cdc74 2023-07-01 falsifian }
527 481cdc74 2023-07-01 falsifian
528 481cdc74 2023-07-01 falsifian test_merge_forward_interrupt() {
529 481cdc74 2023-07-01 falsifian # Test -M and -n options together.
530 481cdc74 2023-07-01 falsifian local testroot=`test_init merge_forward_commit`
531 481cdc74 2023-07-01 falsifian local commit0=`git_show_head $testroot/repo`
532 481cdc74 2023-07-01 falsifian
533 481cdc74 2023-07-01 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
534 481cdc74 2023-07-01 falsifian echo "modified alpha on branch" > $testroot/repo/alpha
535 481cdc74 2023-07-01 falsifian git_commit $testroot/repo -m "committing to alpha on newbranch"
536 481cdc74 2023-07-01 falsifian local commit1=`git_show_head $testroot/repo`
537 481cdc74 2023-07-01 falsifian
538 481cdc74 2023-07-01 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
539 481cdc74 2023-07-01 falsifian ret=$?
540 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
541 481cdc74 2023-07-01 falsifian echo "got checkout failed unexpectedly" >&2
542 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
543 481cdc74 2023-07-01 falsifian return 1
544 481cdc74 2023-07-01 falsifian fi
545 481cdc74 2023-07-01 falsifian
546 481cdc74 2023-07-01 falsifian (cd $testroot/wt && got merge -M -n newbranch > $testroot/stdout)
547 481cdc74 2023-07-01 falsifian ret=$?
548 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
549 481cdc74 2023-07-01 falsifian echo "got merge failed unexpectedly" >&2
550 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
551 481cdc74 2023-07-01 falsifian return 1
552 481cdc74 2023-07-01 falsifian fi
553 481cdc74 2023-07-01 falsifian
554 481cdc74 2023-07-01 falsifian echo "G alpha" > $testroot/stdout.expected
555 481cdc74 2023-07-01 falsifian echo "Merge of refs/heads/newbranch interrupted on request" \
556 481cdc74 2023-07-01 falsifian >> $testroot/stdout.expected
557 481cdc74 2023-07-01 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
558 481cdc74 2023-07-01 falsifian ret=$?
559 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
560 481cdc74 2023-07-01 falsifian diff -u $testroot/stdout.expected $testroot/stdout
561 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
562 481cdc74 2023-07-01 falsifian return 1
563 481cdc74 2023-07-01 falsifian fi
564 481cdc74 2023-07-01 falsifian
565 481cdc74 2023-07-01 falsifian # Continue the merge.
566 481cdc74 2023-07-01 falsifian (cd $testroot/wt && got merge -c > $testroot/stdout)
567 481cdc74 2023-07-01 falsifian ret=$?
568 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
569 481cdc74 2023-07-01 falsifian echo "got merge failed unexpectedly" >&2
570 481cdc74 2023-07-01 falsifian test_done "$testroot" "$ret"
571 481cdc74 2023-07-01 falsifian return 1
572 481cdc74 2023-07-01 falsifian fi
573 481cdc74 2023-07-01 falsifian
574 481cdc74 2023-07-01 falsifian local merge_commit=`git_show_branch_head $testroot/repo master`
575 481cdc74 2023-07-01 falsifian
576 481cdc74 2023-07-01 falsifian echo "M alpha" > $testroot/stdout.expected
577 481cdc74 2023-07-01 falsifian echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
578 481cdc74 2023-07-01 falsifian >> $testroot/stdout.expected
579 481cdc74 2023-07-01 falsifian echo $merge_commit >> $testroot/stdout.expected
580 481cdc74 2023-07-01 falsifian
581 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
582 179f9db0 2023-06-20 falsifian ret=$?
583 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
584 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
585 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
586 179f9db0 2023-06-20 falsifian return 1
587 179f9db0 2023-06-20 falsifian fi
588 481cdc74 2023-07-01 falsifian
589 481cdc74 2023-07-01 falsifian # We should have created a merge commit with two parents.
590 481cdc74 2023-07-01 falsifian (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
591 481cdc74 2023-07-01 falsifian echo "parent 1: $commit0" > $testroot/stdout.expected
592 481cdc74 2023-07-01 falsifian echo "parent 2: $commit1" >> $testroot/stdout.expected
593 481cdc74 2023-07-01 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
594 481cdc74 2023-07-01 falsifian ret=$?
595 481cdc74 2023-07-01 falsifian if [ $ret -ne 0 ]; then
596 481cdc74 2023-07-01 falsifian diff -u $testroot/stdout.expected $testroot/stdout
597 481cdc74 2023-07-01 falsifian fi
598 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
599 179f9db0 2023-06-20 falsifian }
600 179f9db0 2023-06-20 falsifian
601 179f9db0 2023-06-20 falsifian test_merge_backward() {
602 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_backward`
603 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
604 179f9db0 2023-06-20 falsifian
605 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
606 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q master)
607 179f9db0 2023-06-20 falsifian echo "modified alpha on master" > $testroot/repo/alpha
608 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to alpha on master"
609 179f9db0 2023-06-20 falsifian
610 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
611 179f9db0 2023-06-20 falsifian ret=$?
612 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
613 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
614 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
615 179f9db0 2023-06-20 falsifian return 1
616 179f9db0 2023-06-20 falsifian fi
617 179f9db0 2023-06-20 falsifian
618 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
619 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
620 179f9db0 2023-06-20 falsifian ret=$?
621 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
622 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
623 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
624 179f9db0 2023-06-20 falsifian return 1
625 179f9db0 2023-06-20 falsifian fi
626 179f9db0 2023-06-20 falsifian echo "Already up-to-date" > $testroot/stdout.expected
627 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
628 179f9db0 2023-06-20 falsifian ret=$?
629 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
630 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
631 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
632 179f9db0 2023-06-20 falsifian return 1
633 179f9db0 2023-06-20 falsifian fi
634 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
635 f259c4c1 2021-09-24 stsp }
636 f259c4c1 2021-09-24 stsp
637 f259c4c1 2021-09-24 stsp test_merge_continue() {
638 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
639 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
640 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
641 f259c4c1 2021-09-24 stsp
642 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
643 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
644 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
645 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
646 f259c4c1 2021-09-24 stsp
647 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
648 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
649 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
650 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
651 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
652 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
653 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
654 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
655 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
656 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
657 f259c4c1 2021-09-24 stsp
658 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
659 49c543a6 2022-03-31 naddy ret=$?
660 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
661 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
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 # create a conflicting commit
667 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
668 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
669 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
670 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
671 f259c4c1 2021-09-24 stsp
672 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
673 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
674 49c543a6 2022-03-31 naddy ret=$?
675 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
676 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
677 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
678 f259c4c1 2021-09-24 stsp return 1
679 f259c4c1 2021-09-24 stsp fi
680 f259c4c1 2021-09-24 stsp
681 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
682 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
683 49c543a6 2022-03-31 naddy ret=$?
684 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
685 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
686 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
687 f259c4c1 2021-09-24 stsp return 1
688 f259c4c1 2021-09-24 stsp fi
689 f259c4c1 2021-09-24 stsp
690 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
691 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
692 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
693 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
694 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
695 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
696 49c543a6 2022-03-31 naddy ret=$?
697 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
698 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
699 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
700 f259c4c1 2021-09-24 stsp return 1
701 f259c4c1 2021-09-24 stsp fi
702 f259c4c1 2021-09-24 stsp
703 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
704 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
705 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
706 49c543a6 2022-03-31 naddy ret=$?
707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
708 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
709 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
710 f259c4c1 2021-09-24 stsp return 1
711 f259c4c1 2021-09-24 stsp fi
712 f259c4c1 2021-09-24 stsp
713 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
714 f259c4c1 2021-09-24 stsp
715 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
716 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
717 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
718 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
719 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
720 49c543a6 2022-03-31 naddy ret=$?
721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
722 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
724 f259c4c1 2021-09-24 stsp return 1
725 f259c4c1 2021-09-24 stsp fi
726 f259c4c1 2021-09-24 stsp
727 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
728 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
729 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
730 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
731 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
732 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
733 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
734 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
735 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
736 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
737 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
738 49c543a6 2022-03-31 naddy ret=$?
739 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
740 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
741 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
742 f259c4c1 2021-09-24 stsp return 1
743 f259c4c1 2021-09-24 stsp fi
744 f259c4c1 2021-09-24 stsp
745 f259c4c1 2021-09-24 stsp # resolve the conflict
746 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
747 f259c4c1 2021-09-24 stsp
748 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
749 49c543a6 2022-03-31 naddy ret=$?
750 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
751 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
752 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
753 f259c4c1 2021-09-24 stsp return 1
754 f259c4c1 2021-09-24 stsp fi
755 f259c4c1 2021-09-24 stsp
756 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
757 f259c4c1 2021-09-24 stsp
758 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
759 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
760 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
761 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
762 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
763 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
764 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
765 f259c4c1 2021-09-24 stsp
766 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
767 49c543a6 2022-03-31 naddy ret=$?
768 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
769 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
771 f259c4c1 2021-09-24 stsp return 1
772 f259c4c1 2021-09-24 stsp fi
773 f259c4c1 2021-09-24 stsp
774 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
775 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
776 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
777 49c543a6 2022-03-31 naddy ret=$?
778 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
779 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
780 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
781 f259c4c1 2021-09-24 stsp return 1
782 f259c4c1 2021-09-24 stsp fi
783 f259c4c1 2021-09-24 stsp
784 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
785 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
786 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
787 49c543a6 2022-03-31 naddy ret=$?
788 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
789 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
790 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
791 f259c4c1 2021-09-24 stsp return 1
792 f259c4c1 2021-09-24 stsp fi
793 f259c4c1 2021-09-24 stsp
794 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
795 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
796 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
797 f259c4c1 2021-09-24 stsp return 1
798 f259c4c1 2021-09-24 stsp fi
799 f259c4c1 2021-09-24 stsp
800 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
801 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
802 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
803 49c543a6 2022-03-31 naddy ret=$?
804 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
805 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
806 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
807 f259c4c1 2021-09-24 stsp return 1
808 f259c4c1 2021-09-24 stsp fi
809 f259c4c1 2021-09-24 stsp
810 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
811 f259c4c1 2021-09-24 stsp
812 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
813 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
814 49c543a6 2022-03-31 naddy ret=$?
815 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
816 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
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 f259c4c1 2021-09-24 stsp
821 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
822 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
823 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
824 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
825 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
826 49c543a6 2022-03-31 naddy ret=$?
827 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
828 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
829 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
830 f259c4c1 2021-09-24 stsp return 1
831 f259c4c1 2021-09-24 stsp fi
832 f259c4c1 2021-09-24 stsp
833 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
834 f259c4c1 2021-09-24 stsp
835 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
836 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
837 49c543a6 2022-03-31 naddy ret=$?
838 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
839 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
840 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
841 f259c4c1 2021-09-24 stsp return 1
842 f259c4c1 2021-09-24 stsp fi
843 f259c4c1 2021-09-24 stsp
844 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
845 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
846 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
847 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
848 6b5246e4 2023-06-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 6b5246e4 2023-06-05 stsp ret=$?
850 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
851 6b5246e4 2023-06-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 6b5246e4 2023-06-05 stsp fi
853 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
854 6b5246e4 2023-06-05 stsp }
855 6b5246e4 2023-06-05 stsp
856 6b5246e4 2023-06-05 stsp test_merge_continue_new_commit() {
857 6b5246e4 2023-06-05 stsp # "got merge -c" should refuse to run if the current branch tip has
858 6b5246e4 2023-06-05 stsp # changed since the merge was started, to avoid clobbering the changes.
859 6b5246e4 2023-06-05 stsp local testroot=`test_init merge_continue_new_commit`
860 6b5246e4 2023-06-05 stsp
861 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q -b newbranch)
862 6b5246e4 2023-06-05 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
863 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
864 6b5246e4 2023-06-05 stsp
865 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q master)
866 6b5246e4 2023-06-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
867 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master"
868 6b5246e4 2023-06-05 stsp
869 6b5246e4 2023-06-05 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
870 6b5246e4 2023-06-05 stsp ret=$?
871 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
872 6b5246e4 2023-06-05 stsp echo "got checkout failed unexpectedly" >&2
873 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
874 6b5246e4 2023-06-05 stsp return 1
875 6b5246e4 2023-06-05 stsp fi
876 6b5246e4 2023-06-05 stsp
877 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -n newbranch >/dev/null)
878 6b5246e4 2023-06-05 stsp ret=$?
879 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
880 6b5246e4 2023-06-05 stsp echo "got merge failed unexpectedly" >&2
881 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
882 6b5246e4 2023-06-05 stsp return 1
883 6b5246e4 2023-06-05 stsp fi
884 6b5246e4 2023-06-05 stsp
885 6b5246e4 2023-06-05 stsp echo "modified alpha again on master" > $testroot/repo/alpha
886 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master again"
887 6b5246e4 2023-06-05 stsp
888 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
889 6b5246e4 2023-06-05 stsp ret=$?
890 6b5246e4 2023-06-05 stsp if [ $ret -eq 0 ]; then
891 6b5246e4 2023-06-05 stsp echo "got merge succeeded unexpectedly" >&2
892 6b5246e4 2023-06-05 stsp test_done "$testroot" "1"
893 6b5246e4 2023-06-05 stsp return 1
894 6b5246e4 2023-06-05 stsp fi
895 6b5246e4 2023-06-05 stsp
896 6b5246e4 2023-06-05 stsp echo -n > $testroot/stdout.expected
897 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
898 49c543a6 2022-03-31 naddy ret=$?
899 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
900 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
901 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
902 6b5246e4 2023-06-05 stsp return 1
903 6b5246e4 2023-06-05 stsp fi
904 6b5246e4 2023-06-05 stsp
905 6b5246e4 2023-06-05 stsp echo -n "got: merging cannot proceed because the work tree is no " \
906 6b5246e4 2023-06-05 stsp > $testroot/stderr.expected
907 6b5246e4 2023-06-05 stsp echo "longer up-to-date; merge must be aborted and retried" \
908 6b5246e4 2023-06-05 stsp >> $testroot/stderr.expected
909 6b5246e4 2023-06-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
910 6b5246e4 2023-06-05 stsp ret=$?
911 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
912 6b5246e4 2023-06-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
913 f259c4c1 2021-09-24 stsp fi
914 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
915 f259c4c1 2021-09-24 stsp }
916 f259c4c1 2021-09-24 stsp
917 f259c4c1 2021-09-24 stsp test_merge_abort() {
918 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
919 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
920 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
921 f259c4c1 2021-09-24 stsp
922 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
923 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
924 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
925 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
926 f259c4c1 2021-09-24 stsp
927 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
928 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
929 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
930 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
931 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
932 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
933 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
934 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
935 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
936 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
937 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
938 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
939 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
940 f259c4c1 2021-09-24 stsp
941 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
942 49c543a6 2022-03-31 naddy ret=$?
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
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 41f061b2 2021-10-05 stsp
949 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
950 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
951 f259c4c1 2021-09-24 stsp
952 f259c4c1 2021-09-24 stsp # create a conflicting commit
953 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
954 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
955 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
956 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
957 f259c4c1 2021-09-24 stsp
958 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
959 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
960 49c543a6 2022-03-31 naddy ret=$?
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
963 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
964 f259c4c1 2021-09-24 stsp return 1
965 f259c4c1 2021-09-24 stsp fi
966 f259c4c1 2021-09-24 stsp
967 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
968 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
969 49c543a6 2022-03-31 naddy ret=$?
970 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
971 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
972 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
973 f259c4c1 2021-09-24 stsp return 1
974 f259c4c1 2021-09-24 stsp fi
975 f259c4c1 2021-09-24 stsp
976 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
977 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
978 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
979 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
980 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
981 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
982 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
983 49c543a6 2022-03-31 naddy ret=$?
984 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
985 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
986 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
987 f259c4c1 2021-09-24 stsp return 1
988 f259c4c1 2021-09-24 stsp fi
989 f259c4c1 2021-09-24 stsp
990 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
991 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
992 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
993 49c543a6 2022-03-31 naddy ret=$?
994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
995 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
996 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
997 f259c4c1 2021-09-24 stsp return 1
998 f259c4c1 2021-09-24 stsp fi
999 af179be7 2023-04-14 stsp
1000 af179be7 2023-04-14 stsp # unrelated added file added during conflict resolution
1001 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
1002 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
1003 f259c4c1 2021-09-24 stsp
1004 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1005 f259c4c1 2021-09-24 stsp
1006 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
1007 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
1008 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
1009 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1010 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
1011 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
1012 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
1013 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1014 49c543a6 2022-03-31 naddy ret=$?
1015 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1016 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1017 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1018 f259c4c1 2021-09-24 stsp return 1
1019 f259c4c1 2021-09-24 stsp fi
1020 f259c4c1 2021-09-24 stsp
1021 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
1022 49c543a6 2022-03-31 naddy ret=$?
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
1025 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1026 f259c4c1 2021-09-24 stsp return 1
1027 f259c4c1 2021-09-24 stsp fi
1028 f259c4c1 2021-09-24 stsp
1029 af179be7 2023-04-14 stsp echo "R added-file" > $testroot/stdout.expected
1030 af179be7 2023-04-14 stsp echo "R alpha" >> $testroot/stdout.expected
1031 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
1032 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
1033 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
1034 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
1035 af179be7 2023-04-14 stsp echo "G added-file" >> $testroot/stdout.expected
1036 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
1037 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
1038 f259c4c1 2021-09-24 stsp
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 "delta" > $testroot/content.expected
1048 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
1049 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
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/content.expected $testroot/content
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 echo "modified alpha on master" > $testroot/content.expected
1058 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
1059 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
1060 49c543a6 2022-03-31 naddy ret=$?
1061 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1062 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
1063 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1064 f259c4c1 2021-09-24 stsp return 1
1065 f259c4c1 2021-09-24 stsp fi
1066 f259c4c1 2021-09-24 stsp
1067 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
1068 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
1069 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
1070 49c543a6 2022-03-31 naddy ret=$?
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
1073 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1074 f259c4c1 2021-09-24 stsp return 1
1075 f259c4c1 2021-09-24 stsp fi
1076 f259c4c1 2021-09-24 stsp
1077 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
1078 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
1079 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1080 f259c4c1 2021-09-24 stsp return 1
1081 f259c4c1 2021-09-24 stsp fi
1082 f259c4c1 2021-09-24 stsp
1083 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
1084 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
1085 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1086 f259c4c1 2021-09-24 stsp return 1
1087 f259c4c1 2021-09-24 stsp fi
1088 f259c4c1 2021-09-24 stsp
1089 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1090 f259c4c1 2021-09-24 stsp
1091 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
1092 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
1093 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1094 49c543a6 2022-03-31 naddy ret=$?
1095 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1096 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1097 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1098 f259c4c1 2021-09-24 stsp return 1
1099 f259c4c1 2021-09-24 stsp fi
1100 f259c4c1 2021-09-24 stsp
1101 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1102 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
1103 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
1104 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1105 49c543a6 2022-03-31 naddy ret=$?
1106 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1107 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1108 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1109 f259c4c1 2021-09-24 stsp return 1
1110 f259c4c1 2021-09-24 stsp fi
1111 f259c4c1 2021-09-24 stsp
1112 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
1113 f259c4c1 2021-09-24 stsp
1114 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1115 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1116 49c543a6 2022-03-31 naddy ret=$?
1117 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1118 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1119 f259c4c1 2021-09-24 stsp fi
1120 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1121 f259c4c1 2021-09-24 stsp }
1122 f259c4c1 2021-09-24 stsp
1123 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
1124 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
1125 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1126 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1127 f259c4c1 2021-09-24 stsp
1128 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1129 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1130 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1131 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1132 f259c4c1 2021-09-24 stsp
1133 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1134 49c543a6 2022-03-31 naddy ret=$?
1135 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1136 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1137 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1138 f259c4c1 2021-09-24 stsp return 1
1139 f259c4c1 2021-09-24 stsp fi
1140 f259c4c1 2021-09-24 stsp
1141 f259c4c1 2021-09-24 stsp # create a conflicting commit
1142 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1143 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1144 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1145 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1146 f259c4c1 2021-09-24 stsp
1147 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1148 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1149 49c543a6 2022-03-31 naddy ret=$?
1150 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1151 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1152 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1153 f259c4c1 2021-09-24 stsp return 1
1154 f259c4c1 2021-09-24 stsp fi
1155 f259c4c1 2021-09-24 stsp
1156 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1157 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1158 49c543a6 2022-03-31 naddy ret=$?
1159 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1160 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1161 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1162 f259c4c1 2021-09-24 stsp return 1
1163 f259c4c1 2021-09-24 stsp fi
1164 f259c4c1 2021-09-24 stsp
1165 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1166 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1167 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1168 49c543a6 2022-03-31 naddy ret=$?
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1170 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1171 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1172 f259c4c1 2021-09-24 stsp return 1
1173 f259c4c1 2021-09-24 stsp fi
1174 f259c4c1 2021-09-24 stsp
1175 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1176 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1177 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1178 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1181 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1182 f259c4c1 2021-09-24 stsp return 1
1183 f259c4c1 2021-09-24 stsp fi
1184 f259c4c1 2021-09-24 stsp
1185 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1186 f259c4c1 2021-09-24 stsp
1187 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1188 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1189 49c543a6 2022-03-31 naddy ret=$?
1190 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1191 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1192 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1193 f259c4c1 2021-09-24 stsp return 1
1194 f259c4c1 2021-09-24 stsp fi
1195 f259c4c1 2021-09-24 stsp
1196 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
1197 42761529 2023-06-01 stsp "integrate newbranch" "merge newbranch" "stage alpha"; do
1198 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
1199 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
1200 42761529 2023-06-01 stsp ret=$?
1201 42761529 2023-06-01 stsp if [ $ret -eq 0 ]; then
1202 42761529 2023-06-01 stsp echo "got $cmd succeeded unexpectedly" >&2
1203 42761529 2023-06-01 stsp test_done "$testroot" "1"
1204 42761529 2023-06-01 stsp return 1
1205 42761529 2023-06-01 stsp fi
1206 f259c4c1 2021-09-24 stsp
1207 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
1208 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1209 49c543a6 2022-03-31 naddy ret=$?
1210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1211 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1212 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1213 f259c4c1 2021-09-24 stsp return 1
1214 f259c4c1 2021-09-24 stsp fi
1215 f259c4c1 2021-09-24 stsp
1216 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
1217 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1218 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
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 done
1228 f259c4c1 2021-09-24 stsp
1229 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1230 f259c4c1 2021-09-24 stsp }
1231 f259c4c1 2021-09-24 stsp
1232 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
1233 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
1234 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1235 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1236 f259c4c1 2021-09-24 stsp
1237 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1238 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1239 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1240 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1241 f259c4c1 2021-09-24 stsp
1242 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1243 f259c4c1 2021-09-24 stsp > /dev/null
1244 49c543a6 2022-03-31 naddy ret=$?
1245 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1246 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1247 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1248 f259c4c1 2021-09-24 stsp return 1
1249 f259c4c1 2021-09-24 stsp fi
1250 f259c4c1 2021-09-24 stsp
1251 f259c4c1 2021-09-24 stsp # create a conflicting commit
1252 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1253 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1254 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1255 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1256 f259c4c1 2021-09-24 stsp
1257 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1258 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1259 49c543a6 2022-03-31 naddy ret=$?
1260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1261 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1262 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1263 f259c4c1 2021-09-24 stsp return 1
1264 f259c4c1 2021-09-24 stsp fi
1265 f259c4c1 2021-09-24 stsp
1266 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1267 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1268 49c543a6 2022-03-31 naddy ret=$?
1269 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1270 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1271 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1272 f259c4c1 2021-09-24 stsp return 1
1273 f259c4c1 2021-09-24 stsp fi
1274 f259c4c1 2021-09-24 stsp
1275 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
1276 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1277 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
1278 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1279 49c543a6 2022-03-31 naddy ret=$?
1280 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1281 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1282 f259c4c1 2021-09-24 stsp fi
1283 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1284 f259c4c1 2021-09-24 stsp }
1285 f259c4c1 2021-09-24 stsp
1286 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
1287 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
1288 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1289 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1290 f259c4c1 2021-09-24 stsp
1291 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1292 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1293 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1294 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
1295 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1296 f259c4c1 2021-09-24 stsp
1297 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1298 49c543a6 2022-03-31 naddy ret=$?
1299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1300 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1301 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1302 f259c4c1 2021-09-24 stsp return 1
1303 f259c4c1 2021-09-24 stsp fi
1304 f259c4c1 2021-09-24 stsp
1305 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
1306 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1307 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1308 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
1309 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1310 f259c4c1 2021-09-24 stsp
1311 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1312 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1313 49c543a6 2022-03-31 naddy ret=$?
1314 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1315 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1316 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1317 f259c4c1 2021-09-24 stsp return 1
1318 f259c4c1 2021-09-24 stsp fi
1319 f259c4c1 2021-09-24 stsp
1320 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1321 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1322 49c543a6 2022-03-31 naddy ret=$?
1323 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1324 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1325 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1326 f259c4c1 2021-09-24 stsp return 1
1327 f259c4c1 2021-09-24 stsp fi
1328 f259c4c1 2021-09-24 stsp
1329 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
1330 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1331 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1332 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1333 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1334 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1335 49c543a6 2022-03-31 naddy ret=$?
1336 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1337 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1338 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1339 f259c4c1 2021-09-24 stsp return 1
1340 f259c4c1 2021-09-24 stsp fi
1341 f259c4c1 2021-09-24 stsp
1342 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1343 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1344 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1345 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1346 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1347 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1348 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1349 49c543a6 2022-03-31 naddy ret=$?
1350 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1351 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1352 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1353 f259c4c1 2021-09-24 stsp return 1
1354 f259c4c1 2021-09-24 stsp fi
1355 f259c4c1 2021-09-24 stsp
1356 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1357 f259c4c1 2021-09-24 stsp
1358 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1359 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1360 49c543a6 2022-03-31 naddy ret=$?
1361 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1362 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1363 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1364 a6a8f8bb 2021-09-24 stsp return 1
1365 a6a8f8bb 2021-09-24 stsp fi
1366 a6a8f8bb 2021-09-24 stsp
1367 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1368 a6a8f8bb 2021-09-24 stsp }
1369 a6a8f8bb 2021-09-24 stsp
1370 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1371 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1372 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1373 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1374 a6a8f8bb 2021-09-24 stsp
1375 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1376 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1377 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1378 35d2583f 2023-04-17 stsp local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1379 a6a8f8bb 2021-09-24 stsp
1380 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1381 49c543a6 2022-03-31 naddy ret=$?
1382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1383 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1384 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1385 a6a8f8bb 2021-09-24 stsp return 1
1386 a6a8f8bb 2021-09-24 stsp fi
1387 a6a8f8bb 2021-09-24 stsp
1388 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1389 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1390 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1391 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1392 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1393 a6a8f8bb 2021-09-24 stsp
1394 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1395 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1396 49c543a6 2022-03-31 naddy ret=$?
1397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1398 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1399 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1400 a6a8f8bb 2021-09-24 stsp return 1
1401 a6a8f8bb 2021-09-24 stsp fi
1402 a6a8f8bb 2021-09-24 stsp
1403 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1404 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1405 49c543a6 2022-03-31 naddy ret=$?
1406 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1407 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1408 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1409 a6a8f8bb 2021-09-24 stsp return 1
1410 a6a8f8bb 2021-09-24 stsp fi
1411 a6a8f8bb 2021-09-24 stsp
1412 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1413 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1414 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1415 49c543a6 2022-03-31 naddy ret=$?
1416 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1417 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1418 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1419 a6a8f8bb 2021-09-24 stsp return 1
1420 a6a8f8bb 2021-09-24 stsp fi
1421 a6a8f8bb 2021-09-24 stsp
1422 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1423 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1424 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1425 49c543a6 2022-03-31 naddy ret=$?
1426 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1427 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1428 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1429 a6a8f8bb 2021-09-24 stsp return 1
1430 a6a8f8bb 2021-09-24 stsp fi
1431 a6a8f8bb 2021-09-24 stsp
1432 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1433 a6a8f8bb 2021-09-24 stsp
1434 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1435 f259c4c1 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 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1440 f259c4c1 2021-09-24 stsp return 1
1441 f259c4c1 2021-09-24 stsp fi
1442 f259c4c1 2021-09-24 stsp
1443 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1444 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1445 49c543a6 2022-03-31 naddy ret=$?
1446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1447 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1448 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1449 a6a8f8bb 2021-09-24 stsp return 1
1450 a6a8f8bb 2021-09-24 stsp fi
1451 a6a8f8bb 2021-09-24 stsp
1452 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1453 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1454 49c543a6 2022-03-31 naddy ret=$?
1455 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1456 35d2583f 2023-04-17 stsp echo "got merge failed unexpectedly" >&2
1457 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1458 a6a8f8bb 2021-09-24 stsp return 1
1459 a6a8f8bb 2021-09-24 stsp fi
1460 a6a8f8bb 2021-09-24 stsp
1461 35d2583f 2023-04-17 stsp echo -n '' > $testroot/stderr.expected
1462 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1463 49c543a6 2022-03-31 naddy ret=$?
1464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1465 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1466 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1467 35d2583f 2023-04-17 stsp return 1
1468 35d2583f 2023-04-17 stsp fi
1469 35d2583f 2023-04-17 stsp
1470 35d2583f 2023-04-17 stsp local merge_commit=`git_show_head $testroot/repo`
1471 35d2583f 2023-04-17 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1472 35d2583f 2023-04-17 stsp > $testroot/stdout.expected
1473 35d2583f 2023-04-17 stsp echo $merge_commit >> $testroot/stdout.expected
1474 35d2583f 2023-04-17 stsp
1475 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1476 35d2583f 2023-04-17 stsp ret=$?
1477 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1478 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1479 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1480 a6a8f8bb 2021-09-24 stsp return 1
1481 a6a8f8bb 2021-09-24 stsp fi
1482 a6a8f8bb 2021-09-24 stsp
1483 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1484 a6a8f8bb 2021-09-24 stsp
1485 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1486 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1487 49c543a6 2022-03-31 naddy ret=$?
1488 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1489 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1490 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1491 35d2583f 2023-04-17 stsp return 1
1492 4e91ef15 2021-09-26 stsp fi
1493 35d2583f 2023-04-17 stsp
1494 35d2583f 2023-04-17 stsp # We should have created a merge commit with two parents.
1495 35d2583f 2023-04-17 stsp got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1496 35d2583f 2023-04-17 stsp > $testroot/stdout
1497 35d2583f 2023-04-17 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1498 35d2583f 2023-04-17 stsp echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1499 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1500 35d2583f 2023-04-17 stsp ret=$?
1501 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1502 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1503 35d2583f 2023-04-17 stsp fi
1504 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1505 4e91ef15 2021-09-26 stsp }
1506 4e91ef15 2021-09-26 stsp
1507 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1508 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1509 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1510 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1511 4e91ef15 2021-09-26 stsp
1512 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1513 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1514 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1515 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1516 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1517 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1518 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1519 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1520 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1521 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1522 4e91ef15 2021-09-26 stsp
1523 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1524 49c543a6 2022-03-31 naddy ret=$?
1525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1526 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1527 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1528 4e91ef15 2021-09-26 stsp return 1
1529 4e91ef15 2021-09-26 stsp fi
1530 4e91ef15 2021-09-26 stsp
1531 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1532 49c543a6 2022-03-31 naddy ret=$?
1533 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1534 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1535 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1536 4e91ef15 2021-09-26 stsp return 1
1537 4e91ef15 2021-09-26 stsp fi
1538 4e91ef15 2021-09-26 stsp
1539 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1540 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1541 4e91ef15 2021-09-26 stsp A be/lots/of
1542 4e91ef15 2021-09-26 stsp A files/here
1543 4e91ef15 2021-09-26 stsp A there/should
1544 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1545 4e91ef15 2021-09-26 stsp EOF
1546 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1547 49c543a6 2022-03-31 naddy ret=$?
1548 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1549 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1550 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1551 4e91ef15 2021-09-26 stsp return 1
1552 4e91ef15 2021-09-26 stsp fi
1553 4e91ef15 2021-09-26 stsp
1554 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1555 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1556 49c543a6 2022-03-31 naddy ret=$?
1557 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1558 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1559 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1560 4e91ef15 2021-09-26 stsp return 1
1561 4e91ef15 2021-09-26 stsp fi
1562 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1563 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1564 49c543a6 2022-03-31 naddy ret=$?
1565 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1566 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1567 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1568 4e91ef15 2021-09-26 stsp return 1
1569 a6a8f8bb 2021-09-24 stsp fi
1570 4e91ef15 2021-09-26 stsp
1571 4e91ef15 2021-09-26 stsp # update the 'files' branch
1572 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1573 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1574 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1575 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1576 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1577 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1578 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1579 4e91ef15 2021-09-26 stsp
1580 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1581 49c543a6 2022-03-31 naddy ret=$?
1582 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1583 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1584 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1585 4e91ef15 2021-09-26 stsp return 1
1586 4e91ef15 2021-09-26 stsp fi
1587 4e91ef15 2021-09-26 stsp
1588 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1589 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1590 49c543a6 2022-03-31 naddy ret=$?
1591 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1592 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1593 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1594 4e91ef15 2021-09-26 stsp return 1
1595 4e91ef15 2021-09-26 stsp fi
1596 4e91ef15 2021-09-26 stsp
1597 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1598 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1599 4e91ef15 2021-09-26 stsp G be/lots/of
1600 4e91ef15 2021-09-26 stsp A indeed
1601 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1602 4e91ef15 2021-09-26 stsp EOF
1603 4e91ef15 2021-09-26 stsp
1604 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1605 49c543a6 2022-03-31 naddy ret=$?
1606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1607 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1608 4e91ef15 2021-09-26 stsp fi
1609 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1610 f259c4c1 2021-09-24 stsp }
1611 088449d3 2021-09-26 stsp
1612 088449d3 2021-09-26 stsp test_merge_interrupt() {
1613 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1614 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1615 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1616 088449d3 2021-09-26 stsp
1617 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1618 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1619 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1620 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1621 088449d3 2021-09-26 stsp
1622 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1623 49c543a6 2022-03-31 naddy ret=$?
1624 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1625 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1626 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1627 088449d3 2021-09-26 stsp return 1
1628 088449d3 2021-09-26 stsp fi
1629 088449d3 2021-09-26 stsp
1630 088449d3 2021-09-26 stsp # create a non-conflicting commit
1631 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1632 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1633 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1634 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1635 f259c4c1 2021-09-24 stsp
1636 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1637 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1638 49c543a6 2022-03-31 naddy ret=$?
1639 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1640 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1641 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1642 088449d3 2021-09-26 stsp return 1
1643 088449d3 2021-09-26 stsp fi
1644 088449d3 2021-09-26 stsp
1645 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1646 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1647 49c543a6 2022-03-31 naddy ret=$?
1648 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1649 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1650 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1651 088449d3 2021-09-26 stsp return 1
1652 088449d3 2021-09-26 stsp fi
1653 088449d3 2021-09-26 stsp
1654 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1655 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1656 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1657 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1658 49c543a6 2022-03-31 naddy ret=$?
1659 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1660 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1661 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1662 088449d3 2021-09-26 stsp return 1
1663 088449d3 2021-09-26 stsp fi
1664 088449d3 2021-09-26 stsp
1665 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1666 088449d3 2021-09-26 stsp
1667 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1668 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1669 49c543a6 2022-03-31 naddy ret=$?
1670 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1671 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1672 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1673 088449d3 2021-09-26 stsp return 1
1674 088449d3 2021-09-26 stsp fi
1675 088449d3 2021-09-26 stsp
1676 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1677 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1678 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1679 49c543a6 2022-03-31 naddy ret=$?
1680 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1681 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1682 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1683 088449d3 2021-09-26 stsp return 1
1684 088449d3 2021-09-26 stsp fi
1685 088449d3 2021-09-26 stsp
1686 088449d3 2021-09-26 stsp # adjust merge result
1687 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1688 088449d3 2021-09-26 stsp
1689 088449d3 2021-09-26 stsp # continue the merge
1690 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1691 49c543a6 2022-03-31 naddy ret=$?
1692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1693 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1694 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1695 088449d3 2021-09-26 stsp return 1
1696 088449d3 2021-09-26 stsp fi
1697 088449d3 2021-09-26 stsp
1698 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1699 088449d3 2021-09-26 stsp
1700 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1701 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1702 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1703 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1704 088449d3 2021-09-26 stsp
1705 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1706 49c543a6 2022-03-31 naddy ret=$?
1707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1708 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1709 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1710 088449d3 2021-09-26 stsp return 1
1711 088449d3 2021-09-26 stsp fi
1712 088449d3 2021-09-26 stsp
1713 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1714 088449d3 2021-09-26 stsp
1715 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1716 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1717 49c543a6 2022-03-31 naddy ret=$?
1718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1719 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1720 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1721 088449d3 2021-09-26 stsp return 1
1722 088449d3 2021-09-26 stsp fi
1723 088449d3 2021-09-26 stsp
1724 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1725 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1726 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1727 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1728 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1729 49c543a6 2022-03-31 naddy ret=$?
1730 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1731 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1732 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1733 088449d3 2021-09-26 stsp return 1
1734 088449d3 2021-09-26 stsp fi
1735 088449d3 2021-09-26 stsp
1736 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1737 088449d3 2021-09-26 stsp
1738 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1739 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1740 49c543a6 2022-03-31 naddy ret=$?
1741 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1742 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1743 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1744 088449d3 2021-09-26 stsp return 1
1745 088449d3 2021-09-26 stsp fi
1746 088449d3 2021-09-26 stsp
1747 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1748 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1749 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1750 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1751 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1752 49c543a6 2022-03-31 naddy ret=$?
1753 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1754 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1755 088449d3 2021-09-26 stsp fi
1756 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1757 b2b3fce1 2022-10-29 op }
1758 b2b3fce1 2022-10-29 op
1759 b2b3fce1 2022-10-29 op test_merge_umask() {
1760 b2b3fce1 2022-10-29 op local testroot=`test_init merge_umask`
1761 b2b3fce1 2022-10-29 op
1762 b2b3fce1 2022-10-29 op (cd $testroot/repo && git checkout -q -b newbranch)
1763 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/repo/alpha
1764 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1765 b2b3fce1 2022-10-29 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1766 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1767 b2b3fce1 2022-10-29 op
1768 b2b3fce1 2022-10-29 op # diverge from newbranch
1769 b2b3fce1 2022-10-29 op (cd "$testroot/repo" && git checkout -q master)
1770 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/repo/beta
1771 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing zeto no master"
1772 b2b3fce1 2022-10-29 op
1773 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1774 b2b3fce1 2022-10-29 op
1775 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1776 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1777 b2b3fce1 2022-10-29 op
1778 b2b3fce1 2022-10-29 op for f in alpha gamma/delta; do
1779 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1780 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1781 b2b3fce1 2022-10-29 op echo "$f is not 0600 after merge" >&2
1782 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
1783 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1784 b2b3fce1 2022-10-29 op fi
1785 b2b3fce1 2022-10-29 op done
1786 b2b3fce1 2022-10-29 op
1787 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1788 088449d3 2021-09-26 stsp }
1789 d51d11be 2023-02-21 op
1790 d51d11be 2023-02-21 op test_merge_gitconfig_author() {
1791 d51d11be 2023-02-21 op local testroot=`test_init merge_gitconfig_author`
1792 d51d11be 2023-02-21 op
1793 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.name 'Flan Luck')
1794 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1795 d51d11be 2023-02-21 op
1796 d51d11be 2023-02-21 op (cd $testroot/repo && git checkout -q -b newbranch)
1797 d51d11be 2023-02-21 op echo "modified alpha on branch" >$testroot/repo/alpha
1798 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1799 d51d11be 2023-02-21 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1800 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1801 088449d3 2021-09-26 stsp
1802 d51d11be 2023-02-21 op # diverge from newbranch
1803 d51d11be 2023-02-21 op (cd "$testroot/repo" && git checkout -q master)
1804 d51d11be 2023-02-21 op echo "modified beta on master" >$testroot/repo/beta
1805 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing zeto no master"
1806 d51d11be 2023-02-21 op
1807 d51d11be 2023-02-21 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1808 d51d11be 2023-02-21 op
1809 d51d11be 2023-02-21 op # unset in a subshell to avoid affecting our environment
1810 d51d11be 2023-02-21 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1811 d51d11be 2023-02-21 op got merge newbranch > /dev/null)
1812 d51d11be 2023-02-21 op
1813 d51d11be 2023-02-21 op (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1814 d51d11be 2023-02-21 op ret=$?
1815 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1816 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1817 d51d11be 2023-02-21 op return 1
1818 d51d11be 2023-02-21 op fi
1819 d51d11be 2023-02-21 op
1820 d51d11be 2023-02-21 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1821 d51d11be 2023-02-21 op > $testroot/stdout.expected
1822 d51d11be 2023-02-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1823 d51d11be 2023-02-21 op ret=$?
1824 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1825 d51d11be 2023-02-21 op diff -u $testroot/stdout.expected $testroot/stdout
1826 d51d11be 2023-02-21 op fi
1827 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1828 d51d11be 2023-02-21 op }
1829 13342307 2023-06-21 stsp
1830 13342307 2023-06-21 stsp test_merge_fetched_branch() {
1831 13342307 2023-06-21 stsp local testroot=`test_init merge_fetched_branch`
1832 13342307 2023-06-21 stsp local testurl=ssh://127.0.0.1/$testroot
1833 13342307 2023-06-21 stsp local commit_id=`git_show_head $testroot/repo`
1834 13342307 2023-06-21 stsp
1835 13342307 2023-06-21 stsp got clone -q $testurl/repo $testroot/repo-clone
1836 13342307 2023-06-21 stsp ret=$?
1837 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1838 13342307 2023-06-21 stsp echo "got clone command failed unexpectedly" >&2
1839 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1840 13342307 2023-06-21 stsp return 1
1841 13342307 2023-06-21 stsp fi
1842 d51d11be 2023-02-21 op
1843 13342307 2023-06-21 stsp echo "modified alpha" > $testroot/repo/alpha
1844 13342307 2023-06-21 stsp git_commit $testroot/repo -m "modified alpha"
1845 13342307 2023-06-21 stsp local commit_id2=`git_show_head $testroot/repo`
1846 13342307 2023-06-21 stsp
1847 13342307 2023-06-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout
1848 13342307 2023-06-21 stsp ret=$?
1849 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1850 13342307 2023-06-21 stsp echo "got fetch command failed unexpectedly" >&2
1851 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1852 13342307 2023-06-21 stsp return 1
1853 13342307 2023-06-21 stsp fi
1854 13342307 2023-06-21 stsp
1855 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1856 13342307 2023-06-21 stsp
1857 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1858 13342307 2023-06-21 stsp ret=$?
1859 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1860 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1861 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1862 13342307 2023-06-21 stsp return 1
1863 13342307 2023-06-21 stsp fi
1864 13342307 2023-06-21 stsp
1865 13342307 2023-06-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1866 13342307 2023-06-21 stsp
1867 13342307 2023-06-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1868 13342307 2023-06-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1869 13342307 2023-06-21 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1870 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1871 13342307 2023-06-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
1872 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1873 13342307 2023-06-21 stsp
1874 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1875 13342307 2023-06-21 stsp ret=$?
1876 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1877 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1878 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1879 13342307 2023-06-21 stsp return 1
1880 13342307 2023-06-21 stsp fi
1881 13342307 2023-06-21 stsp
1882 13342307 2023-06-21 stsp got checkout $testroot/repo-clone $testroot/wt > /dev/null
1883 13342307 2023-06-21 stsp
1884 13342307 2023-06-21 stsp echo "modified beta" > $testroot/wt/beta
1885 13342307 2023-06-21 stsp (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1886 13342307 2023-06-21 stsp local commit_id3=`git_show_head $testroot/repo-clone`
1887 13342307 2023-06-21 stsp
1888 13342307 2023-06-21 stsp (cd $testroot/wt && got update > /dev/null)
1889 13342307 2023-06-21 stsp (cd $testroot/wt && got merge origin/master > $testroot/stdout)
1890 13342307 2023-06-21 stsp local merge_commit_id=`git_show_head $testroot/repo-clone`
1891 13342307 2023-06-21 stsp
1892 13342307 2023-06-21 stsp cat > $testroot/stdout.expected <<EOF
1893 13342307 2023-06-21 stsp G alpha
1894 13342307 2023-06-21 stsp Merged refs/remotes/origin/master into refs/heads/master: $merge_commit_id
1895 13342307 2023-06-21 stsp EOF
1896 13342307 2023-06-21 stsp
1897 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1898 13342307 2023-06-21 stsp ret=$?
1899 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1900 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1901 13342307 2023-06-21 stsp fi
1902 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1903 13342307 2023-06-21 stsp }
1904 13342307 2023-06-21 stsp
1905 13342307 2023-06-21 stsp test_merge_fetched_branch_remote() {
1906 13342307 2023-06-21 stsp local testroot=`test_init merge_fetched_branch_remote`
1907 13342307 2023-06-21 stsp local testurl=ssh://127.0.0.1/$testroot
1908 13342307 2023-06-21 stsp local commit_id=`git_show_head $testroot/repo`
1909 13342307 2023-06-21 stsp
1910 13342307 2023-06-21 stsp got clone -q $testurl/repo $testroot/repo-clone
1911 13342307 2023-06-21 stsp ret=$?
1912 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1913 13342307 2023-06-21 stsp echo "got clone command failed unexpectedly" >&2
1914 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1915 13342307 2023-06-21 stsp return 1
1916 13342307 2023-06-21 stsp fi
1917 13342307 2023-06-21 stsp
1918 13342307 2023-06-21 stsp echo "modified alpha" > $testroot/repo/alpha
1919 13342307 2023-06-21 stsp git_commit $testroot/repo -m "modified alpha"
1920 13342307 2023-06-21 stsp local commit_id2=`git_show_head $testroot/repo`
1921 13342307 2023-06-21 stsp
1922 13342307 2023-06-21 stsp got fetch -q -r $testroot/repo-clone > $testroot/stdout
1923 13342307 2023-06-21 stsp ret=$?
1924 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1925 13342307 2023-06-21 stsp echo "got fetch command failed unexpectedly" >&2
1926 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1927 13342307 2023-06-21 stsp return 1
1928 13342307 2023-06-21 stsp fi
1929 13342307 2023-06-21 stsp
1930 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1931 13342307 2023-06-21 stsp
1932 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1933 13342307 2023-06-21 stsp ret=$?
1934 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1935 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1936 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1937 13342307 2023-06-21 stsp return 1
1938 13342307 2023-06-21 stsp fi
1939 13342307 2023-06-21 stsp
1940 13342307 2023-06-21 stsp got ref -l -r $testroot/repo-clone > $testroot/stdout
1941 13342307 2023-06-21 stsp
1942 13342307 2023-06-21 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
1943 13342307 2023-06-21 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
1944 13342307 2023-06-21 stsp echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
1945 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1946 13342307 2023-06-21 stsp echo "refs/remotes/origin/master: $commit_id2" \
1947 13342307 2023-06-21 stsp >> $testroot/stdout.expected
1948 13342307 2023-06-21 stsp
1949 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1950 13342307 2023-06-21 stsp ret=$?
1951 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1952 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1953 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1954 13342307 2023-06-21 stsp return 1
1955 13342307 2023-06-21 stsp fi
1956 13342307 2023-06-21 stsp
1957 13342307 2023-06-21 stsp got checkout $testroot/repo-clone $testroot/wt > /dev/null
1958 13342307 2023-06-21 stsp
1959 13342307 2023-06-21 stsp echo "modified beta" > $testroot/wt/beta
1960 13342307 2023-06-21 stsp (cd $testroot/wt && got commit -m "modified beta" > /dev/null)
1961 13342307 2023-06-21 stsp local commit_id3=`git_show_head $testroot/repo-clone`
1962 13342307 2023-06-21 stsp
1963 13342307 2023-06-21 stsp (cd $testroot/wt && got update -b origin/master > /dev/null)
1964 13342307 2023-06-21 stsp (cd $testroot/wt && got merge master > \
1965 13342307 2023-06-21 stsp $testroot/stdout 2> $testroot/stderr)
1966 13342307 2023-06-21 stsp local merge_commit_id=`git_show_head $testroot/repo-clone`
1967 13342307 2023-06-21 stsp
1968 13342307 2023-06-21 stsp echo -n > $testroot/stdout.expected
1969 13342307 2023-06-21 stsp
1970 13342307 2023-06-21 stsp cmp -s $testroot/stdout $testroot/stdout.expected
1971 13342307 2023-06-21 stsp ret=$?
1972 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1973 13342307 2023-06-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1974 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1975 13342307 2023-06-21 stsp return 1
1976 13342307 2023-06-21 stsp fi
1977 13342307 2023-06-21 stsp
1978 13342307 2023-06-21 stsp echo -n "got: work tree's current branch refs/remotes/origin/master " \
1979 13342307 2023-06-21 stsp > $testroot/stderr.expected
1980 13342307 2023-06-21 stsp echo -n 'is outside the "refs/heads/" reference namespace; ' \
1981 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1982 13342307 2023-06-21 stsp echo -n "update -b required: will not commit to a branch " \
1983 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1984 13342307 2023-06-21 stsp echo 'outside the "refs/heads/" reference namespace' \
1985 13342307 2023-06-21 stsp >> $testroot/stderr.expected
1986 13342307 2023-06-21 stsp
1987 13342307 2023-06-21 stsp cmp -s $testroot/stderr $testroot/stderr.expected
1988 13342307 2023-06-21 stsp ret=$?
1989 13342307 2023-06-21 stsp if [ $ret -ne 0 ]; then
1990 13342307 2023-06-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1991 13342307 2023-06-21 stsp fi
1992 13342307 2023-06-21 stsp test_done "$testroot" "$ret"
1993 13342307 2023-06-21 stsp }
1994 13342307 2023-06-21 stsp
1995 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1996 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1997 179f9db0 2023-06-20 falsifian run_test test_merge_forward
1998 481cdc74 2023-07-01 falsifian run_test test_merge_forward_commit
1999 481cdc74 2023-07-01 falsifian run_test test_merge_forward_interrupt
2000 179f9db0 2023-06-20 falsifian run_test test_merge_backward
2001 f259c4c1 2021-09-24 stsp run_test test_merge_continue
2002 6b5246e4 2023-06-05 stsp run_test test_merge_continue_new_commit
2003 f259c4c1 2021-09-24 stsp run_test test_merge_abort
2004 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
2005 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
2006 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
2007 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
2008 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
2009 088449d3 2021-09-26 stsp run_test test_merge_interrupt
2010 b2b3fce1 2022-10-29 op run_test test_merge_umask
2011 d51d11be 2023-02-21 op run_test test_merge_gitconfig_author
2012 13342307 2023-06-21 stsp run_test test_merge_fetched_branch
2013 13342307 2023-06-21 stsp run_test test_merge_fetched_branch_remote