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 179f9db0 2023-06-20 falsifian echo -n "got: merge is a fast-forward; " > $testroot/stderr.expected
419 179f9db0 2023-06-20 falsifian echo "this is incompatible with got merge -n" \
420 179f9db0 2023-06-20 falsifian >> $testroot/stderr.expected
421 179f9db0 2023-06-20 falsifian cmp -s $testroot/stderr.expected $testroot/stderr
422 179f9db0 2023-06-20 falsifian ret=$?
423 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
424 179f9db0 2023-06-20 falsifian diff -u $testroot/stderr.expected $testroot/stderr
425 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
426 179f9db0 2023-06-20 falsifian return 1
427 179f9db0 2023-06-20 falsifian fi
428 179f9db0 2023-06-20 falsifian
429 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
430 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
431 179f9db0 2023-06-20 falsifian ret=$?
432 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
433 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
434 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
435 179f9db0 2023-06-20 falsifian return 1
436 179f9db0 2023-06-20 falsifian fi
437 179f9db0 2023-06-20 falsifian
438 179f9db0 2023-06-20 falsifian echo "Forwarding refs/heads/master to refs/heads/newbranch" \
439 179f9db0 2023-06-20 falsifian > $testroot/stdout.expected
440 179f9db0 2023-06-20 falsifian echo "U beta" >> $testroot/stdout.expected
441 179f9db0 2023-06-20 falsifian echo "Updated to commit $commit2" \
442 179f9db0 2023-06-20 falsifian >> $testroot/stdout.expected
443 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
444 49c543a6 2022-03-31 naddy ret=$?
445 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
446 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
448 179f9db0 2023-06-20 falsifian return 1
449 f259c4c1 2021-09-24 stsp fi
450 179f9db0 2023-06-20 falsifian
451 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
452 179f9db0 2023-06-20 falsifian echo -n "commit $commit2 " > $testroot/stdout.expected
453 179f9db0 2023-06-20 falsifian echo "(master, newbranch)" >> $testroot/stdout.expected
454 179f9db0 2023-06-20 falsifian echo "commit $commit1" >> $testroot/stdout.expected
455 179f9db0 2023-06-20 falsifian echo "commit $commit0" >> $testroot/stdout.expected
456 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
457 179f9db0 2023-06-20 falsifian ret=$?
458 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
459 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
460 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
461 179f9db0 2023-06-20 falsifian return 1
462 179f9db0 2023-06-20 falsifian fi
463 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
464 179f9db0 2023-06-20 falsifian }
465 179f9db0 2023-06-20 falsifian
466 179f9db0 2023-06-20 falsifian test_merge_backward() {
467 179f9db0 2023-06-20 falsifian local testroot=`test_init merge_backward`
468 179f9db0 2023-06-20 falsifian local commit0=`git_show_head $testroot/repo`
469 179f9db0 2023-06-20 falsifian
470 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q -b newbranch)
471 179f9db0 2023-06-20 falsifian (cd $testroot/repo && git checkout -q master)
472 179f9db0 2023-06-20 falsifian echo "modified alpha on master" > $testroot/repo/alpha
473 179f9db0 2023-06-20 falsifian git_commit $testroot/repo -m "committing to alpha on master"
474 179f9db0 2023-06-20 falsifian
475 179f9db0 2023-06-20 falsifian got checkout -b master $testroot/repo $testroot/wt > /dev/null
476 179f9db0 2023-06-20 falsifian ret=$?
477 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
478 179f9db0 2023-06-20 falsifian echo "got checkout failed unexpectedly" >&2
479 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
480 179f9db0 2023-06-20 falsifian return 1
481 179f9db0 2023-06-20 falsifian fi
482 179f9db0 2023-06-20 falsifian
483 179f9db0 2023-06-20 falsifian (cd $testroot/wt && got merge newbranch \
484 179f9db0 2023-06-20 falsifian > $testroot/stdout 2> $testroot/stderr)
485 179f9db0 2023-06-20 falsifian ret=$?
486 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
487 179f9db0 2023-06-20 falsifian echo "got merge failed unexpectedly" >&2
488 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
489 179f9db0 2023-06-20 falsifian return 1
490 179f9db0 2023-06-20 falsifian fi
491 179f9db0 2023-06-20 falsifian echo "Already up-to-date" > $testroot/stdout.expected
492 179f9db0 2023-06-20 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
493 179f9db0 2023-06-20 falsifian ret=$?
494 179f9db0 2023-06-20 falsifian if [ $ret -ne 0 ]; then
495 179f9db0 2023-06-20 falsifian diff -u $testroot/stdout.expected $testroot/stdout
496 179f9db0 2023-06-20 falsifian test_done "$testroot" "$ret"
497 179f9db0 2023-06-20 falsifian return 1
498 179f9db0 2023-06-20 falsifian fi
499 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
500 f259c4c1 2021-09-24 stsp }
501 f259c4c1 2021-09-24 stsp
502 f259c4c1 2021-09-24 stsp test_merge_continue() {
503 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_continue`
504 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
505 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
506 f259c4c1 2021-09-24 stsp
507 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
508 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
509 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
510 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
511 f259c4c1 2021-09-24 stsp
512 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
513 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
514 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
515 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
516 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
517 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
518 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
519 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
520 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
521 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
522 f259c4c1 2021-09-24 stsp
523 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
524 49c543a6 2022-03-31 naddy ret=$?
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
527 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
528 f259c4c1 2021-09-24 stsp return 1
529 f259c4c1 2021-09-24 stsp fi
530 f259c4c1 2021-09-24 stsp
531 f259c4c1 2021-09-24 stsp # create a conflicting commit
532 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
533 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
534 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
535 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
536 f259c4c1 2021-09-24 stsp
537 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
538 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
539 49c543a6 2022-03-31 naddy ret=$?
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
542 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
543 f259c4c1 2021-09-24 stsp return 1
544 f259c4c1 2021-09-24 stsp fi
545 f259c4c1 2021-09-24 stsp
546 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
547 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
548 49c543a6 2022-03-31 naddy ret=$?
549 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
550 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
551 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
552 f259c4c1 2021-09-24 stsp return 1
553 f259c4c1 2021-09-24 stsp fi
554 f259c4c1 2021-09-24 stsp
555 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
556 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
557 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
558 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
559 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
560 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
561 49c543a6 2022-03-31 naddy ret=$?
562 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
563 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
564 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
565 f259c4c1 2021-09-24 stsp return 1
566 f259c4c1 2021-09-24 stsp fi
567 f259c4c1 2021-09-24 stsp
568 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
569 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
570 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
571 49c543a6 2022-03-31 naddy ret=$?
572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
573 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
574 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
575 f259c4c1 2021-09-24 stsp return 1
576 f259c4c1 2021-09-24 stsp fi
577 f259c4c1 2021-09-24 stsp
578 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
579 f259c4c1 2021-09-24 stsp
580 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
581 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
582 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
583 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
584 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
585 49c543a6 2022-03-31 naddy ret=$?
586 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
587 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
589 f259c4c1 2021-09-24 stsp return 1
590 f259c4c1 2021-09-24 stsp fi
591 f259c4c1 2021-09-24 stsp
592 f259c4c1 2021-09-24 stsp echo '<<<<<<<' > $testroot/content.expected
593 f259c4c1 2021-09-24 stsp echo "modified alpha on master" >> $testroot/content.expected
594 f259c4c1 2021-09-24 stsp echo "||||||| 3-way merge base: commit $commit0" \
595 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
596 f259c4c1 2021-09-24 stsp echo "alpha" >> $testroot/content.expected
597 f259c4c1 2021-09-24 stsp echo "=======" >> $testroot/content.expected
598 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" >> $testroot/content.expected
599 f259c4c1 2021-09-24 stsp echo ">>>>>>> merged change: commit $branch_commit3" \
600 f259c4c1 2021-09-24 stsp >> $testroot/content.expected
601 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
602 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
603 49c543a6 2022-03-31 naddy ret=$?
604 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
605 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
606 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
607 f259c4c1 2021-09-24 stsp return 1
608 f259c4c1 2021-09-24 stsp fi
609 f259c4c1 2021-09-24 stsp
610 f259c4c1 2021-09-24 stsp # resolve the conflict
611 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/wt/alpha
612 f259c4c1 2021-09-24 stsp
613 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
614 49c543a6 2022-03-31 naddy ret=$?
615 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
616 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
617 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
618 f259c4c1 2021-09-24 stsp return 1
619 f259c4c1 2021-09-24 stsp fi
620 f259c4c1 2021-09-24 stsp
621 f259c4c1 2021-09-24 stsp local merge_commit=`git_show_head $testroot/repo`
622 f259c4c1 2021-09-24 stsp
623 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
624 0ff8d236 2021-09-28 stsp echo "D beta" >> $testroot/stdout.expected
625 0ff8d236 2021-09-28 stsp echo "A epsilon/new" >> $testroot/stdout.expected
626 0ff8d236 2021-09-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
627 f259c4c1 2021-09-24 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
628 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
629 f259c4c1 2021-09-24 stsp echo $merge_commit >> $testroot/stdout.expected
630 f259c4c1 2021-09-24 stsp
631 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
632 49c543a6 2022-03-31 naddy ret=$?
633 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
634 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
635 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
636 f259c4c1 2021-09-24 stsp return 1
637 f259c4c1 2021-09-24 stsp fi
638 f259c4c1 2021-09-24 stsp
639 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/content.expected
640 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
641 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
642 49c543a6 2022-03-31 naddy ret=$?
643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
644 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
645 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
646 f259c4c1 2021-09-24 stsp return 1
647 f259c4c1 2021-09-24 stsp fi
648 f259c4c1 2021-09-24 stsp
649 f259c4c1 2021-09-24 stsp echo "modified alpha by both branches" > $testroot/content.expected
650 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
651 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
652 49c543a6 2022-03-31 naddy ret=$?
653 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
654 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
655 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
656 f259c4c1 2021-09-24 stsp return 1
657 f259c4c1 2021-09-24 stsp fi
658 f259c4c1 2021-09-24 stsp
659 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/beta ]; then
660 f259c4c1 2021-09-24 stsp echo "removed file beta still exists on disk" >&2
661 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
662 f259c4c1 2021-09-24 stsp return 1
663 f259c4c1 2021-09-24 stsp fi
664 f259c4c1 2021-09-24 stsp
665 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/content.expected
666 f259c4c1 2021-09-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
667 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
668 49c543a6 2022-03-31 naddy ret=$?
669 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
670 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
671 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
672 f259c4c1 2021-09-24 stsp return 1
673 f259c4c1 2021-09-24 stsp fi
674 f259c4c1 2021-09-24 stsp
675 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
676 f259c4c1 2021-09-24 stsp
677 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
678 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
679 49c543a6 2022-03-31 naddy ret=$?
680 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
681 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
682 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
683 f259c4c1 2021-09-24 stsp return 1
684 f259c4c1 2021-09-24 stsp fi
685 f259c4c1 2021-09-24 stsp
686 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
687 f259c4c1 2021-09-24 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
688 f259c4c1 2021-09-24 stsp echo "commit $master_commit" >> $testroot/stdout.expected
689 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
690 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
691 49c543a6 2022-03-31 naddy ret=$?
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
695 f259c4c1 2021-09-24 stsp return 1
696 f259c4c1 2021-09-24 stsp fi
697 f259c4c1 2021-09-24 stsp
698 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
699 f259c4c1 2021-09-24 stsp
700 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
701 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
702 49c543a6 2022-03-31 naddy ret=$?
703 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
704 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
706 f259c4c1 2021-09-24 stsp return 1
707 f259c4c1 2021-09-24 stsp fi
708 f259c4c1 2021-09-24 stsp
709 f259c4c1 2021-09-24 stsp # We should have created a merge commit with two parents.
710 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
711 f259c4c1 2021-09-24 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
712 f259c4c1 2021-09-24 stsp echo "parent 2: $branch_commit3" >> $testroot/stdout.expected
713 6b5246e4 2023-06-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
714 6b5246e4 2023-06-05 stsp ret=$?
715 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
716 6b5246e4 2023-06-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 6b5246e4 2023-06-05 stsp fi
718 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
719 6b5246e4 2023-06-05 stsp }
720 6b5246e4 2023-06-05 stsp
721 6b5246e4 2023-06-05 stsp test_merge_continue_new_commit() {
722 6b5246e4 2023-06-05 stsp # "got merge -c" should refuse to run if the current branch tip has
723 6b5246e4 2023-06-05 stsp # changed since the merge was started, to avoid clobbering the changes.
724 6b5246e4 2023-06-05 stsp local testroot=`test_init merge_continue_new_commit`
725 6b5246e4 2023-06-05 stsp
726 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q -b newbranch)
727 6b5246e4 2023-06-05 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
728 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
729 6b5246e4 2023-06-05 stsp
730 6b5246e4 2023-06-05 stsp (cd $testroot/repo && git checkout -q master)
731 6b5246e4 2023-06-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
732 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master"
733 6b5246e4 2023-06-05 stsp
734 6b5246e4 2023-06-05 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
735 6b5246e4 2023-06-05 stsp ret=$?
736 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
737 6b5246e4 2023-06-05 stsp echo "got checkout failed unexpectedly" >&2
738 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
739 6b5246e4 2023-06-05 stsp return 1
740 6b5246e4 2023-06-05 stsp fi
741 6b5246e4 2023-06-05 stsp
742 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -n newbranch >/dev/null)
743 6b5246e4 2023-06-05 stsp ret=$?
744 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
745 6b5246e4 2023-06-05 stsp echo "got merge failed unexpectedly" >&2
746 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
747 6b5246e4 2023-06-05 stsp return 1
748 6b5246e4 2023-06-05 stsp fi
749 6b5246e4 2023-06-05 stsp
750 6b5246e4 2023-06-05 stsp echo "modified alpha again on master" > $testroot/repo/alpha
751 6b5246e4 2023-06-05 stsp git_commit $testroot/repo -m "committing to alpha on master again"
752 6b5246e4 2023-06-05 stsp
753 6b5246e4 2023-06-05 stsp (cd $testroot/wt && got merge -c > $testroot/stdout 2> $testroot/stderr)
754 6b5246e4 2023-06-05 stsp ret=$?
755 6b5246e4 2023-06-05 stsp if [ $ret -eq 0 ]; then
756 6b5246e4 2023-06-05 stsp echo "got merge succeeded unexpectedly" >&2
757 6b5246e4 2023-06-05 stsp test_done "$testroot" "1"
758 6b5246e4 2023-06-05 stsp return 1
759 6b5246e4 2023-06-05 stsp fi
760 6b5246e4 2023-06-05 stsp
761 6b5246e4 2023-06-05 stsp echo -n > $testroot/stdout.expected
762 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
763 49c543a6 2022-03-31 naddy ret=$?
764 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
765 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
766 6b5246e4 2023-06-05 stsp test_done "$testroot" "$ret"
767 6b5246e4 2023-06-05 stsp return 1
768 6b5246e4 2023-06-05 stsp fi
769 6b5246e4 2023-06-05 stsp
770 6b5246e4 2023-06-05 stsp echo -n "got: merging cannot proceed because the work tree is no " \
771 6b5246e4 2023-06-05 stsp > $testroot/stderr.expected
772 6b5246e4 2023-06-05 stsp echo "longer up-to-date; merge must be aborted and retried" \
773 6b5246e4 2023-06-05 stsp >> $testroot/stderr.expected
774 6b5246e4 2023-06-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
775 6b5246e4 2023-06-05 stsp ret=$?
776 6b5246e4 2023-06-05 stsp if [ $ret -ne 0 ]; then
777 6b5246e4 2023-06-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
778 f259c4c1 2021-09-24 stsp fi
779 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
780 f259c4c1 2021-09-24 stsp }
781 f259c4c1 2021-09-24 stsp
782 f259c4c1 2021-09-24 stsp test_merge_abort() {
783 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_abort`
784 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
785 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
786 f259c4c1 2021-09-24 stsp
787 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
788 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
789 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
790 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
791 f259c4c1 2021-09-24 stsp
792 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
793 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
794 f259c4c1 2021-09-24 stsp local branch_commit1=`git_show_branch_head $testroot/repo newbranch`
795 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git rm -q beta)
796 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "removing beta on newbranch"
797 f259c4c1 2021-09-24 stsp local branch_commit2=`git_show_branch_head $testroot/repo newbranch`
798 f259c4c1 2021-09-24 stsp echo "new file on branch" > $testroot/repo/epsilon/new
799 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git add epsilon/new)
800 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding new file on newbranch"
801 f259c4c1 2021-09-24 stsp local branch_commit3=`git_show_branch_head $testroot/repo newbranch`
802 f259c4c1 2021-09-24 stsp (cd $testroot/repo && ln -s alpha symlink && git add symlink)
803 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "adding symlink on newbranch"
804 f259c4c1 2021-09-24 stsp local branch_commit4=`git_show_branch_head $testroot/repo newbranch`
805 f259c4c1 2021-09-24 stsp
806 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
807 49c543a6 2022-03-31 naddy ret=$?
808 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
809 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
810 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
811 f259c4c1 2021-09-24 stsp return 1
812 f259c4c1 2021-09-24 stsp fi
813 41f061b2 2021-10-05 stsp
814 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
815 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
816 f259c4c1 2021-09-24 stsp
817 f259c4c1 2021-09-24 stsp # create a conflicting commit
818 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
819 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
820 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
821 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
822 f259c4c1 2021-09-24 stsp
823 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
824 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
825 49c543a6 2022-03-31 naddy ret=$?
826 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
827 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
828 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
829 f259c4c1 2021-09-24 stsp return 1
830 f259c4c1 2021-09-24 stsp fi
831 f259c4c1 2021-09-24 stsp
832 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
833 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
834 49c543a6 2022-03-31 naddy ret=$?
835 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
836 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
837 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
838 f259c4c1 2021-09-24 stsp return 1
839 f259c4c1 2021-09-24 stsp fi
840 f259c4c1 2021-09-24 stsp
841 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
842 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
843 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
844 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
845 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
846 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
847 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
848 49c543a6 2022-03-31 naddy ret=$?
849 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
850 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
852 f259c4c1 2021-09-24 stsp return 1
853 f259c4c1 2021-09-24 stsp fi
854 f259c4c1 2021-09-24 stsp
855 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
856 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
857 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
858 49c543a6 2022-03-31 naddy ret=$?
859 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
860 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
861 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
862 f259c4c1 2021-09-24 stsp return 1
863 f259c4c1 2021-09-24 stsp fi
864 af179be7 2023-04-14 stsp
865 af179be7 2023-04-14 stsp # unrelated added file added during conflict resolution
866 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
867 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
868 f259c4c1 2021-09-24 stsp
869 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
870 f259c4c1 2021-09-24 stsp
871 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
872 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
873 f259c4c1 2021-09-24 stsp echo "D beta" >> $testroot/stdout.expected
874 f259c4c1 2021-09-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
875 f259c4c1 2021-09-24 stsp echo "M gamma/delta" >> $testroot/stdout.expected
876 f259c4c1 2021-09-24 stsp echo "A symlink" >> $testroot/stdout.expected
877 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
878 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 49c543a6 2022-03-31 naddy ret=$?
880 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
881 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
883 f259c4c1 2021-09-24 stsp return 1
884 f259c4c1 2021-09-24 stsp fi
885 f259c4c1 2021-09-24 stsp
886 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge -a > $testroot/stdout)
887 49c543a6 2022-03-31 naddy ret=$?
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 f259c4c1 2021-09-24 stsp echo "got merge failed unexpectedly" >&2
890 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
891 f259c4c1 2021-09-24 stsp return 1
892 f259c4c1 2021-09-24 stsp fi
893 f259c4c1 2021-09-24 stsp
894 af179be7 2023-04-14 stsp echo "R added-file" > $testroot/stdout.expected
895 af179be7 2023-04-14 stsp echo "R alpha" >> $testroot/stdout.expected
896 f259c4c1 2021-09-24 stsp echo "R beta" >> $testroot/stdout.expected
897 f259c4c1 2021-09-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
898 f259c4c1 2021-09-24 stsp echo "R gamma/delta" >> $testroot/stdout.expected
899 f259c4c1 2021-09-24 stsp echo "R symlink" >> $testroot/stdout.expected
900 af179be7 2023-04-14 stsp echo "G added-file" >> $testroot/stdout.expected
901 f259c4c1 2021-09-24 stsp echo "Merge of refs/heads/newbranch aborted" \
902 f259c4c1 2021-09-24 stsp >> $testroot/stdout.expected
903 f259c4c1 2021-09-24 stsp
904 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
905 49c543a6 2022-03-31 naddy ret=$?
906 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
907 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
909 f259c4c1 2021-09-24 stsp return 1
910 f259c4c1 2021-09-24 stsp fi
911 f259c4c1 2021-09-24 stsp
912 f259c4c1 2021-09-24 stsp echo "delta" > $testroot/content.expected
913 f259c4c1 2021-09-24 stsp cat $testroot/wt/gamma/delta > $testroot/content
914 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
915 49c543a6 2022-03-31 naddy ret=$?
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
918 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
919 f259c4c1 2021-09-24 stsp return 1
920 f259c4c1 2021-09-24 stsp fi
921 f259c4c1 2021-09-24 stsp
922 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/content.expected
923 f259c4c1 2021-09-24 stsp cat $testroot/wt/alpha > $testroot/content
924 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
925 49c543a6 2022-03-31 naddy ret=$?
926 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
927 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
928 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
929 f259c4c1 2021-09-24 stsp return 1
930 f259c4c1 2021-09-24 stsp fi
931 f259c4c1 2021-09-24 stsp
932 f259c4c1 2021-09-24 stsp echo "beta" > $testroot/content.expected
933 f259c4c1 2021-09-24 stsp cat $testroot/wt/beta > $testroot/content
934 f259c4c1 2021-09-24 stsp cmp -s $testroot/content.expected $testroot/content
935 49c543a6 2022-03-31 naddy ret=$?
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 f259c4c1 2021-09-24 stsp diff -u $testroot/content.expected $testroot/content
938 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
939 f259c4c1 2021-09-24 stsp return 1
940 f259c4c1 2021-09-24 stsp fi
941 f259c4c1 2021-09-24 stsp
942 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/epsilon/new ]; then
943 f259c4c1 2021-09-24 stsp echo "reverted file epsilon/new still exists on disk" >&2
944 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
945 f259c4c1 2021-09-24 stsp return 1
946 f259c4c1 2021-09-24 stsp fi
947 f259c4c1 2021-09-24 stsp
948 f259c4c1 2021-09-24 stsp if [ -e $testroot/wt/symlink ]; then
949 f259c4c1 2021-09-24 stsp echo "reverted symlink still exists on disk" >&2
950 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
951 f259c4c1 2021-09-24 stsp return 1
952 f259c4c1 2021-09-24 stsp fi
953 f259c4c1 2021-09-24 stsp
954 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
955 f259c4c1 2021-09-24 stsp
956 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
957 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
958 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
959 49c543a6 2022-03-31 naddy ret=$?
960 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
961 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
963 f259c4c1 2021-09-24 stsp return 1
964 f259c4c1 2021-09-24 stsp fi
965 f259c4c1 2021-09-24 stsp
966 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
967 f259c4c1 2021-09-24 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
968 f259c4c1 2021-09-24 stsp echo "commit $commit0" >> $testroot/stdout.expected
969 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
970 49c543a6 2022-03-31 naddy ret=$?
971 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
972 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
973 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
974 f259c4c1 2021-09-24 stsp return 1
975 f259c4c1 2021-09-24 stsp fi
976 f259c4c1 2021-09-24 stsp
977 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > $testroot/stdout)
978 f259c4c1 2021-09-24 stsp
979 f259c4c1 2021-09-24 stsp echo 'Already up-to-date' > $testroot/stdout.expected
980 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
981 49c543a6 2022-03-31 naddy ret=$?
982 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
983 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
984 f259c4c1 2021-09-24 stsp fi
985 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
986 f259c4c1 2021-09-24 stsp }
987 f259c4c1 2021-09-24 stsp
988 f259c4c1 2021-09-24 stsp test_merge_in_progress() {
989 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_in_progress`
990 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
991 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
992 f259c4c1 2021-09-24 stsp
993 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
994 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
995 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
996 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
997 f259c4c1 2021-09-24 stsp
998 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
999 49c543a6 2022-03-31 naddy ret=$?
1000 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1001 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1002 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1003 f259c4c1 2021-09-24 stsp return 1
1004 f259c4c1 2021-09-24 stsp fi
1005 f259c4c1 2021-09-24 stsp
1006 f259c4c1 2021-09-24 stsp # create a conflicting commit
1007 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1008 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1009 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1010 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1011 f259c4c1 2021-09-24 stsp
1012 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1013 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1014 49c543a6 2022-03-31 naddy ret=$?
1015 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1016 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
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 newbranch \
1022 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1023 49c543a6 2022-03-31 naddy ret=$?
1024 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1025 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1026 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1027 f259c4c1 2021-09-24 stsp return 1
1028 f259c4c1 2021-09-24 stsp fi
1029 f259c4c1 2021-09-24 stsp
1030 f259c4c1 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1031 f259c4c1 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1032 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1033 49c543a6 2022-03-31 naddy ret=$?
1034 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1035 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1036 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1037 f259c4c1 2021-09-24 stsp return 1
1038 f259c4c1 2021-09-24 stsp fi
1039 f259c4c1 2021-09-24 stsp
1040 f259c4c1 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1041 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1042 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1043 49c543a6 2022-03-31 naddy ret=$?
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1047 f259c4c1 2021-09-24 stsp return 1
1048 f259c4c1 2021-09-24 stsp fi
1049 f259c4c1 2021-09-24 stsp
1050 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1051 f259c4c1 2021-09-24 stsp
1052 f259c4c1 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1053 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1054 49c543a6 2022-03-31 naddy ret=$?
1055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1056 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1057 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1058 f259c4c1 2021-09-24 stsp return 1
1059 f259c4c1 2021-09-24 stsp fi
1060 f259c4c1 2021-09-24 stsp
1061 f259c4c1 2021-09-24 stsp for cmd in update commit histedit "rebase newbranch" \
1062 42761529 2023-06-01 stsp "integrate newbranch" "merge newbranch" "stage alpha"; do
1063 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
1064 f259c4c1 2021-09-24 stsp 2> $testroot/stderr)
1065 42761529 2023-06-01 stsp ret=$?
1066 42761529 2023-06-01 stsp if [ $ret -eq 0 ]; then
1067 42761529 2023-06-01 stsp echo "got $cmd succeeded unexpectedly" >&2
1068 42761529 2023-06-01 stsp test_done "$testroot" "1"
1069 42761529 2023-06-01 stsp return 1
1070 42761529 2023-06-01 stsp fi
1071 f259c4c1 2021-09-24 stsp
1072 f259c4c1 2021-09-24 stsp echo -n > $testroot/stdout.expected
1073 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1078 f259c4c1 2021-09-24 stsp return 1
1079 f259c4c1 2021-09-24 stsp fi
1080 f259c4c1 2021-09-24 stsp
1081 f259c4c1 2021-09-24 stsp echo -n "got: a merge operation is in progress in this " \
1082 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1083 f259c4c1 2021-09-24 stsp echo "work tree and must be continued or aborted first" \
1084 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1085 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1086 49c543a6 2022-03-31 naddy ret=$?
1087 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1088 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1089 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1090 f259c4c1 2021-09-24 stsp return 1
1091 f259c4c1 2021-09-24 stsp fi
1092 f259c4c1 2021-09-24 stsp done
1093 f259c4c1 2021-09-24 stsp
1094 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1095 f259c4c1 2021-09-24 stsp }
1096 f259c4c1 2021-09-24 stsp
1097 f259c4c1 2021-09-24 stsp test_merge_path_prefix() {
1098 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_path_prefix`
1099 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1100 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1101 f259c4c1 2021-09-24 stsp
1102 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1103 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1104 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1105 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1106 f259c4c1 2021-09-24 stsp
1107 f259c4c1 2021-09-24 stsp got checkout -p epsilon -b master $testroot/repo $testroot/wt \
1108 f259c4c1 2021-09-24 stsp > /dev/null
1109 49c543a6 2022-03-31 naddy ret=$?
1110 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1111 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1112 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1113 f259c4c1 2021-09-24 stsp return 1
1114 f259c4c1 2021-09-24 stsp fi
1115 f259c4c1 2021-09-24 stsp
1116 f259c4c1 2021-09-24 stsp # create a conflicting commit
1117 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1118 f259c4c1 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1119 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1120 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1121 f259c4c1 2021-09-24 stsp
1122 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1123 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1124 49c543a6 2022-03-31 naddy ret=$?
1125 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1126 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1127 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1128 f259c4c1 2021-09-24 stsp return 1
1129 f259c4c1 2021-09-24 stsp fi
1130 f259c4c1 2021-09-24 stsp
1131 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1132 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1133 49c543a6 2022-03-31 naddy ret=$?
1134 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1135 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1136 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1137 f259c4c1 2021-09-24 stsp return 1
1138 f259c4c1 2021-09-24 stsp fi
1139 f259c4c1 2021-09-24 stsp
1140 f259c4c1 2021-09-24 stsp echo -n "got: cannot merge branch which contains changes outside " \
1141 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1142 f259c4c1 2021-09-24 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
1143 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1144 49c543a6 2022-03-31 naddy ret=$?
1145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1146 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1147 f259c4c1 2021-09-24 stsp fi
1148 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1149 f259c4c1 2021-09-24 stsp }
1150 f259c4c1 2021-09-24 stsp
1151 f259c4c1 2021-09-24 stsp test_merge_missing_file() {
1152 f259c4c1 2021-09-24 stsp local testroot=`test_init merge_missing_file`
1153 f259c4c1 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1154 f259c4c1 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1155 f259c4c1 2021-09-24 stsp
1156 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1157 f259c4c1 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1158 f259c4c1 2021-09-24 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1159 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha and delta"
1160 f259c4c1 2021-09-24 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1161 f259c4c1 2021-09-24 stsp
1162 f259c4c1 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1163 49c543a6 2022-03-31 naddy ret=$?
1164 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1165 f259c4c1 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1166 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1167 f259c4c1 2021-09-24 stsp return 1
1168 f259c4c1 2021-09-24 stsp fi
1169 f259c4c1 2021-09-24 stsp
1170 f259c4c1 2021-09-24 stsp # create a conflicting commit which renames alpha
1171 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1172 f259c4c1 2021-09-24 stsp (cd $testroot/repo && git mv alpha epsilon/alpha-moved)
1173 f259c4c1 2021-09-24 stsp git_commit $testroot/repo -m "moving alpha on master"
1174 f259c4c1 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1175 f259c4c1 2021-09-24 stsp
1176 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1177 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1178 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 f259c4c1 2021-09-24 stsp echo "got update failed unexpectedly" >&2
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 merge newbranch \
1186 f259c4c1 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1187 49c543a6 2022-03-31 naddy ret=$?
1188 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1189 f259c4c1 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1190 f259c4c1 2021-09-24 stsp test_done "$testroot" "1"
1191 f259c4c1 2021-09-24 stsp return 1
1192 f259c4c1 2021-09-24 stsp fi
1193 f259c4c1 2021-09-24 stsp
1194 f259c4c1 2021-09-24 stsp echo "! alpha" > $testroot/stdout.expected
1195 f259c4c1 2021-09-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1196 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1197 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1198 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1199 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1200 49c543a6 2022-03-31 naddy ret=$?
1201 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1202 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1203 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1204 f259c4c1 2021-09-24 stsp return 1
1205 f259c4c1 2021-09-24 stsp fi
1206 f259c4c1 2021-09-24 stsp
1207 c1b05723 2021-09-28 stsp echo -n "got: changes destined for some files " \
1208 f259c4c1 2021-09-24 stsp > $testroot/stderr.expected
1209 f259c4c1 2021-09-24 stsp echo -n "were not yet merged and should be merged manually if " \
1210 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1211 f259c4c1 2021-09-24 stsp echo "required before the merge operation is continued" \
1212 f259c4c1 2021-09-24 stsp >> $testroot/stderr.expected
1213 f259c4c1 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1214 49c543a6 2022-03-31 naddy ret=$?
1215 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1216 f259c4c1 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1217 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1218 f259c4c1 2021-09-24 stsp return 1
1219 f259c4c1 2021-09-24 stsp fi
1220 f259c4c1 2021-09-24 stsp
1221 f259c4c1 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1222 f259c4c1 2021-09-24 stsp
1223 f259c4c1 2021-09-24 stsp echo "M gamma/delta" > $testroot/stdout.expected
1224 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1225 49c543a6 2022-03-31 naddy ret=$?
1226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1227 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1228 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1229 a6a8f8bb 2021-09-24 stsp return 1
1230 a6a8f8bb 2021-09-24 stsp fi
1231 a6a8f8bb 2021-09-24 stsp
1232 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1233 a6a8f8bb 2021-09-24 stsp }
1234 a6a8f8bb 2021-09-24 stsp
1235 a6a8f8bb 2021-09-24 stsp test_merge_no_op() {
1236 a6a8f8bb 2021-09-24 stsp local testroot=`test_init merge_no_op`
1237 a6a8f8bb 2021-09-24 stsp local commit0=`git_show_head $testroot/repo`
1238 a6a8f8bb 2021-09-24 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1239 a6a8f8bb 2021-09-24 stsp
1240 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1241 a6a8f8bb 2021-09-24 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1242 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1243 35d2583f 2023-04-17 stsp local branch_commit=`git_show_branch_head $testroot/repo newbranch`
1244 a6a8f8bb 2021-09-24 stsp
1245 a6a8f8bb 2021-09-24 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1246 49c543a6 2022-03-31 naddy ret=$?
1247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1248 a6a8f8bb 2021-09-24 stsp echo "got checkout failed unexpectedly" >&2
1249 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1250 a6a8f8bb 2021-09-24 stsp return 1
1251 a6a8f8bb 2021-09-24 stsp fi
1252 a6a8f8bb 2021-09-24 stsp
1253 a6a8f8bb 2021-09-24 stsp # create a conflicting commit
1254 a6a8f8bb 2021-09-24 stsp (cd $testroot/repo && git checkout -q master)
1255 a6a8f8bb 2021-09-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
1256 a6a8f8bb 2021-09-24 stsp git_commit $testroot/repo -m "committing to alpha on master"
1257 a6a8f8bb 2021-09-24 stsp local master_commit=`git_show_head $testroot/repo`
1258 a6a8f8bb 2021-09-24 stsp
1259 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1260 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got update > /dev/null)
1261 49c543a6 2022-03-31 naddy ret=$?
1262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1263 a6a8f8bb 2021-09-24 stsp echo "got update failed unexpectedly" >&2
1264 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1265 a6a8f8bb 2021-09-24 stsp return 1
1266 a6a8f8bb 2021-09-24 stsp fi
1267 a6a8f8bb 2021-09-24 stsp
1268 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge newbranch \
1269 a6a8f8bb 2021-09-24 stsp > $testroot/stdout 2> $testroot/stderr)
1270 49c543a6 2022-03-31 naddy ret=$?
1271 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1272 a6a8f8bb 2021-09-24 stsp echo "got merge succeeded unexpectedly" >&2
1273 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "1"
1274 a6a8f8bb 2021-09-24 stsp return 1
1275 a6a8f8bb 2021-09-24 stsp fi
1276 a6a8f8bb 2021-09-24 stsp
1277 a6a8f8bb 2021-09-24 stsp echo "C alpha" >> $testroot/stdout.expected
1278 a6a8f8bb 2021-09-24 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1279 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1280 49c543a6 2022-03-31 naddy ret=$?
1281 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1282 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1283 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1284 a6a8f8bb 2021-09-24 stsp return 1
1285 a6a8f8bb 2021-09-24 stsp fi
1286 a6a8f8bb 2021-09-24 stsp
1287 a6a8f8bb 2021-09-24 stsp echo "got: conflicts must be resolved before merging can continue" \
1288 a6a8f8bb 2021-09-24 stsp > $testroot/stderr.expected
1289 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1290 49c543a6 2022-03-31 naddy ret=$?
1291 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1292 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1293 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1294 a6a8f8bb 2021-09-24 stsp return 1
1295 a6a8f8bb 2021-09-24 stsp fi
1296 a6a8f8bb 2021-09-24 stsp
1297 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1298 a6a8f8bb 2021-09-24 stsp
1299 a6a8f8bb 2021-09-24 stsp echo "C alpha" > $testroot/stdout.expected
1300 f259c4c1 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1301 49c543a6 2022-03-31 naddy ret=$?
1302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1303 f259c4c1 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1304 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1305 f259c4c1 2021-09-24 stsp return 1
1306 f259c4c1 2021-09-24 stsp fi
1307 f259c4c1 2021-09-24 stsp
1308 a6a8f8bb 2021-09-24 stsp # resolve the conflict by reverting all changes; now it is no-op merge
1309 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got revert alpha > /dev/null)
1310 49c543a6 2022-03-31 naddy ret=$?
1311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1312 a6a8f8bb 2021-09-24 stsp echo "got revert failed unexpectedly" >&2
1313 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1314 a6a8f8bb 2021-09-24 stsp return 1
1315 a6a8f8bb 2021-09-24 stsp fi
1316 a6a8f8bb 2021-09-24 stsp
1317 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got merge -c > $testroot/stdout \
1318 a6a8f8bb 2021-09-24 stsp 2> $testroot/stderr)
1319 49c543a6 2022-03-31 naddy ret=$?
1320 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1321 35d2583f 2023-04-17 stsp echo "got merge failed unexpectedly" >&2
1322 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1323 a6a8f8bb 2021-09-24 stsp return 1
1324 a6a8f8bb 2021-09-24 stsp fi
1325 a6a8f8bb 2021-09-24 stsp
1326 35d2583f 2023-04-17 stsp echo -n '' > $testroot/stderr.expected
1327 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1328 49c543a6 2022-03-31 naddy ret=$?
1329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1330 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
1331 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1332 35d2583f 2023-04-17 stsp return 1
1333 35d2583f 2023-04-17 stsp fi
1334 35d2583f 2023-04-17 stsp
1335 35d2583f 2023-04-17 stsp local merge_commit=`git_show_head $testroot/repo`
1336 35d2583f 2023-04-17 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1337 35d2583f 2023-04-17 stsp > $testroot/stdout.expected
1338 35d2583f 2023-04-17 stsp echo $merge_commit >> $testroot/stdout.expected
1339 35d2583f 2023-04-17 stsp
1340 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1341 35d2583f 2023-04-17 stsp ret=$?
1342 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1343 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1344 a6a8f8bb 2021-09-24 stsp test_done "$testroot" "$ret"
1345 a6a8f8bb 2021-09-24 stsp return 1
1346 a6a8f8bb 2021-09-24 stsp fi
1347 a6a8f8bb 2021-09-24 stsp
1348 a6a8f8bb 2021-09-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1349 a6a8f8bb 2021-09-24 stsp
1350 a6a8f8bb 2021-09-24 stsp echo -n "" > $testroot/stdout.expected
1351 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1352 49c543a6 2022-03-31 naddy ret=$?
1353 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1354 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1355 35d2583f 2023-04-17 stsp test_done "$testroot" "$ret"
1356 35d2583f 2023-04-17 stsp return 1
1357 4e91ef15 2021-09-26 stsp fi
1358 35d2583f 2023-04-17 stsp
1359 35d2583f 2023-04-17 stsp # We should have created a merge commit with two parents.
1360 35d2583f 2023-04-17 stsp got log -r $testroot/repo -l1 -c $merge_commit | grep ^parent \
1361 35d2583f 2023-04-17 stsp > $testroot/stdout
1362 35d2583f 2023-04-17 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1363 35d2583f 2023-04-17 stsp echo "parent 2: $branch_commit" >> $testroot/stdout.expected
1364 35d2583f 2023-04-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1365 35d2583f 2023-04-17 stsp ret=$?
1366 35d2583f 2023-04-17 stsp if [ $ret -ne 0 ]; then
1367 35d2583f 2023-04-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1368 35d2583f 2023-04-17 stsp fi
1369 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1370 4e91ef15 2021-09-26 stsp }
1371 4e91ef15 2021-09-26 stsp
1372 4e91ef15 2021-09-26 stsp test_merge_imported_branch() {
1373 4e91ef15 2021-09-26 stsp local testroot=`test_init merge_import`
1374 4e91ef15 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1375 4e91ef15 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1376 4e91ef15 2021-09-26 stsp
1377 4e91ef15 2021-09-26 stsp # import a new sub-tree to the 'files' branch such that
1378 4e91ef15 2021-09-26 stsp # none of the files added here collide with existing ones
1379 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/there
1380 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/be/lots
1381 4e91ef15 2021-09-26 stsp mkdir -p $testroot/tree/files
1382 4e91ef15 2021-09-26 stsp echo "there should" > $testroot/tree/there/should
1383 4e91ef15 2021-09-26 stsp echo "be lots of" > $testroot/tree/be/lots/of
1384 4e91ef15 2021-09-26 stsp echo "files here" > $testroot/tree/files/here
1385 4e91ef15 2021-09-26 stsp got import -r $testroot/repo -b files -m 'import files' \
1386 4e91ef15 2021-09-26 stsp $testroot/tree > /dev/null
1387 4e91ef15 2021-09-26 stsp
1388 4e91ef15 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1389 49c543a6 2022-03-31 naddy ret=$?
1390 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1391 4e91ef15 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1392 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1393 4e91ef15 2021-09-26 stsp return 1
1394 4e91ef15 2021-09-26 stsp fi
1395 4e91ef15 2021-09-26 stsp
1396 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1397 49c543a6 2022-03-31 naddy ret=$?
1398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1399 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1400 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1401 4e91ef15 2021-09-26 stsp return 1
1402 4e91ef15 2021-09-26 stsp fi
1403 4e91ef15 2021-09-26 stsp
1404 4e91ef15 2021-09-26 stsp local merge_commit0=`git_show_head $testroot/repo`
1405 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1406 4e91ef15 2021-09-26 stsp A be/lots/of
1407 4e91ef15 2021-09-26 stsp A files/here
1408 4e91ef15 2021-09-26 stsp A there/should
1409 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit0
1410 4e91ef15 2021-09-26 stsp EOF
1411 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1412 49c543a6 2022-03-31 naddy ret=$?
1413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1414 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1415 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1416 4e91ef15 2021-09-26 stsp return 1
1417 4e91ef15 2021-09-26 stsp fi
1418 4e91ef15 2021-09-26 stsp
1419 4e91ef15 2021-09-26 stsp # try to merge again while no new changes are available
1420 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1421 49c543a6 2022-03-31 naddy ret=$?
1422 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1423 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1424 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1425 4e91ef15 2021-09-26 stsp return 1
1426 4e91ef15 2021-09-26 stsp fi
1427 4e91ef15 2021-09-26 stsp echo "Already up-to-date" > $testroot/stdout.expected
1428 a6a8f8bb 2021-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1429 49c543a6 2022-03-31 naddy ret=$?
1430 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1431 a6a8f8bb 2021-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1432 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1433 4e91ef15 2021-09-26 stsp return 1
1434 a6a8f8bb 2021-09-24 stsp fi
1435 4e91ef15 2021-09-26 stsp
1436 4e91ef15 2021-09-26 stsp # update the 'files' branch
1437 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git reset -q --hard master)
1438 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git checkout -q files)
1439 4e91ef15 2021-09-26 stsp echo "indeed" > $testroot/repo/indeed
1440 4e91ef15 2021-09-26 stsp (cd $testroot/repo && git add indeed)
1441 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "adding another file indeed"
1442 4e91ef15 2021-09-26 stsp echo "be lots and lots of" > $testroot/repo/be/lots/of
1443 4e91ef15 2021-09-26 stsp git_commit $testroot/repo -m "lots of changes"
1444 4e91ef15 2021-09-26 stsp
1445 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1446 49c543a6 2022-03-31 naddy ret=$?
1447 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1448 4e91ef15 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1449 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1450 4e91ef15 2021-09-26 stsp return 1
1451 4e91ef15 2021-09-26 stsp fi
1452 4e91ef15 2021-09-26 stsp
1453 4e91ef15 2021-09-26 stsp # we should now be able to merge more changes from files branch
1454 4e91ef15 2021-09-26 stsp (cd $testroot/wt && got merge files > $testroot/stdout)
1455 49c543a6 2022-03-31 naddy ret=$?
1456 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1457 4e91ef15 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1458 4e91ef15 2021-09-26 stsp test_done "$testroot" "$ret"
1459 4e91ef15 2021-09-26 stsp return 1
1460 4e91ef15 2021-09-26 stsp fi
1461 4e91ef15 2021-09-26 stsp
1462 4e91ef15 2021-09-26 stsp local merge_commit1=`git_show_branch_head $testroot/repo master`
1463 4e91ef15 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
1464 4e91ef15 2021-09-26 stsp G be/lots/of
1465 4e91ef15 2021-09-26 stsp A indeed
1466 4e91ef15 2021-09-26 stsp Merged refs/heads/files into refs/heads/master: $merge_commit1
1467 4e91ef15 2021-09-26 stsp EOF
1468 4e91ef15 2021-09-26 stsp
1469 4e91ef15 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1470 49c543a6 2022-03-31 naddy ret=$?
1471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1472 4e91ef15 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1473 4e91ef15 2021-09-26 stsp fi
1474 f259c4c1 2021-09-24 stsp test_done "$testroot" "$ret"
1475 f259c4c1 2021-09-24 stsp }
1476 088449d3 2021-09-26 stsp
1477 088449d3 2021-09-26 stsp test_merge_interrupt() {
1478 088449d3 2021-09-26 stsp local testroot=`test_init merge_interrupt`
1479 088449d3 2021-09-26 stsp local commit0=`git_show_head $testroot/repo`
1480 088449d3 2021-09-26 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1481 088449d3 2021-09-26 stsp
1482 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1483 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1484 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
1485 088449d3 2021-09-26 stsp local branch_commit0=`git_show_branch_head $testroot/repo newbranch`
1486 088449d3 2021-09-26 stsp
1487 088449d3 2021-09-26 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
1488 49c543a6 2022-03-31 naddy ret=$?
1489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1490 088449d3 2021-09-26 stsp echo "got checkout failed unexpectedly" >&2
1491 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1492 088449d3 2021-09-26 stsp return 1
1493 088449d3 2021-09-26 stsp fi
1494 088449d3 2021-09-26 stsp
1495 088449d3 2021-09-26 stsp # create a non-conflicting commit
1496 088449d3 2021-09-26 stsp (cd $testroot/repo && git checkout -q master)
1497 088449d3 2021-09-26 stsp echo "modified beta on master" > $testroot/repo/beta
1498 088449d3 2021-09-26 stsp git_commit $testroot/repo -m "committing to beta on master"
1499 088449d3 2021-09-26 stsp local master_commit=`git_show_head $testroot/repo`
1500 f259c4c1 2021-09-24 stsp
1501 5e91dae4 2022-08-30 stsp # need an up-to-date work tree for 'got merge'
1502 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > /dev/null)
1503 49c543a6 2022-03-31 naddy ret=$?
1504 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1505 088449d3 2021-09-26 stsp echo "got update failed unexpectedly" >&2
1506 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1507 088449d3 2021-09-26 stsp return 1
1508 088449d3 2021-09-26 stsp fi
1509 088449d3 2021-09-26 stsp
1510 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -n newbranch \
1511 088449d3 2021-09-26 stsp > $testroot/stdout 2> $testroot/stderr)
1512 49c543a6 2022-03-31 naddy ret=$?
1513 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1514 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1515 088449d3 2021-09-26 stsp test_done "$testroot" "1"
1516 088449d3 2021-09-26 stsp return 1
1517 088449d3 2021-09-26 stsp fi
1518 088449d3 2021-09-26 stsp
1519 088449d3 2021-09-26 stsp echo "G alpha" > $testroot/stdout.expected
1520 088449d3 2021-09-26 stsp echo "Merge of refs/heads/newbranch interrupted on request" \
1521 088449d3 2021-09-26 stsp >> $testroot/stdout.expected
1522 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1523 49c543a6 2022-03-31 naddy ret=$?
1524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1525 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1527 088449d3 2021-09-26 stsp return 1
1528 088449d3 2021-09-26 stsp fi
1529 088449d3 2021-09-26 stsp
1530 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1531 088449d3 2021-09-26 stsp
1532 088449d3 2021-09-26 stsp echo "M alpha" > $testroot/stdout.expected
1533 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1534 49c543a6 2022-03-31 naddy ret=$?
1535 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1536 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1537 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1538 088449d3 2021-09-26 stsp return 1
1539 088449d3 2021-09-26 stsp fi
1540 088449d3 2021-09-26 stsp
1541 088449d3 2021-09-26 stsp echo "modified alpha on branch" > $testroot/content.expected
1542 088449d3 2021-09-26 stsp cat $testroot/wt/alpha > $testroot/content
1543 088449d3 2021-09-26 stsp cmp -s $testroot/content.expected $testroot/content
1544 49c543a6 2022-03-31 naddy ret=$?
1545 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1546 088449d3 2021-09-26 stsp diff -u $testroot/content.expected $testroot/content
1547 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1548 088449d3 2021-09-26 stsp return 1
1549 088449d3 2021-09-26 stsp fi
1550 088449d3 2021-09-26 stsp
1551 088449d3 2021-09-26 stsp # adjust merge result
1552 088449d3 2021-09-26 stsp echo "adjusted merge result" > $testroot/wt/alpha
1553 088449d3 2021-09-26 stsp
1554 088449d3 2021-09-26 stsp # continue the merge
1555 088449d3 2021-09-26 stsp (cd $testroot/wt && got merge -c > $testroot/stdout)
1556 49c543a6 2022-03-31 naddy ret=$?
1557 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1558 088449d3 2021-09-26 stsp echo "got merge failed unexpectedly" >&2
1559 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1560 088449d3 2021-09-26 stsp return 1
1561 088449d3 2021-09-26 stsp fi
1562 088449d3 2021-09-26 stsp
1563 088449d3 2021-09-26 stsp local merge_commit=`git_show_head $testroot/repo`
1564 088449d3 2021-09-26 stsp
1565 0ff8d236 2021-09-28 stsp echo "M alpha" > $testroot/stdout.expected
1566 088449d3 2021-09-26 stsp echo -n "Merged refs/heads/newbranch into refs/heads/master: " \
1567 0ff8d236 2021-09-28 stsp >> $testroot/stdout.expected
1568 088449d3 2021-09-26 stsp echo $merge_commit >> $testroot/stdout.expected
1569 088449d3 2021-09-26 stsp
1570 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1571 49c543a6 2022-03-31 naddy ret=$?
1572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1573 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1574 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1575 088449d3 2021-09-26 stsp return 1
1576 088449d3 2021-09-26 stsp fi
1577 088449d3 2021-09-26 stsp
1578 088449d3 2021-09-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1579 088449d3 2021-09-26 stsp
1580 088449d3 2021-09-26 stsp echo -n > $testroot/stdout.expected
1581 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1582 49c543a6 2022-03-31 naddy ret=$?
1583 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1584 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1585 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1586 088449d3 2021-09-26 stsp return 1
1587 088449d3 2021-09-26 stsp fi
1588 088449d3 2021-09-26 stsp
1589 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1590 088449d3 2021-09-26 stsp echo "commit $merge_commit (master)" > $testroot/stdout.expected
1591 088449d3 2021-09-26 stsp echo "commit $master_commit" >> $testroot/stdout.expected
1592 088449d3 2021-09-26 stsp echo "commit $commit0" >> $testroot/stdout.expected
1593 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1594 49c543a6 2022-03-31 naddy ret=$?
1595 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1596 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1597 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1598 088449d3 2021-09-26 stsp return 1
1599 088449d3 2021-09-26 stsp fi
1600 088449d3 2021-09-26 stsp
1601 088449d3 2021-09-26 stsp (cd $testroot/wt && got update > $testroot/stdout)
1602 088449d3 2021-09-26 stsp
1603 088449d3 2021-09-26 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1604 088449d3 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 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1608 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1609 088449d3 2021-09-26 stsp return 1
1610 088449d3 2021-09-26 stsp fi
1611 088449d3 2021-09-26 stsp
1612 088449d3 2021-09-26 stsp # We should have created a merge commit with two parents.
1613 088449d3 2021-09-26 stsp (cd $testroot/wt && got log -l1 | grep ^parent > $testroot/stdout)
1614 088449d3 2021-09-26 stsp echo "parent 1: $master_commit" > $testroot/stdout.expected
1615 088449d3 2021-09-26 stsp echo "parent 2: $branch_commit0" >> $testroot/stdout.expected
1616 088449d3 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1617 49c543a6 2022-03-31 naddy ret=$?
1618 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1619 088449d3 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1620 088449d3 2021-09-26 stsp fi
1621 088449d3 2021-09-26 stsp test_done "$testroot" "$ret"
1622 b2b3fce1 2022-10-29 op }
1623 b2b3fce1 2022-10-29 op
1624 b2b3fce1 2022-10-29 op test_merge_umask() {
1625 b2b3fce1 2022-10-29 op local testroot=`test_init merge_umask`
1626 b2b3fce1 2022-10-29 op
1627 b2b3fce1 2022-10-29 op (cd $testroot/repo && git checkout -q -b newbranch)
1628 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/repo/alpha
1629 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1630 b2b3fce1 2022-10-29 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1631 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1632 b2b3fce1 2022-10-29 op
1633 b2b3fce1 2022-10-29 op # diverge from newbranch
1634 b2b3fce1 2022-10-29 op (cd "$testroot/repo" && git checkout -q master)
1635 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/repo/beta
1636 b2b3fce1 2022-10-29 op git_commit "$testroot/repo" -m "committing zeto no master"
1637 b2b3fce1 2022-10-29 op
1638 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1639 b2b3fce1 2022-10-29 op
1640 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1641 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got merge newbranch) >/dev/null
1642 b2b3fce1 2022-10-29 op
1643 b2b3fce1 2022-10-29 op for f in alpha gamma/delta; do
1644 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
1645 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1646 b2b3fce1 2022-10-29 op echo "$f is not 0600 after merge" >&2
1647 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
1648 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1649 b2b3fce1 2022-10-29 op fi
1650 b2b3fce1 2022-10-29 op done
1651 b2b3fce1 2022-10-29 op
1652 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1653 088449d3 2021-09-26 stsp }
1654 d51d11be 2023-02-21 op
1655 d51d11be 2023-02-21 op test_merge_gitconfig_author() {
1656 d51d11be 2023-02-21 op local testroot=`test_init merge_gitconfig_author`
1657 d51d11be 2023-02-21 op
1658 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.name 'Flan Luck')
1659 d51d11be 2023-02-21 op (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
1660 d51d11be 2023-02-21 op
1661 d51d11be 2023-02-21 op (cd $testroot/repo && git checkout -q -b newbranch)
1662 d51d11be 2023-02-21 op echo "modified alpha on branch" >$testroot/repo/alpha
1663 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing alpha on newbranch"
1664 d51d11be 2023-02-21 op echo "modified delta on branch" >$testroot/repo/gamma/delta
1665 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing delta on newbranch"
1666 088449d3 2021-09-26 stsp
1667 d51d11be 2023-02-21 op # diverge from newbranch
1668 d51d11be 2023-02-21 op (cd "$testroot/repo" && git checkout -q master)
1669 d51d11be 2023-02-21 op echo "modified beta on master" >$testroot/repo/beta
1670 d51d11be 2023-02-21 op git_commit "$testroot/repo" -m "committing zeto no master"
1671 d51d11be 2023-02-21 op
1672 d51d11be 2023-02-21 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1673 d51d11be 2023-02-21 op
1674 d51d11be 2023-02-21 op # unset in a subshell to avoid affecting our environment
1675 d51d11be 2023-02-21 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
1676 d51d11be 2023-02-21 op got merge newbranch > /dev/null)
1677 d51d11be 2023-02-21 op
1678 d51d11be 2023-02-21 op (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
1679 d51d11be 2023-02-21 op ret=$?
1680 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1681 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1682 d51d11be 2023-02-21 op return 1
1683 d51d11be 2023-02-21 op fi
1684 d51d11be 2023-02-21 op
1685 d51d11be 2023-02-21 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1686 d51d11be 2023-02-21 op > $testroot/stdout.expected
1687 d51d11be 2023-02-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1688 d51d11be 2023-02-21 op ret=$?
1689 d51d11be 2023-02-21 op if [ $ret -ne 0 ]; then
1690 d51d11be 2023-02-21 op diff -u $testroot/stdout.expected $testroot/stdout
1691 d51d11be 2023-02-21 op fi
1692 d51d11be 2023-02-21 op test_done "$testroot" "$ret"
1693 d51d11be 2023-02-21 op }
1694 d51d11be 2023-02-21 op
1695 f259c4c1 2021-09-24 stsp test_parseargs "$@"
1696 f259c4c1 2021-09-24 stsp run_test test_merge_basic
1697 179f9db0 2023-06-20 falsifian run_test test_merge_forward
1698 179f9db0 2023-06-20 falsifian run_test test_merge_backward
1699 f259c4c1 2021-09-24 stsp run_test test_merge_continue
1700 6b5246e4 2023-06-05 stsp run_test test_merge_continue_new_commit
1701 f259c4c1 2021-09-24 stsp run_test test_merge_abort
1702 f259c4c1 2021-09-24 stsp run_test test_merge_in_progress
1703 f259c4c1 2021-09-24 stsp run_test test_merge_path_prefix
1704 f259c4c1 2021-09-24 stsp run_test test_merge_missing_file
1705 a6a8f8bb 2021-09-24 stsp run_test test_merge_no_op
1706 4e91ef15 2021-09-26 stsp run_test test_merge_imported_branch
1707 088449d3 2021-09-26 stsp run_test test_merge_interrupt
1708 b2b3fce1 2022-10-29 op run_test test_merge_umask
1709 d51d11be 2023-02-21 op run_test test_merge_gitconfig_author