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