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