3 234035bc 2019-06-01 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 234035bc 2019-06-01 stsp # Permission to use, copy, modify, and distribute this software for any
6 234035bc 2019-06-01 stsp # purpose with or without fee is hereby granted, provided that the above
7 234035bc 2019-06-01 stsp # copyright notice and this permission notice appear in all copies.
9 234035bc 2019-06-01 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 234035bc 2019-06-01 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 234035bc 2019-06-01 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 234035bc 2019-06-01 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 234035bc 2019-06-01 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 234035bc 2019-06-01 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 234035bc 2019-06-01 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 234035bc 2019-06-01 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_cherrypick_basic() {
20 234035bc 2019-06-01 stsp local testroot=`test_init cherrypick_basic`
22 234035bc 2019-06-01 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
29 234035bc 2019-06-01 stsp (cd $testroot/repo && git checkout -q -b newbranch)
30 234035bc 2019-06-01 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
31 234035bc 2019-06-01 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
33 234035bc 2019-06-01 stsp echo "modified alpha on branch" > $testroot/repo/alpha
34 234035bc 2019-06-01 stsp (cd $testroot/repo && git rm -q beta)
35 234035bc 2019-06-01 stsp echo "new file on branch" > $testroot/repo/epsilon/new
36 234035bc 2019-06-01 stsp (cd $testroot/repo && git add epsilon/new)
37 234035bc 2019-06-01 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
39 234035bc 2019-06-01 stsp local branch_rev=`git_show_head $testroot/repo`
41 243a13f5 2021-09-02 stsp echo "modified new file on branch" > $testroot/repo/epsilon/new
42 243a13f5 2021-09-02 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
43 243a13f5 2021-09-02 stsp local branch_rev2=`git_show_head $testroot/repo`
45 234035bc 2019-06-01 stsp (cd $testroot/wt && got cherrypick $branch_rev > $testroot/stdout)
47 234035bc 2019-06-01 stsp echo "G alpha" > $testroot/stdout.expected
48 234035bc 2019-06-01 stsp echo "D beta" >> $testroot/stdout.expected
49 234035bc 2019-06-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
50 a7648d7a 2019-06-02 stsp echo "Merged commit $branch_rev" >> $testroot/stdout.expected
52 234035bc 2019-06-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
54 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
55 234035bc 2019-06-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
56 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
60 234035bc 2019-06-01 stsp echo "modified alpha on branch" > $testroot/content.expected
61 234035bc 2019-06-01 stsp cat $testroot/wt/alpha > $testroot/content
62 234035bc 2019-06-01 stsp cmp -s $testroot/content.expected $testroot/content
64 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
65 234035bc 2019-06-01 stsp diff -u $testroot/content.expected $testroot/content
66 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
70 234035bc 2019-06-01 stsp if [ -e $testroot/wt/beta ]; then
71 234035bc 2019-06-01 stsp echo "removed file beta still exists on disk" >&2
72 234035bc 2019-06-01 stsp test_done "$testroot" "1"
76 234035bc 2019-06-01 stsp echo "new file on branch" > $testroot/content.expected
77 234035bc 2019-06-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
78 234035bc 2019-06-01 stsp cmp -s $testroot/content.expected $testroot/content
80 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
81 234035bc 2019-06-01 stsp diff -u $testroot/content.expected $testroot/content
82 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
86 2b92fad7 2019-06-02 stsp echo 'M alpha' > $testroot/stdout.expected
87 2b92fad7 2019-06-02 stsp echo 'D beta' >> $testroot/stdout.expected
88 2b92fad7 2019-06-02 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
90 2b92fad7 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
92 2b92fad7 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
94 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
95 2b92fad7 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
96 243a13f5 2021-09-02 stsp test_done "$testroot" "$ret"
100 243a13f5 2021-09-02 stsp (cd $testroot/wt && got cherrypick $branch_rev2 > $testroot/stdout)
102 243a13f5 2021-09-02 stsp echo "G epsilon/new" > $testroot/stdout.expected
103 243a13f5 2021-09-02 stsp echo "Merged commit $branch_rev2" >> $testroot/stdout.expected
105 243a13f5 2021-09-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
108 243a13f5 2021-09-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
109 243a13f5 2021-09-02 stsp test_done "$testroot" "$ret"
113 243a13f5 2021-09-02 stsp echo 'M alpha' > $testroot/stdout.expected
114 243a13f5 2021-09-02 stsp echo 'D beta' >> $testroot/stdout.expected
115 243a13f5 2021-09-02 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
117 243a13f5 2021-09-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
119 243a13f5 2021-09-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
121 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
122 243a13f5 2021-09-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
127 f6cae3ed 2020-09-13 naddy test_cherrypick_root_commit() {
128 03415a1a 2019-06-02 stsp local testroot=`test_init cherrypick_root_commit`
130 03415a1a 2019-06-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
133 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
137 03415a1a 2019-06-02 stsp (cd $testroot/repo && git checkout -q -b newbranch)
138 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q alpha)
139 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q beta)
140 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
141 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q gamma/delta)
142 03415a1a 2019-06-02 stsp mkdir -p $testroot/repo/epsilon
143 03415a1a 2019-06-02 stsp echo "new file on branch" > $testroot/repo/epsilon/new
144 03415a1a 2019-06-02 stsp (cd $testroot/repo && git add epsilon/new)
145 03415a1a 2019-06-02 stsp git_commit $testroot/repo -m "committing on newbranch"
147 03415a1a 2019-06-02 stsp echo "modified new file on branch" >> $testroot/repo/epsilon/new
148 03415a1a 2019-06-02 stsp git_commit $testroot/repo -m "committing on newbranch again"
150 03415a1a 2019-06-02 stsp tree=`git_show_tree $testroot/repo`
151 03415a1a 2019-06-02 stsp root_commit=`git_commit_tree $testroot/repo "new root commit" $tree`
153 03415a1a 2019-06-02 stsp (cd $testroot/wt && got cherrypick $root_commit > $testroot/stdout)
155 03415a1a 2019-06-02 stsp echo "A epsilon/new" > $testroot/stdout.expected
156 a7648d7a 2019-06-02 stsp echo "Merged commit $root_commit" >> $testroot/stdout.expected
158 03415a1a 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
161 03415a1a 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
162 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
166 03415a1a 2019-06-02 stsp echo "new file on branch" > $testroot/content.expected
167 03415a1a 2019-06-02 stsp echo "modified new file on branch" >> $testroot/content.expected
168 03415a1a 2019-06-02 stsp cat $testroot/wt/epsilon/new > $testroot/content
169 03415a1a 2019-06-02 stsp cmp -s $testroot/content.expected $testroot/content
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 03415a1a 2019-06-02 stsp diff -u $testroot/content.expected $testroot/content
173 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
177 03415a1a 2019-06-02 stsp echo 'A epsilon/new' > $testroot/stdout.expected
179 03415a1a 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
181 03415a1a 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
184 03415a1a 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
186 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
189 f6cae3ed 2020-09-13 naddy test_cherrypick_into_work_tree_with_conflicts() {
190 ceb466a7 2020-04-18 stsp local testroot=`test_init cherrypick_into_work_tree_with_conflicts`
192 ceb466a7 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
195 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
199 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git checkout -q -b newbranch)
200 ceb466a7 2020-04-18 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
201 ceb466a7 2020-04-18 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
203 ceb466a7 2020-04-18 stsp echo "modified alpha on branch" > $testroot/repo/alpha
204 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git rm -q beta)
205 ceb466a7 2020-04-18 stsp echo "new file on branch" > $testroot/repo/epsilon/new
206 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git add epsilon/new)
207 ceb466a7 2020-04-18 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
209 ceb466a7 2020-04-18 stsp local branch_rev=`git_show_head $testroot/repo`
211 ceb466a7 2020-04-18 stsp # fake a merge conflict
212 ceb466a7 2020-04-18 stsp echo '<<<<<<<' > $testroot/wt/alpha
213 ceb466a7 2020-04-18 stsp echo 'alpha' >> $testroot/wt/alpha
214 ceb466a7 2020-04-18 stsp echo '=======' >> $testroot/wt/alpha
215 ceb466a7 2020-04-18 stsp echo 'alpha, too' >> $testroot/wt/alpha
216 ceb466a7 2020-04-18 stsp echo '>>>>>>>' >> $testroot/wt/alpha
217 ceb466a7 2020-04-18 stsp cp $testroot/wt/alpha $testroot/content.expected
219 ceb466a7 2020-04-18 stsp echo "C alpha" > $testroot/stdout.expected
220 ceb466a7 2020-04-18 stsp (cd $testroot/wt && got status > $testroot/stdout)
221 ceb466a7 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
223 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
224 ceb466a7 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
225 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
229 ceb466a7 2020-04-18 stsp (cd $testroot/wt && got cherrypick $branch_rev \
230 ceb466a7 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
232 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
233 ceb466a7 2020-04-18 stsp echo "cherrypick succeeded unexpectedly" >&2
234 ceb466a7 2020-04-18 stsp test_done "$testroot" "1"
238 ceb466a7 2020-04-18 stsp echo -n > $testroot/stdout.expected
239 ceb466a7 2020-04-18 stsp echo -n "got: work tree contains conflicted files; " \
240 ceb466a7 2020-04-18 stsp > $testroot/stderr.expected
241 ceb466a7 2020-04-18 stsp echo "these conflicts must be resolved first" \
242 ceb466a7 2020-04-18 stsp >> $testroot/stderr.expected
244 ceb466a7 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
246 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
247 ceb466a7 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
248 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
252 ceb466a7 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
254 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
255 ceb466a7 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
256 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
260 ceb466a7 2020-04-18 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
263 ceb466a7 2020-04-18 stsp diff -u $testroot/content.expected $testroot/wt/alpha
265 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
268 ed99f061 2021-09-03 stsp test_cherrypick_into_work_tree_with_mixed_commits() {
269 ed99f061 2021-09-03 stsp local testroot=`test_init cherrypick_into_work_tree_with_mixed_commits`
270 ed99f061 2021-09-03 stsp local first_rev=`git_show_head $testroot/repo`
272 ed99f061 2021-09-03 stsp echo "modified alpha" > $testroot/repo/alpha
273 5e91dae4 2022-08-30 stsp git_commit $testroot/repo -m "committing to alpha"
274 ed99f061 2021-09-03 stsp local second_rev=`git_show_head $testroot/repo`
276 ed99f061 2021-09-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
278 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
279 ed99f061 2021-09-03 stsp test_done "$testroot" "$ret"
283 ed99f061 2021-09-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
284 ed99f061 2021-09-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
285 ed99f061 2021-09-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
287 ed99f061 2021-09-03 stsp (cd $testroot/repo && git rm -q beta)
288 ed99f061 2021-09-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
289 ed99f061 2021-09-03 stsp (cd $testroot/repo && git add epsilon/new)
290 ed99f061 2021-09-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
292 ed99f061 2021-09-03 stsp local branch_rev=`git_show_head $testroot/repo`
294 ed99f061 2021-09-03 stsp (cd $testroot/wt && got update -c $first_rev alpha >/dev/null)
296 ed99f061 2021-09-03 stsp (cd $testroot/wt && got cherrypick $branch_rev \
297 ed99f061 2021-09-03 stsp > $testroot/stdout 2> $testroot/stderr)
299 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
300 ed99f061 2021-09-03 stsp echo "cherrypick succeeded unexpectedly" >&2
301 ed99f061 2021-09-03 stsp test_done "$testroot" "1"
305 ed99f061 2021-09-03 stsp echo -n > $testroot/stdout.expected
306 ed99f061 2021-09-03 stsp echo -n "got: work tree contains files from multiple base commits; " \
307 ed99f061 2021-09-03 stsp > $testroot/stderr.expected
308 ed99f061 2021-09-03 stsp echo "the entire work tree must be updated first" \
309 ed99f061 2021-09-03 stsp >> $testroot/stderr.expected
311 ed99f061 2021-09-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
313 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
314 ed99f061 2021-09-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
315 ed99f061 2021-09-03 stsp test_done "$testroot" "$ret"
319 ed99f061 2021-09-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
322 ed99f061 2021-09-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
324 ed99f061 2021-09-03 stsp test_done "$testroot" "$ret"
328 f6cae3ed 2020-09-13 naddy test_cherrypick_modified_submodule() {
329 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_modified_submodules`
331 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
333 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
334 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
335 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
337 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
339 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
340 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
342 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
343 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link on newbranch
344 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
345 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
346 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "modified submodule link"
347 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
349 e7303626 2020-05-14 stsp # This cherrypick is a no-op because Got's file index
350 e7303626 2020-05-14 stsp # does not track submodules.
351 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
353 e7303626 2020-05-14 stsp echo -n > $testroot/stdout.expected
354 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
357 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
359 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
362 f6cae3ed 2020-09-13 naddy test_cherrypick_added_submodule() {
363 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_added_submodules`
365 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
367 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
369 e7303626 2020-05-14 stsp # Add the repo/repo2 submodule on newbranch
370 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
371 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
372 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
373 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
374 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
376 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
378 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
379 e7303626 2020-05-14 stsp echo "Merged commit $commit_id" >> $testroot/stdout.expected
380 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
383 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
385 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
388 f6cae3ed 2020-09-13 naddy test_cherrypick_conflict_wt_file_vs_repo_submodule() {
389 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_conflict_wt_file_vs_repo_submodule`
391 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
393 e7303626 2020-05-14 stsp # Add a file which will clash with the submodule
394 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
395 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
396 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
399 e7303626 2020-05-14 stsp echo "commit failed unexpectedly" >&2
400 e7303626 2020-05-14 stsp test_done "$testroot" "1"
404 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
406 e7303626 2020-05-14 stsp # Add the repo/repo2 submodule on newbranch
407 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
408 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
409 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
410 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
411 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
413 e7303626 2020-05-14 stsp # Modify the clashing file such that any modifications brought
414 e7303626 2020-05-14 stsp # in by 'got cherrypick' would require a merge.
415 e7303626 2020-05-14 stsp echo "This file was changed" > $testroot/wt/repo2
417 e7303626 2020-05-14 stsp (cd $testroot/wt && got update >/dev/null)
418 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
420 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
421 e7303626 2020-05-14 stsp echo "Merged commit $commit_id" >> $testroot/stdout.expected
422 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
425 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
426 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
430 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
432 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
433 e7303626 2020-05-14 stsp echo "M repo2" >> $testroot/stdout.expected
434 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
436 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
437 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
442 f6cae3ed 2020-09-13 naddy test_cherrypick_modified_symlinks() {
443 af57b12a 2020-07-23 stsp local testroot=`test_init cherrypick_modified_symlinks`
445 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
446 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
447 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
448 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
449 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
450 af57b12a 2020-07-23 stsp (cd $testroot/repo && git add .)
451 af57b12a 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
452 af57b12a 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
454 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -R -c $commit_id1 \
455 5267b9e4 2021-09-26 stsp > $testroot/stdout
456 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
458 5267b9e4 2021-09-26 stsp alpha.link@ -> alpha
461 5267b9e4 2021-09-26 stsp epsilon/beta.link@ -> ../beta
462 5267b9e4 2021-09-26 stsp epsilon/zeta
463 5267b9e4 2021-09-26 stsp epsilon.link@ -> epsilon
465 5267b9e4 2021-09-26 stsp gamma/delta
466 5267b9e4 2021-09-26 stsp nonexistent.link@ -> nonexistent
467 5267b9e4 2021-09-26 stsp passwd.link@ -> /etc/passwd
469 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
472 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
477 af57b12a 2020-07-23 stsp got branch -r $testroot/repo foo
479 af57b12a 2020-07-23 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
481 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
482 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
483 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
484 5267b9e4 2021-09-26 stsp (cd $testroot/repo && ln -sf .got/foo $testroot/repo/dotgotfoo.link)
485 af57b12a 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
486 af57b12a 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
487 af57b12a 2020-07-23 stsp (cd $testroot/repo && git add .)
488 af57b12a 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
489 af57b12a 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
491 af57b12a 2020-07-23 stsp (cd $testroot/wt && got cherrypick $commit_id2 > $testroot/stdout)
493 af57b12a 2020-07-23 stsp echo "G alpha.link" > $testroot/stdout.expected
494 af57b12a 2020-07-23 stsp echo "G epsilon/beta.link" >> $testroot/stdout.expected
495 af57b12a 2020-07-23 stsp echo "A dotgotfoo.link" >> $testroot/stdout.expected
496 af57b12a 2020-07-23 stsp echo "G epsilon.link" >> $testroot/stdout.expected
497 af57b12a 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
498 af57b12a 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
499 af57b12a 2020-07-23 stsp echo "Merged commit $commit_id2" >> $testroot/stdout.expected
500 af57b12a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
502 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
503 af57b12a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
504 af57b12a 2020-07-23 stsp test_done "$testroot" "$ret"
508 af57b12a 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
509 af57b12a 2020-07-23 stsp echo "alpha.link is not a symlink"
510 af57b12a 2020-07-23 stsp test_done "$testroot" "1"
514 af57b12a 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
515 af57b12a 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
516 af57b12a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
518 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
519 af57b12a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
520 af57b12a 2020-07-23 stsp test_done "$testroot" "$ret"
524 5267b9e4 2021-09-26 stsp if ! [ -h $testroot/wt/dotgotfoo.link ]; then
525 5267b9e4 2021-09-26 stsp echo "dotgotfoo.link is not a symlink"
526 5267b9e4 2021-09-26 stsp test_done "$testroot" "1"
530 5267b9e4 2021-09-26 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
531 5267b9e4 2021-09-26 stsp echo ".got/foo" > $testroot/stdout.expected
532 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
534 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
535 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
536 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
540 af57b12a 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
541 af57b12a 2020-07-23 stsp echo "epsilon.link is not a symlink"
542 af57b12a 2020-07-23 stsp test_done "$testroot" "1"
546 af57b12a 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
547 af57b12a 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
548 af57b12a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
550 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
551 af57b12a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
552 af57b12a 2020-07-23 stsp test_done "$testroot" "$ret"
556 af57b12a 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
557 af57b12a 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
558 af57b12a 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
559 af57b12a 2020-07-23 stsp test_done "$testroot" "1"
563 af57b12a 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
564 af57b12a 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
566 af57b12a 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
568 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
569 af57b12a 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
570 af57b12a 2020-07-23 stsp test_done "$testroot" "$ret"
574 af57b12a 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
575 af57b12a 2020-07-23 stsp echo "../gamma/delta" > $testroot/stdout.expected
576 e26bafba 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
578 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
579 e26bafba 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
580 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
584 e26bafba 2020-07-23 stsp if [ -h $testroot/wt/nonexistent.link ]; then
585 e26bafba 2020-07-23 stsp echo -n "nonexistent.link still exists on disk: " >&2
586 e26bafba 2020-07-23 stsp readlink $testroot/wt/nonexistent.link >&2
587 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
591 5267b9e4 2021-09-26 stsp (cd $testroot/wt && got commit -m 'commit cherrypick result' \
592 5267b9e4 2021-09-26 stsp > /dev/null 2>$testroot/stderr)
594 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
595 5267b9e4 2021-09-26 stsp echo "got commit succeeded unexpectedly" >&2
596 a19f439c 2022-06-03 op test_done "$testroot" "1"
599 5267b9e4 2021-09-26 stsp echo -n "got: $testroot/wt/dotgotfoo.link: symbolic link points " \
600 5267b9e4 2021-09-26 stsp > $testroot/stderr.expected
601 5267b9e4 2021-09-26 stsp echo "outside of paths under version control" \
602 5267b9e4 2021-09-26 stsp >> $testroot/stderr.expected
603 5267b9e4 2021-09-26 stsp cmp -s $testroot/stderr.expected $testroot/stderr
605 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
606 5267b9e4 2021-09-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
607 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
611 5267b9e4 2021-09-26 stsp (cd $testroot/wt && got commit -S -m 'commit cherrypick result' \
612 5267b9e4 2021-09-26 stsp > /dev/null)
614 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
615 5267b9e4 2021-09-26 stsp echo "got commit failed unexpectedly" >&2
616 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
619 5267b9e4 2021-09-26 stsp local commit_id2=`git_show_head $testroot/repo`
621 5267b9e4 2021-09-26 stsp got tree -r $testroot/repo -R -c $commit_id2 \
622 5267b9e4 2021-09-26 stsp > $testroot/stdout
623 5267b9e4 2021-09-26 stsp cat > $testroot/stdout.expected <<EOF
625 5267b9e4 2021-09-26 stsp alpha.link@ -> beta
627 5267b9e4 2021-09-26 stsp dotgotfoo.link@ -> .got/foo
629 5267b9e4 2021-09-26 stsp epsilon/beta.link@ -> ../gamma/delta
630 5267b9e4 2021-09-26 stsp epsilon/zeta
631 5267b9e4 2021-09-26 stsp epsilon.link@ -> gamma
633 5267b9e4 2021-09-26 stsp gamma/delta
634 5267b9e4 2021-09-26 stsp passwd.link@ -> /etc/passwd
635 5267b9e4 2021-09-26 stsp zeta.link@ -> epsilon/zeta
637 5267b9e4 2021-09-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
639 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
640 5267b9e4 2021-09-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
642 5267b9e4 2021-09-26 stsp test_done "$testroot" "$ret"
645 f6cae3ed 2020-09-13 naddy test_cherrypick_symlink_conflicts() {
646 e26bafba 2020-07-23 stsp local testroot=`test_init cherrypick_symlink_conflicts`
648 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
649 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
650 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
651 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
652 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
653 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
654 e26bafba 2020-07-23 stsp (cd $testroot/repo && git add .)
655 e26bafba 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
656 e26bafba 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
658 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
659 fba9f79c 2020-07-23 stsp (cd $testroot/repo && ln -sf beta boo.link)
660 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
661 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
662 e26bafba 2020-07-23 stsp echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
663 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
664 e26bafba 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
665 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf gamma/delta zeta.link)
666 e26bafba 2020-07-23 stsp (cd $testroot/repo && ln -sf alpha new.link)
667 e26bafba 2020-07-23 stsp (cd $testroot/repo && git add .)
668 e26bafba 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
669 e26bafba 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
671 e26bafba 2020-07-23 stsp got branch -r $testroot/repo -c $commit_id1 foo
672 e26bafba 2020-07-23 stsp got checkout -b foo $testroot/repo $testroot/wt > /dev/null
674 e26bafba 2020-07-23 stsp # modified symlink to file A vs modified symlink to file B
675 e26bafba 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
676 e26bafba 2020-07-23 stsp # modified symlink to dir A vs modified symlink to file B
677 e26bafba 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
678 e26bafba 2020-07-23 stsp # modeified symlink to file A vs modified symlink to dir B
679 e26bafba 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
680 e26bafba 2020-07-23 stsp # added regular file A vs added bad symlink to file A
681 5267b9e4 2021-09-26 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
682 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
683 e26bafba 2020-07-23 stsp # added bad symlink to file A vs added regular file A
684 e26bafba 2020-07-23 stsp echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
685 d219f183 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
686 fba9f79c 2020-07-23 stsp # added symlink to file A vs unversioned file A
687 fba9f79c 2020-07-23 stsp echo 'this is unversioned file boo' > $testroot/wt/boo.link
688 e26bafba 2020-07-23 stsp # removed symlink to non-existent file A vs modified symlink
689 e26bafba 2020-07-23 stsp # to nonexistent file B
690 e26bafba 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
691 e26bafba 2020-07-23 stsp # modified symlink to file A vs removed symlink to file A
692 e26bafba 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
693 e26bafba 2020-07-23 stsp # added symlink to file A vs added symlink to file B
694 e26bafba 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
695 e26bafba 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
696 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m "change symlinks on foo" \
697 e26bafba 2020-07-23 stsp > /dev/null)
699 e26bafba 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
700 e26bafba 2020-07-23 stsp (cd $testroot/wt && got cherrypick $commit_id2 > $testroot/stdout)
702 e26bafba 2020-07-23 stsp echo -n > $testroot/stdout.expected
703 11cc08c1 2020-07-23 stsp echo "C alpha.link" >> $testroot/stdout.expected
704 11cc08c1 2020-07-23 stsp echo "C epsilon/beta.link" >> $testroot/stdout.expected
705 c90c8ce3 2020-07-23 stsp echo "? boo.link" >> $testroot/stdout.expected
706 11cc08c1 2020-07-23 stsp echo "C epsilon.link" >> $testroot/stdout.expected
707 fba9f79c 2020-07-23 stsp echo "C dotgotbar.link" >> $testroot/stdout.expected
708 3b9f0f87 2020-07-23 stsp echo "C dotgotfoo.link" >> $testroot/stdout.expected
709 e26bafba 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
710 e26bafba 2020-07-23 stsp echo "! zeta.link" >> $testroot/stdout.expected
711 11cc08c1 2020-07-23 stsp echo "C new.link" >> $testroot/stdout.expected
712 e26bafba 2020-07-23 stsp echo "Merged commit $commit_id2" >> $testroot/stdout.expected
713 3b9f0f87 2020-07-23 stsp echo "Files with new merge conflicts: 6" >> $testroot/stdout.expected
714 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
715 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
716 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
717 35ca1db7 2021-09-28 stsp echo -n "Files not merged because an unversioned file was found in " \
718 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
719 35ca1db7 2021-09-28 stsp echo "the work tree: 1" >> $testroot/stdout.expected
720 e26bafba 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
722 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
723 e26bafba 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
724 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
728 11cc08c1 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
729 11cc08c1 2020-07-23 stsp echo "alpha.link is a symlink"
730 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
734 11cc08c1 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
735 283102fc 2020-07-23 stsp > $testroot/content.expected
736 11cc08c1 2020-07-23 stsp echo "beta" >> $testroot/content.expected
737 11cc08c1 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
738 11cc08c1 2020-07-23 stsp >> $testroot/content.expected
739 11cc08c1 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
740 11cc08c1 2020-07-23 stsp echo "=======" >> $testroot/content.expected
741 11cc08c1 2020-07-23 stsp echo "gamma/delta" >> $testroot/content.expected
742 11cc08c1 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
743 11cc08c1 2020-07-23 stsp echo -n "" >> $testroot/content.expected
745 11cc08c1 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
746 fba9f79c 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
748 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
749 fba9f79c 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
750 fba9f79c 2020-07-23 stsp test_done "$testroot" "$ret"
754 c90c8ce3 2020-07-23 stsp if [ -h $testroot/wt/boo.link ]; then
755 c90c8ce3 2020-07-23 stsp echo "boo.link is a symlink"
756 fba9f79c 2020-07-23 stsp test_done "$testroot" "1"
760 c90c8ce3 2020-07-23 stsp echo "this is unversioned file boo" > $testroot/content.expected
761 fba9f79c 2020-07-23 stsp cp $testroot/wt/boo.link $testroot/content
762 11cc08c1 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
764 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
765 11cc08c1 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
766 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
770 11cc08c1 2020-07-23 stsp if [ -h $testroot/wt/epsilon.link ]; then
771 11cc08c1 2020-07-23 stsp echo "epsilon.link is a symlink"
772 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
776 11cc08c1 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
777 283102fc 2020-07-23 stsp > $testroot/content.expected
778 11cc08c1 2020-07-23 stsp echo "gamma" >> $testroot/content.expected
779 11cc08c1 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
780 11cc08c1 2020-07-23 stsp >> $testroot/content.expected
781 11cc08c1 2020-07-23 stsp echo "epsilon" >> $testroot/content.expected
782 11cc08c1 2020-07-23 stsp echo "=======" >> $testroot/content.expected
783 11cc08c1 2020-07-23 stsp echo "beta" >> $testroot/content.expected
784 11cc08c1 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
785 11cc08c1 2020-07-23 stsp echo -n "" >> $testroot/content.expected
787 11cc08c1 2020-07-23 stsp cp $testroot/wt/epsilon.link $testroot/content
788 11cc08c1 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
790 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
791 11cc08c1 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
792 af57b12a 2020-07-23 stsp test_done "$testroot" "$ret"
796 e26bafba 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
797 e26bafba 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
798 e26bafba 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
799 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
803 e26bafba 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
804 e26bafba 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
806 e26bafba 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
808 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
809 e26bafba 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
810 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
814 11cc08c1 2020-07-23 stsp if [ -h $testroot/wt/epsilon/beta.link ]; then
815 11cc08c1 2020-07-23 stsp echo "epsilon/beta.link is a symlink"
816 11cc08c1 2020-07-23 stsp test_done "$testroot" "1"
820 11cc08c1 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
821 283102fc 2020-07-23 stsp > $testroot/content.expected
822 11cc08c1 2020-07-23 stsp echo "../gamma/delta" >> $testroot/content.expected
823 11cc08c1 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
824 11cc08c1 2020-07-23 stsp >> $testroot/content.expected
825 11cc08c1 2020-07-23 stsp echo "../beta" >> $testroot/content.expected
826 11cc08c1 2020-07-23 stsp echo "=======" >> $testroot/content.expected
827 11cc08c1 2020-07-23 stsp echo "../gamma" >> $testroot/content.expected
828 11cc08c1 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
829 11cc08c1 2020-07-23 stsp echo -n "" >> $testroot/content.expected
831 11cc08c1 2020-07-23 stsp cp $testroot/wt/epsilon/beta.link $testroot/content
832 11cc08c1 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
834 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
835 11cc08c1 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
836 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
840 af57b12a 2020-07-23 stsp if [ -h $testroot/wt/nonexistent.link ]; then
841 af57b12a 2020-07-23 stsp echo -n "nonexistent.link still exists on disk: " >&2
842 af57b12a 2020-07-23 stsp readlink $testroot/wt/nonexistent.link >&2
843 af57b12a 2020-07-23 stsp test_done "$testroot" "1"
847 e26bafba 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
848 e26bafba 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
849 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
853 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
854 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
855 3b9f0f87 2020-07-23 stsp echo "this is regular file foo" >> $testroot/content.expected
856 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
857 5267b9e4 2021-09-26 stsp echo -n ".got/foo" >> $testroot/content.expected
858 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
859 e26bafba 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
860 e26bafba 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
862 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
863 e26bafba 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
864 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
868 e26bafba 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
869 e26bafba 2020-07-23 stsp echo "dotgotbar.link is a symlink"
870 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
873 d219f183 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
874 d219f183 2020-07-23 stsp > $testroot/content.expected
875 d219f183 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
876 d219f183 2020-07-23 stsp echo "=======" >> $testroot/content.expected
877 d219f183 2020-07-23 stsp echo "this is regular file bar" >> $testroot/content.expected
878 d219f183 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
879 d219f183 2020-07-23 stsp echo -n "" >> $testroot/content.expected
880 e26bafba 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
881 e26bafba 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
883 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
884 e26bafba 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
885 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
889 11cc08c1 2020-07-23 stsp if [ -h $testroot/wt/new.link ]; then
890 11cc08c1 2020-07-23 stsp echo "new.link is a symlink"
891 e26bafba 2020-07-23 stsp test_done "$testroot" "1"
895 11cc08c1 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
896 283102fc 2020-07-23 stsp > $testroot/content.expected
897 11cc08c1 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
898 11cc08c1 2020-07-23 stsp echo "=======" >> $testroot/content.expected
899 11cc08c1 2020-07-23 stsp echo "beta" >> $testroot/content.expected
900 11cc08c1 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
901 11cc08c1 2020-07-23 stsp echo -n "" >> $testroot/content.expected
903 11cc08c1 2020-07-23 stsp cp $testroot/wt/new.link $testroot/content
904 11cc08c1 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
906 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
907 11cc08c1 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
908 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
912 e26bafba 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
913 e26bafba 2020-07-23 stsp echo "M new.link" >> $testroot/stdout.expected
914 e26bafba 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
915 e26bafba 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
917 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
918 e26bafba 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
919 e26bafba 2020-07-23 stsp test_done "$testroot" "$ret"
923 af57b12a 2020-07-23 stsp test_done "$testroot" "0"
926 f6cae3ed 2020-09-13 naddy test_cherrypick_with_path_prefix_and_empty_tree() {
927 69d57f3d 2020-07-31 stsp local testroot=`test_init cherrypick_with_path_prefix_and_empty_tree 1`
929 69d57f3d 2020-07-31 stsp (cd $testroot/repo && git commit --allow-empty \
930 69d57f3d 2020-07-31 stsp -m "initial empty commit" >/dev/null)
932 69d57f3d 2020-07-31 stsp (cd $testroot/repo && got br bar >/dev/null)
934 69d57f3d 2020-07-31 stsp mkdir -p $testroot/repo/epsilon
935 69d57f3d 2020-07-31 stsp echo "file foo" > $testroot/repo/epsilon/foo
936 69d57f3d 2020-07-31 stsp (cd $testroot/repo && git add .)
937 69d57f3d 2020-07-31 stsp git_commit $testroot/repo -m "add file foo"
938 69d57f3d 2020-07-31 stsp local commit_id=`git_show_head $testroot/repo`
940 69d57f3d 2020-07-31 stsp got checkout -b bar $testroot/repo $testroot/wt > /dev/null
942 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
943 69d57f3d 2020-07-31 stsp echo "got checkout failed unexpectedly" >&2
944 69d57f3d 2020-07-31 stsp test_done "$testroot" "$ret"
948 69d57f3d 2020-07-31 stsp mkdir -p $testroot/wt/epsilon
949 69d57f3d 2020-07-31 stsp echo "new file" > $testroot/wt/epsilon/new
950 69d57f3d 2020-07-31 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
951 69d57f3d 2020-07-31 stsp (cd $testroot/wt && got commit -m "add file on branch bar" > /dev/null)
953 69d57f3d 2020-07-31 stsp got checkout -b bar -p epsilon $testroot/repo $testroot/wt2 > /dev/null
955 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
956 69d57f3d 2020-07-31 stsp echo "got checkout failed unexpectedly" >&2
957 69d57f3d 2020-07-31 stsp test_done "$testroot" "$ret"
960 69d57f3d 2020-07-31 stsp (cd $testroot/wt2 && got cherrypick $commit_id > $testroot/stdout)
962 69d57f3d 2020-07-31 stsp echo "A foo" > $testroot/stdout.expected
963 69d57f3d 2020-07-31 stsp echo "Merged commit $commit_id" >> $testroot/stdout.expected
965 cce854ad 2021-04-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 cce854ad 2021-04-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
970 cce854ad 2021-04-13 stsp test_done "$testroot" "$ret"
973 cce854ad 2021-04-13 stsp test_cherrypick_conflict_no_eol() {
974 cce854ad 2021-04-13 stsp local testroot=`test_init cherrypick_conflict_no_eol 1`
975 cce854ad 2021-04-13 stsp local content_a="aaa\naaa\naaa\naaa\naaa\naaa\n"
976 cce854ad 2021-04-13 stsp local content_b="aaa\naaa\nbbb\naaa\naaa\naaa\naaa"
977 cce854ad 2021-04-13 stsp local content_c="aaa\naaa\nccc\naaa\naaa\naaa\naaa"
979 cce854ad 2021-04-13 stsp printf "$content_a" > $testroot/repo/a
980 cce854ad 2021-04-13 stsp (cd $testroot/repo && git add a)
981 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "initial commit"
983 cce854ad 2021-04-13 stsp (cd $testroot/repo && got branch newbranch)
985 cce854ad 2021-04-13 stsp printf "$content_b" > $testroot/repo/a
986 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "change bbb"
988 cce854ad 2021-04-13 stsp printf "$content_c" > $testroot/repo/a
989 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "change ccc"
990 cce854ad 2021-04-13 stsp local ccc_commit=`git_show_head $testroot/repo`
992 cce854ad 2021-04-13 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
995 cce854ad 2021-04-13 stsp test_done "$testroot" "$ret"
999 cce854ad 2021-04-13 stsp (cd $testroot/wt && got cherrypick $ccc_commit > $testroot/stdout)
1001 cce854ad 2021-04-13 stsp echo "C a" > $testroot/stdout.expected
1002 cce854ad 2021-04-13 stsp echo "Merged commit $ccc_commit" >> $testroot/stdout.expected
1003 cce854ad 2021-04-13 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1005 69d57f3d 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1007 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1008 69d57f3d 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
1010 cce854ad 2021-04-13 stsp test_done "$testroot" "$ret"
1013 cce854ad 2021-04-13 stsp test_cherrypick_conflict_no_eol2() {
1014 cce854ad 2021-04-13 stsp local testroot=`test_init cherrypick_conflict_no_eol2 1`
1015 cce854ad 2021-04-13 stsp local content_a="aaa\naaa\naaa\naaa\naaa\naaa"
1016 cce854ad 2021-04-13 stsp local content_b="aaa\naaa\nbbb\naaa\naaa\naaa"
1017 cce854ad 2021-04-13 stsp local content_c="aaa\naaa\nbbb\naaa\naaa\naaa\n"
1019 cce854ad 2021-04-13 stsp printf "$content_a" > $testroot/repo/a
1020 cce854ad 2021-04-13 stsp (cd $testroot/repo && git add a)
1021 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "initial commit"
1023 cce854ad 2021-04-13 stsp (cd $testroot/repo && got branch newbranch)
1025 cce854ad 2021-04-13 stsp printf "$content_b" > $testroot/repo/a
1026 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "change bbb"
1028 cce854ad 2021-04-13 stsp printf "$content_c" > $testroot/repo/a
1029 cce854ad 2021-04-13 stsp git_commit $testroot/repo -m "change ccc"
1030 cce854ad 2021-04-13 stsp local ccc_commit=`git_show_head $testroot/repo`
1032 cce854ad 2021-04-13 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1034 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1035 cce854ad 2021-04-13 stsp test_done "$testroot" "$ret"
1039 cce854ad 2021-04-13 stsp (cd $testroot/wt && got cherrypick $ccc_commit \
1040 cce854ad 2021-04-13 stsp > $testroot/stdout 2> $testroot/stderr)
1042 cce854ad 2021-04-13 stsp echo "C a" > $testroot/stdout.expected
1043 cce854ad 2021-04-13 stsp echo "Merged commit $ccc_commit" >> $testroot/stdout.expected
1044 cce854ad 2021-04-13 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1046 cce854ad 2021-04-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1048 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1049 54d5be07 2021-06-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1051 3cd22b21 2021-05-31 stsp test_done "$testroot" "$ret"
1054 3cd22b21 2021-05-31 stsp test_cherrypick_unrelated_changes() {
1055 3cd22b21 2021-05-31 stsp local testroot=`test_init cherrypick_unrelated_changes`
1057 3cd22b21 2021-05-31 stsp # Sorry about the large HERE document but I have not found
1058 3cd22b21 2021-05-31 stsp # a smaller reproduction recipe yet...
1059 3cd22b21 2021-05-31 stsp cat > $testroot/repo/reference.c <<EOF
1060 3cd22b21 2021-05-31 stsp const struct got_error *
1061 3cd22b21 2021-05-31 stsp got_ref_alloc(struct got_reference **ref, const char *name,
1062 3cd22b21 2021-05-31 stsp struct got_object_id *id)
1064 3cd22b21 2021-05-31 stsp if (!is_valid_ref_name(name))
1065 3cd22b21 2021-05-31 stsp return got_error_path(name, GOT_ERR_BAD_REF_NAME);
1067 3cd22b21 2021-05-31 stsp return alloc_ref(ref, name, id, 0);
1070 3cd22b21 2021-05-31 stsp static const struct got_error *
1071 3cd22b21 2021-05-31 stsp parse_packed_ref_line(struct got_reference **ref, const char *abs_refname,
1072 3cd22b21 2021-05-31 stsp const char *line)
1074 3cd22b21 2021-05-31 stsp struct got_object_id id;
1075 3cd22b21 2021-05-31 stsp const char *name;
1077 3cd22b21 2021-05-31 stsp *ref = NULL;
1079 3cd22b21 2021-05-31 stsp if (line[0] == '#' || line[0] == '^')
1080 3cd22b21 2021-05-31 stsp return NULL;
1082 3cd22b21 2021-05-31 stsp if (!got_parse_sha1_digest(id.sha1, line))
1083 3cd22b21 2021-05-31 stsp return got_error(GOT_ERR_BAD_REF_DATA);
1085 3cd22b21 2021-05-31 stsp if (abs_refname) {
1086 3cd22b21 2021-05-31 stsp if (strcmp(line + SHA1_DIGEST_STRING_LENGTH, abs_refname) != 0)
1087 3cd22b21 2021-05-31 stsp return NULL;
1088 3cd22b21 2021-05-31 stsp name = abs_refname;
1090 3cd22b21 2021-05-31 stsp name = line + SHA1_DIGEST_STRING_LENGTH;
1092 3cd22b21 2021-05-31 stsp return alloc_ref(ref, name, &id, GOT_REF_IS_PACKED);
1095 3cd22b21 2021-05-31 stsp static const struct got_error *
1096 3cd22b21 2021-05-31 stsp open_packed_ref(struct got_reference **ref, FILE *f, const char **subdirs,
1097 3cd22b21 2021-05-31 stsp int nsubdirs, const char *refname)
1099 3cd22b21 2021-05-31 stsp const struct got_error *err = NULL;
1100 3cd22b21 2021-05-31 stsp char *abs_refname;
1101 3cd22b21 2021-05-31 stsp char *line = NULL;
1102 3cd22b21 2021-05-31 stsp size_t linesize = 0;
1103 3cd22b21 2021-05-31 stsp ssize_t linelen;
1104 3cd22b21 2021-05-31 stsp int i, ref_is_absolute = (strncmp(refname, "refs/", 5) == 0);
1106 3cd22b21 2021-05-31 stsp *ref = NULL;
1108 3cd22b21 2021-05-31 stsp if (ref_is_absolute)
1109 3cd22b21 2021-05-31 stsp abs_refname = (char *)refname;
1111 3cd22b21 2021-05-31 stsp linelen = getline(&line, &linesize, f);
1112 3cd22b21 2021-05-31 stsp if (linelen == -1) {
1113 3cd22b21 2021-05-31 stsp if (feof(f))
1115 3cd22b21 2021-05-31 stsp err = got_ferror(f, GOT_ERR_BAD_REF_DATA);
1118 3cd22b21 2021-05-31 stsp if (linelen > 0 && line[linelen - 1] == '\n')
1119 3cd22b21 2021-05-31 stsp line[linelen - 1] = '\0';
1120 3cd22b21 2021-05-31 stsp for (i = 0; i < nsubdirs; i++) {
1121 3cd22b21 2021-05-31 stsp if (!ref_is_absolute &&
1122 3cd22b21 2021-05-31 stsp asprintf(&abs_refname, "refs/%s/%s", subdirs[i],
1123 3cd22b21 2021-05-31 stsp refname) == -1)
1124 3cd22b21 2021-05-31 stsp return got_error_from_errno("asprintf");
1125 3cd22b21 2021-05-31 stsp err = parse_packed_ref_line(ref, abs_refname, line);
1126 3cd22b21 2021-05-31 stsp if (!ref_is_absolute)
1127 3cd22b21 2021-05-31 stsp free(abs_refname);
1128 3cd22b21 2021-05-31 stsp if (err || *ref != NULL)
1133 3cd22b21 2021-05-31 stsp } while (*ref == NULL);
1134 3cd22b21 2021-05-31 stsp free(line);
1136 3cd22b21 2021-05-31 stsp return err;
1139 3cd22b21 2021-05-31 stsp static const struct got_error *
1140 3cd22b21 2021-05-31 stsp open_ref(struct got_reference **ref, const char *path_refs, const char *subdir,
1141 3cd22b21 2021-05-31 stsp const char *name, int lock)
1143 3cd22b21 2021-05-31 stsp const struct got_error *err = NULL;
1144 3cd22b21 2021-05-31 stsp char *path = NULL;
1145 3cd22b21 2021-05-31 stsp char *absname = NULL;
1146 3cd22b21 2021-05-31 stsp int ref_is_absolute = (strncmp(name, "refs/", 5) == 0);
1147 3cd22b21 2021-05-31 stsp int ref_is_well_known = (subdir[0] == '\0' && is_well_known_ref(name));
1149 3cd22b21 2021-05-31 stsp *ref = NULL;
1151 3cd22b21 2021-05-31 stsp if (ref_is_absolute || ref_is_well_known) {
1152 3cd22b21 2021-05-31 stsp if (asprintf(&path, "%s/%s", path_refs, name) == -1)
1153 3cd22b21 2021-05-31 stsp return got_error_from_errno("asprintf");
1154 3cd22b21 2021-05-31 stsp absname = (char *)name;
1156 3cd22b21 2021-05-31 stsp if (asprintf(&path, "%s/%s%s%s", path_refs, subdir,
1157 3cd22b21 2021-05-31 stsp subdir[0] ? "/" : "", name) == -1)
1158 3cd22b21 2021-05-31 stsp return got_error_from_errno("asprintf");
1160 3cd22b21 2021-05-31 stsp if (asprintf(&absname, "refs/%s%s%s",
1161 3cd22b21 2021-05-31 stsp subdir, subdir[0] ? "/" : "", name) == -1) {
1162 3cd22b21 2021-05-31 stsp err = got_error_from_errno("asprintf");
1163 3cd22b21 2021-05-31 stsp goto done;
1167 3cd22b21 2021-05-31 stsp err = parse_ref_file(ref, name, absname, path, lock);
1169 3cd22b21 2021-05-31 stsp if (!ref_is_absolute && !ref_is_well_known)
1170 3cd22b21 2021-05-31 stsp free(absname);
1171 3cd22b21 2021-05-31 stsp free(path);
1172 3cd22b21 2021-05-31 stsp return err;
1175 3cd22b21 2021-05-31 stsp const struct got_error *
1176 3cd22b21 2021-05-31 stsp got_ref_open(struct got_reference **ref, struct got_repository *repo,
1177 3cd22b21 2021-05-31 stsp const char *refname, int lock)
1179 3cd22b21 2021-05-31 stsp const struct got_error *err = NULL;
1180 3cd22b21 2021-05-31 stsp char *path_refs = NULL;
1181 3cd22b21 2021-05-31 stsp const char *subdirs[] = {
1182 3cd22b21 2021-05-31 stsp GOT_REF_HEADS, GOT_REF_TAGS, GOT_REF_REMOTES
1185 3cd22b21 2021-05-31 stsp int well_known = is_well_known_ref(refname);
1186 3cd22b21 2021-05-31 stsp struct got_lockfile *lf = NULL;
1188 3cd22b21 2021-05-31 stsp *ref = NULL;
1190 3cd22b21 2021-05-31 stsp path_refs = get_refs_dir_path(repo, refname);
1191 3cd22b21 2021-05-31 stsp if (path_refs == NULL) {
1192 3cd22b21 2021-05-31 stsp err = got_error_from_errno2("get_refs_dir_path", refname);
1193 3cd22b21 2021-05-31 stsp goto done;
1196 3cd22b21 2021-05-31 stsp if (well_known) {
1197 3cd22b21 2021-05-31 stsp err = open_ref(ref, path_refs, "", refname, lock);
1199 3cd22b21 2021-05-31 stsp char *packed_refs_path;
1202 3cd22b21 2021-05-31 stsp /* Search on-disk refs before packed refs! */
1203 3cd22b21 2021-05-31 stsp for (i = 0; i < nitems(subdirs); i++) {
1204 3cd22b21 2021-05-31 stsp err = open_ref(ref, path_refs, subdirs[i], refname,
1206 3cd22b21 2021-05-31 stsp if ((err && err->code != GOT_ERR_NOT_REF) || *ref)
1207 3cd22b21 2021-05-31 stsp goto done;
1210 3cd22b21 2021-05-31 stsp packed_refs_path = got_repo_get_path_packed_refs(repo);
1211 3cd22b21 2021-05-31 stsp if (packed_refs_path == NULL) {
1212 3cd22b21 2021-05-31 stsp err = got_error_from_errno(
1213 3cd22b21 2021-05-31 stsp "got_repo_get_path_packed_refs");
1214 3cd22b21 2021-05-31 stsp goto done;
1217 3cd22b21 2021-05-31 stsp if (lock) {
1218 3cd22b21 2021-05-31 stsp err = got_lockfile_lock(&lf, packed_refs_path);
1220 3cd22b21 2021-05-31 stsp goto done;
1222 3cd22b21 2021-05-31 stsp f = fopen(packed_refs_path, "rb");
1223 3cd22b21 2021-05-31 stsp free(packed_refs_path);
1224 3cd22b21 2021-05-31 stsp if (f != NULL) {
1225 3cd22b21 2021-05-31 stsp err = open_packed_ref(ref, f, subdirs, nitems(subdirs),
1227 3cd22b21 2021-05-31 stsp if (!err) {
1228 3cd22b21 2021-05-31 stsp if (fclose(f) == EOF) {
1229 3cd22b21 2021-05-31 stsp err = got_error_from_errno("fclose");
1230 3cd22b21 2021-05-31 stsp got_ref_close(*ref);
1231 3cd22b21 2021-05-31 stsp *ref = NULL;
1232 3cd22b21 2021-05-31 stsp } else if (*ref)
1233 3cd22b21 2021-05-31 stsp (*ref)->lf = lf;
1238 3cd22b21 2021-05-31 stsp if (!err && *ref == NULL)
1239 3cd22b21 2021-05-31 stsp err = got_error_not_ref(refname);
1240 3cd22b21 2021-05-31 stsp if (err && lf)
1241 3cd22b21 2021-05-31 stsp got_lockfile_unlock(lf);
1242 3cd22b21 2021-05-31 stsp free(path_refs);
1243 3cd22b21 2021-05-31 stsp return err;
1246 3cd22b21 2021-05-31 stsp struct got_reference *
1247 3cd22b21 2021-05-31 stsp got_ref_dup(struct got_reference *ref)
1249 3cd22b21 2021-05-31 stsp struct got_reference *ret;
1251 3cd22b21 2021-05-31 stsp ret = calloc(1, sizeof(*ret));
1252 3cd22b21 2021-05-31 stsp if (ret == NULL)
1253 3cd22b21 2021-05-31 stsp return NULL;
1255 3cd22b21 2021-05-31 stsp ret->flags = ref->flags;
1256 3cd22b21 2021-05-31 stsp if (ref->flags & GOT_REF_IS_SYMBOLIC) {
1257 3cd22b21 2021-05-31 stsp ret->ref.symref.name = strdup(ref->ref.symref.name);
1258 3cd22b21 2021-05-31 stsp if (ret->ref.symref.name == NULL) {
1259 3cd22b21 2021-05-31 stsp free(ret);
1260 3cd22b21 2021-05-31 stsp return NULL;
1262 3cd22b21 2021-05-31 stsp ret->ref.symref.ref = strdup(ref->ref.symref.ref);
1263 3cd22b21 2021-05-31 stsp if (ret->ref.symref.ref == NULL) {
1264 3cd22b21 2021-05-31 stsp free(ret->ref.symref.name);
1265 3cd22b21 2021-05-31 stsp free(ret);
1266 3cd22b21 2021-05-31 stsp return NULL;
1269 3cd22b21 2021-05-31 stsp ret->ref.ref.name = strdup(ref->ref.ref.name);
1270 3cd22b21 2021-05-31 stsp if (ret->ref.ref.name == NULL) {
1271 3cd22b21 2021-05-31 stsp free(ret);
1272 3cd22b21 2021-05-31 stsp return NULL;
1274 3cd22b21 2021-05-31 stsp memcpy(ret->ref.ref.sha1, ref->ref.ref.sha1,
1275 3cd22b21 2021-05-31 stsp sizeof(ret->ref.ref.sha1));
1278 3cd22b21 2021-05-31 stsp return ret;
1281 3cd22b21 2021-05-31 stsp const struct got_error *
1282 3cd22b21 2021-05-31 stsp got_reflist_entry_dup(struct got_reflist_entry **newp,
1283 3cd22b21 2021-05-31 stsp struct got_reflist_entry *re)
1285 3cd22b21 2021-05-31 stsp const struct got_error *err = NULL;
1286 3cd22b21 2021-05-31 stsp struct got_reflist_entry *new;
1288 3cd22b21 2021-05-31 stsp *newp = NULL;
1290 3cd22b21 2021-05-31 stsp new = malloc(sizeof(*new));
1291 3cd22b21 2021-05-31 stsp if (new == NULL)
1292 3cd22b21 2021-05-31 stsp return got_error_from_errno("malloc");
1294 3cd22b21 2021-05-31 stsp new->ref = got_ref_dup(re->ref);
1295 3cd22b21 2021-05-31 stsp if (new->ref == NULL) {
1296 3cd22b21 2021-05-31 stsp err = got_error_from_errno("got_ref_dup");
1297 3cd22b21 2021-05-31 stsp free(new);
1298 3cd22b21 2021-05-31 stsp return err;
1301 3cd22b21 2021-05-31 stsp *newp = new;
1302 3cd22b21 2021-05-31 stsp return NULL;
1306 3cd22b21 2021-05-31 stsp got_ref_list_free(struct got_reflist_head *refs)
1308 3cd22b21 2021-05-31 stsp struct got_reflist_entry *re;
1310 3cd22b21 2021-05-31 stsp while ((re = TAILQ_FIRST(refs))) {
1311 3cd22b21 2021-05-31 stsp TAILQ_REMOVE(refs, re, entry);
1316 3cd22b21 2021-05-31 stsp (cd $testroot/repo && git add reference.c)
1317 3cd22b21 2021-05-31 stsp git_commit $testroot/repo -m "added reference.c file"
1318 3cd22b21 2021-05-31 stsp local base_commit=`git_show_head $testroot/repo`
1320 3cd22b21 2021-05-31 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1322 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1323 3cd22b21 2021-05-31 stsp test_done "$testroot" "$ret"
1327 3cd22b21 2021-05-31 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1328 3cd22b21 2021-05-31 stsp ed -s $testroot/repo/reference.c <<EOF
1330 3cd22b21 2021-05-31 stsp if (!is_valid_ref_name(name))
1331 3cd22b21 2021-05-31 stsp return got_error_path(name, GOT_ERR_BAD_REF_NAME);
1337 3cd22b21 2021-05-31 stsp git_commit $testroot/repo -m "added lines on newbranch"
1338 3cd22b21 2021-05-31 stsp local branch_rev1=`git_show_head $testroot/repo`
1340 3cd22b21 2021-05-31 stsp ed -s $testroot/repo/reference.c <<EOF
1342 3cd22b21 2021-05-31 stsp got_ref_close(re->ref);
1347 3cd22b21 2021-05-31 stsp git_commit $testroot/repo -m "more lines on newbranch"
1349 3cd22b21 2021-05-31 stsp local branch_rev2=`git_show_head $testroot/repo`
1351 3cd22b21 2021-05-31 stsp (cd $testroot/wt && got cherrypick $branch_rev2 > $testroot/stdout)
1353 3cd22b21 2021-05-31 stsp echo "G reference.c" > $testroot/stdout.expected
1354 3cd22b21 2021-05-31 stsp echo "Merged commit $branch_rev2" >> $testroot/stdout.expected
1356 3cd22b21 2021-05-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1358 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1359 3cd22b21 2021-05-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
1360 3cd22b21 2021-05-31 stsp test_done "$testroot" "$ret"
1364 3cd22b21 2021-05-31 stsp cat > $testroot/diff.expected <<EOF
1365 3cd22b21 2021-05-31 stsp --- reference.c
1366 3cd22b21 2021-05-31 stsp +++ reference.c
1367 3cd22b21 2021-05-31 stsp @@ -250,6 +250,7 @@ got_ref_list_free(struct got_reflist_head *refs)
1369 3cd22b21 2021-05-31 stsp while ((re = TAILQ_FIRST(refs))) {
1370 3cd22b21 2021-05-31 stsp TAILQ_REMOVE(refs, re, entry);
1371 3cd22b21 2021-05-31 stsp + got_ref_close(re->ref);
1376 3cd22b21 2021-05-31 stsp (cd $testroot/wt && got diff |
1377 8469d821 2022-06-25 stsp egrep -v '^(diff|blob|file|commit|path)' > $testroot/diff)
1378 3cd22b21 2021-05-31 stsp cmp -s $testroot/diff.expected $testroot/diff
1380 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1381 54d5be07 2021-06-03 stsp diff -u $testroot/diff.expected $testroot/diff
1384 0baddd91 2021-09-03 stsp test_done "$testroot" "$ret"
1387 0baddd91 2021-09-03 stsp test_cherrypick_same_branch() {
1388 0baddd91 2021-09-03 stsp local testroot=`test_init cherrypick_same_branch`
1390 0baddd91 2021-09-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1392 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1393 0baddd91 2021-09-03 stsp test_done "$testroot" "$ret"
1397 0baddd91 2021-09-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1398 0baddd91 2021-09-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1399 0baddd91 2021-09-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1401 0baddd91 2021-09-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1402 0baddd91 2021-09-03 stsp (cd $testroot/repo && git rm -q beta)
1403 0baddd91 2021-09-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1404 0baddd91 2021-09-03 stsp (cd $testroot/repo && git add epsilon/new)
1405 0baddd91 2021-09-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1407 0baddd91 2021-09-03 stsp local branch_rev=`git_show_head $testroot/repo`
1409 0baddd91 2021-09-03 stsp # picking a commit from the branch's own history does not make
1410 0baddd91 2021-09-03 stsp # sense but we should have test coverage for this case regardless
1411 0baddd91 2021-09-03 stsp (cd $testroot/wt && got up -b newbranch > /dev/null)
1412 0baddd91 2021-09-03 stsp (cd $testroot/wt && got cherrypick $branch_rev > $testroot/stdout)
1414 0baddd91 2021-09-03 stsp echo "G alpha" > $testroot/stdout.expected
1415 0baddd91 2021-09-03 stsp echo "! beta" >> $testroot/stdout.expected
1416 0baddd91 2021-09-03 stsp echo "G epsilon/new" >> $testroot/stdout.expected
1417 0baddd91 2021-09-03 stsp echo "Merged commit $branch_rev" >> $testroot/stdout.expected
1418 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1419 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1420 35ca1db7 2021-09-28 stsp echo "in the work tree: 1" >> $testroot/stdout.expected
1422 0baddd91 2021-09-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1425 0baddd91 2021-09-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1427 69d57f3d 2020-07-31 stsp test_done "$testroot" "$ret"
1430 c1e86b1d 2021-10-08 stsp test_cherrypick_dot_on_a_line_by_itself() {
1431 c1e86b1d 2021-10-08 stsp local testroot=`test_init cherrypick_dot_on_a_line_by_itself`
1433 c1e86b1d 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1435 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1436 c1e86b1d 2021-10-08 stsp test_done "$testroot" "$ret"
1440 c1e86b1d 2021-10-08 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1441 f10244c0 2021-10-11 stsp printf "modified\n:delta\n.\non\n:branch\n" > $testroot/repo/gamma/delta
1442 c1e86b1d 2021-10-08 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1443 c1e86b1d 2021-10-08 stsp local branch_rev=`git_show_head $testroot/repo`
1445 c1e86b1d 2021-10-08 stsp (cd $testroot/wt && got cherrypick newbranch > $testroot/stdout)
1447 c1e86b1d 2021-10-08 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1448 c1e86b1d 2021-10-08 stsp echo "Merged commit $branch_rev" >> $testroot/stdout.expected
1450 c1e86b1d 2021-10-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1453 c1e86b1d 2021-10-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1454 c1e86b1d 2021-10-08 stsp test_done "$testroot" "$ret"
1458 f10244c0 2021-10-11 stsp printf "modified\n:delta\n.\non\n:branch\n" > $testroot/content.expected
1459 c1e86b1d 2021-10-08 stsp cat $testroot/wt/gamma/delta > $testroot/content
1460 c1e86b1d 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
1462 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1463 f10244c0 2021-10-11 stsp diff -u $testroot/content.expected $testroot/content
1465 c1e86b1d 2021-10-08 stsp test_done "$testroot" "$ret"
1468 0e039681 2021-11-15 stsp test_cherrypick_binary_file() {
1469 0e039681 2021-11-15 stsp local testroot=`test_init cherrypick_binary_file`
1470 0e039681 2021-11-15 stsp local commit_id0=`git_show_head $testroot/repo`
1472 0e039681 2021-11-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1474 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1475 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1479 0e039681 2021-11-15 stsp cp /bin/ls $testroot/wt/foo
1480 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
1481 0e039681 2021-11-15 stsp (cd $testroot/wt && got add foo >/dev/null)
1482 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
1483 0e039681 2021-11-15 stsp local commit_id1=`git_show_head $testroot/repo`
1485 0e039681 2021-11-15 stsp cp /bin/cat $testroot/wt/foo
1486 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
1487 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
1488 0e039681 2021-11-15 stsp local commit_id2=`git_show_head $testroot/repo`
1490 0e039681 2021-11-15 stsp cp /bin/cp $testroot/wt/foo
1491 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
1492 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
1493 0e039681 2021-11-15 stsp local commit_id3=`git_show_head $testroot/repo`
1495 0e039681 2021-11-15 stsp (cd $testroot/wt && got rm foo >/dev/null)
1496 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
1497 0e039681 2021-11-15 stsp local commit_id4=`git_show_head $testroot/repo`
1499 0e039681 2021-11-15 stsp # backdate the work tree to make it usable for cherry-picking
1500 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
1502 0e039681 2021-11-15 stsp # cherry-pick addition of a binary file
1503 0e039681 2021-11-15 stsp (cd $testroot/wt && got cy $commit_id1 > $testroot/stdout)
1505 0e039681 2021-11-15 stsp echo "A foo" > $testroot/stdout.expected
1506 0e039681 2021-11-15 stsp echo "Merged commit $commit_id1" >> $testroot/stdout.expected
1508 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1511 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1512 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1516 0e039681 2021-11-15 stsp cp /bin/ls $testroot/content.expected
1517 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
1518 0e039681 2021-11-15 stsp cp $testroot/wt/foo $testroot/content
1519 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1521 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1522 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1523 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1527 0e039681 2021-11-15 stsp # cherry-pick modification of a binary file
1528 0e039681 2021-11-15 stsp (cd $testroot/wt && got cy $commit_id2 > $testroot/stdout)
1530 0e039681 2021-11-15 stsp echo "G foo" > $testroot/stdout.expected
1531 0e039681 2021-11-15 stsp echo "Merged commit $commit_id2" >> $testroot/stdout.expected
1533 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1535 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1536 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1537 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1541 0e039681 2021-11-15 stsp cp /bin/cat $testroot/content.expected
1542 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
1543 0e039681 2021-11-15 stsp cp $testroot/wt/foo $testroot/content
1544 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1546 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1547 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1548 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1552 0e039681 2021-11-15 stsp # cherry-pick conflicting addition of a binary file
1553 0e039681 2021-11-15 stsp (cd $testroot/wt && got cy $commit_id1 > $testroot/stdout)
1555 0e039681 2021-11-15 stsp echo "C foo" > $testroot/stdout.expected
1556 0e039681 2021-11-15 stsp echo "Merged commit $commit_id1" >> $testroot/stdout.expected
1557 0e039681 2021-11-15 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1559 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1561 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1562 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1563 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1567 0e039681 2021-11-15 stsp echo "Binary files differ and cannot be merged automatically:" \
1568 0e039681 2021-11-15 stsp > $testroot/content.expected
1569 0e039681 2021-11-15 stsp echo "<<<<<<< merged change: commit $commit_id1" \
1570 0e039681 2021-11-15 stsp >> $testroot/content.expected
1571 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
1572 0e039681 2021-11-15 stsp ls $testroot/wt/foo-1-* >> $testroot/content.expected
1573 0e039681 2021-11-15 stsp echo '=======' >> $testroot/content.expected
1574 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
1575 0e039681 2021-11-15 stsp ls $testroot/wt/foo-2-* >> $testroot/content.expected
1576 0e039681 2021-11-15 stsp echo '>>>>>>>' >> $testroot/content.expected
1577 0e039681 2021-11-15 stsp cp $testroot/wt/foo $testroot/content
1578 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1580 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1581 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1582 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1586 0e039681 2021-11-15 stsp # revert local changes to allow further testing
1587 0e039681 2021-11-15 stsp (cd $testroot/wt && got revert -R . >/dev/null)
1589 0e039681 2021-11-15 stsp (cd $testroot/wt && got status > $testroot/stdout)
1590 0e039681 2021-11-15 stsp echo '? foo' > $testroot/stdout.expected
1591 0e039681 2021-11-15 stsp echo -n '? ' >> $testroot/stdout.expected
1592 0e039681 2021-11-15 stsp (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
1593 0e039681 2021-11-15 stsp echo -n '? ' >> $testroot/stdout.expected
1594 0e039681 2021-11-15 stsp (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
1595 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1597 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1598 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1599 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1604 0e039681 2021-11-15 stsp rm $testroot/wt/foo $testroot/wt/foo-1-* $testroot/wt/foo-2-*
1605 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
1607 0e039681 2021-11-15 stsp # cherry-pick conflicting modification of a binary file
1608 0e039681 2021-11-15 stsp (cd $testroot/wt && got cy $commit_id3 > $testroot/stdout)
1610 0e039681 2021-11-15 stsp echo "C foo" > $testroot/stdout.expected
1611 0e039681 2021-11-15 stsp echo "Merged commit $commit_id3" >> $testroot/stdout.expected
1612 0e039681 2021-11-15 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1614 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1616 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1617 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1618 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1622 0e039681 2021-11-15 stsp echo "Binary files differ and cannot be merged automatically:" \
1623 0e039681 2021-11-15 stsp > $testroot/content.expected
1624 0e039681 2021-11-15 stsp echo '<<<<<<<' >> $testroot/content.expected
1625 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
1626 0e039681 2021-11-15 stsp ls $testroot/wt/foo-1-* >> $testroot/content.expected
1627 0e039681 2021-11-15 stsp echo "||||||| 3-way merge base: commit $commit_id2" \
1628 0e039681 2021-11-15 stsp >> $testroot/content.expected
1629 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
1630 0e039681 2021-11-15 stsp ls $testroot/wt/foo-orig-* >> $testroot/content.expected
1631 0e039681 2021-11-15 stsp echo '=======' >> $testroot/content.expected
1632 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
1633 0e039681 2021-11-15 stsp ls $testroot/wt/foo-2-* >> $testroot/content.expected
1634 0e039681 2021-11-15 stsp echo ">>>>>>> merged change: commit $commit_id3" \
1635 0e039681 2021-11-15 stsp >> $testroot/content.expected
1636 0e039681 2021-11-15 stsp cp $testroot/wt/foo $testroot/content
1637 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1639 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1640 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1641 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1645 0e039681 2021-11-15 stsp cp /bin/ls $testroot/content.expected
1646 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
1647 0e039681 2021-11-15 stsp cat $testroot/wt/foo-1-* > $testroot/content
1648 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1650 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1651 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1652 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1656 0e039681 2021-11-15 stsp cp /bin/cp $testroot/content.expected
1657 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
1658 0e039681 2021-11-15 stsp cat $testroot/wt/foo-2-* > $testroot/content
1659 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
1661 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1662 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
1663 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1667 0e039681 2021-11-15 stsp # revert local changes to allow further testing
1668 0e039681 2021-11-15 stsp (cd $testroot/wt && got revert -R . > /dev/null)
1669 0e039681 2021-11-15 stsp rm $testroot/wt/foo-1-*
1670 0e039681 2021-11-15 stsp rm $testroot/wt/foo-2-*
1671 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id3 > /dev/null)
1673 0e039681 2021-11-15 stsp # cherry-pick deletion of a binary file
1674 0e039681 2021-11-15 stsp (cd $testroot/wt && got cy $commit_id4 > $testroot/stdout)
1676 0e039681 2021-11-15 stsp echo "D foo" > $testroot/stdout.expected
1677 0e039681 2021-11-15 stsp echo "Merged commit $commit_id4" >> $testroot/stdout.expected
1679 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1681 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1682 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
1683 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
1687 0e039681 2021-11-15 stsp if [ -e $testroot/wt/foo ]; then
1688 0e039681 2021-11-15 stsp echo "removed file foo still exists on disk" >&2
1689 0e039681 2021-11-15 stsp test_done "$testroot" "1"
1692 0e039681 2021-11-15 stsp test_done "$testroot" "0"
1695 b2b3fce1 2022-10-29 op test_cherrypick_umask() {
1696 b2b3fce1 2022-10-29 op local testroot=`test_init cherrypick_umask`
1698 b2b3fce1 2022-10-29 op got checkout $testroot/repo $testroot/wt >/dev/null
1700 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1701 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1705 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got branch newbranch) >/dev/null
1706 b2b3fce1 2022-10-29 op echo "modified alpha on branch" > $testroot/wt/alpha
1707 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit alpha') >/dev/null
1708 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -b master) >/dev/null
1710 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1711 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got cherrypick newbranch) >/dev/null
1713 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1714 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1718 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1719 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after cherrypick!" >&2
1720 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1721 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1725 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1728 22d6be81 2023-01-28 mark test_cherrypick_logmsg_ref() {
1729 22d6be81 2023-01-28 mark local testroot=`test_init cherrypick_logmsg_ref`
1731 22d6be81 2023-01-28 mark got checkout $testroot/repo $testroot/wt > /dev/null
1733 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1734 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1738 22d6be81 2023-01-28 mark (cd $testroot/repo && git checkout -q -b newbranch)
1740 22d6be81 2023-01-28 mark echo "modified delta on branch" > $testroot/repo/gamma/delta
1741 22d6be81 2023-01-28 mark echo "modified alpha on branch" > $testroot/repo/alpha
1742 22d6be81 2023-01-28 mark (cd $testroot/repo && git rm -q beta)
1743 22d6be81 2023-01-28 mark echo "new file on branch" > $testroot/repo/epsilon/new
1744 22d6be81 2023-01-28 mark (cd $testroot/repo && git add epsilon/new)
1746 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit changes on newbranch"
1747 22d6be81 2023-01-28 mark local commit_time=`git_show_author_time $testroot/repo`
1748 22d6be81 2023-01-28 mark local branch_rev=`git_show_head $testroot/repo`
1750 22d6be81 2023-01-28 mark echo "modified new file on branch" > $testroot/repo/epsilon/new
1752 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit modified new file on newbranch"
1753 22d6be81 2023-01-28 mark local commit_time2=`git_show_author_time $testroot/repo`
1754 22d6be81 2023-01-28 mark local branch_rev2=`git_show_head $testroot/repo`
1756 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1757 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1759 22d6be81 2023-01-28 mark # show all log message refs in the work tree
1760 22d6be81 2023-01-28 mark local sep="-----------------------------------------------"
1761 22d6be81 2023-01-28 mark local logmsg="commit changes on newbranch"
1762 22d6be81 2023-01-28 mark local changeset=" M alpha\n D beta\n A epsilon/new\n M gamma/delta"
1763 22d6be81 2023-01-28 mark local logmsg2="commit modified new file on newbranch"
1764 22d6be81 2023-01-28 mark local changeset2=" M epsilon/new"
1765 22d6be81 2023-01-28 mark local date=`date -u -r $commit_time +"%a %b %e %X %Y UTC"`
1766 22d6be81 2023-01-28 mark local date2=`date -u -r $commit_time2 +"%a %b %e %X %Y UTC"`
1767 22d6be81 2023-01-28 mark local ymd=`date -u -r $commit_time +"%F"`
1768 22d6be81 2023-01-28 mark local short_id=$(printf '%.7s' $branch_rev)
1769 22d6be81 2023-01-28 mark local ymd2=`date -u -r $commit_time2 +"%F"`
1770 22d6be81 2023-01-28 mark local short_id2="newbranch"
1771 466be138 2023-02-01 mark local wt_sorted=$(printf "$branch_rev\n$branch_rev2" | sort)
1773 466be138 2023-02-01 mark for r in $wt_sorted; do
1774 22d6be81 2023-01-28 mark echo $sep >> $testroot/stdout.expected
1775 22d6be81 2023-01-28 mark if [ $r == $branch_rev ]; then
1776 b584caa3 2023-01-30 mark echo "cherrypick $r" >> $testroot/stdout.expected
1777 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1778 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
1779 22d6be81 2023-01-28 mark printf " \n $logmsg\n \n" >> $testroot/stdout.expected
1780 22d6be81 2023-01-28 mark printf "$changeset\n\n" >> $testroot/stdout.expected
1782 22d6be81 2023-01-28 mark # for forthcoming wt 'cherrypick -X' test
1783 378a2540 2023-01-28 stsp echo "Deleted: $ymd $short_id $logmsg" >> \
1784 22d6be81 2023-01-28 mark $testroot/stdout.wt_deleted
1786 b584caa3 2023-01-30 mark echo "cherrypick $r (newbranch)" \
1787 22d6be81 2023-01-28 mark >> $testroot/stdout.expected
1788 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1789 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
1790 22d6be81 2023-01-28 mark printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
1791 22d6be81 2023-01-28 mark printf "$changeset2\n\n" >> $testroot/stdout.expected
1793 22d6be81 2023-01-28 mark # for forthcoming wt 'cherrypick -X' test
1794 378a2540 2023-01-28 stsp echo "Deleted: $ymd2 $short_id2 $logmsg2" >> \
1795 22d6be81 2023-01-28 mark $testroot/stdout.wt_deleted
1799 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
1801 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1803 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1804 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1805 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1809 22d6be81 2023-01-28 mark # only show log message ref of the specified commit id
1810 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
1811 b584caa3 2023-01-30 mark echo "cherrypick $branch_rev" >> $testroot/stdout.expected
1812 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1813 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
1814 22d6be81 2023-01-28 mark printf " \n $logmsg\n \n" >> $testroot/stdout.expected
1815 22d6be81 2023-01-28 mark printf "$changeset\n\n" >> $testroot/stdout.expected
1817 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick -l $branch_rev > $testroot/stdout)
1819 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1821 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1822 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1823 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1827 22d6be81 2023-01-28 mark # only show log message ref of the specified symref
1828 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
1829 b584caa3 2023-01-30 mark echo "cherrypick $branch_rev2 (newbranch)" >> $testroot/stdout.expected
1830 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1831 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
1832 22d6be81 2023-01-28 mark printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
1833 22d6be81 2023-01-28 mark printf "$changeset2\n\n" >> $testroot/stdout.expected
1835 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick -l "newbranch" > $testroot/stdout)
1837 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1839 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1840 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1841 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1845 22d6be81 2023-01-28 mark # create a second work tree with cherrypicked commits and ensure
1846 22d6be81 2023-01-28 mark # cy -l within the new work tree only shows the refs it created
1847 22d6be81 2023-01-28 mark got checkout $testroot/repo $testroot/wt2 > /dev/null
1849 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1850 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1854 22d6be81 2023-01-28 mark (cd $testroot/repo && git checkout -q -b newbranch2)
1856 22d6be81 2023-01-28 mark echo "modified delta on branch2" > $testroot/repo/gamma/delta
1857 22d6be81 2023-01-28 mark echo "modified alpha on branch2" > $testroot/repo/alpha
1858 22d6be81 2023-01-28 mark echo "new file on branch2" > $testroot/repo/epsilon/new2
1859 22d6be81 2023-01-28 mark (cd $testroot/repo && git add epsilon/new2)
1861 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit changes on newbranch2"
1862 22d6be81 2023-01-28 mark local b2_commit_time=`git_show_author_time $testroot/repo`
1863 22d6be81 2023-01-28 mark local branch2_rev=`git_show_head $testroot/repo`
1865 22d6be81 2023-01-28 mark echo "modified file new2 on branch2" > $testroot/repo/epsilon/new2
1867 22d6be81 2023-01-28 mark git_commit $testroot/repo -m "commit modified file new2 on newbranch2"
1868 22d6be81 2023-01-28 mark local b2_commit_time2=`git_show_author_time $testroot/repo`
1869 22d6be81 2023-01-28 mark local branch2_rev2=`git_show_head $testroot/repo`
1871 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got cherrypick $branch2_rev > /dev/null)
1872 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got cherrypick $branch2_rev2 > /dev/null)
1874 22d6be81 2023-01-28 mark local b2_logmsg="commit changes on newbranch2"
1875 22d6be81 2023-01-28 mark local b2_changeset=" M alpha\n A epsilon/new2\n M gamma/delta"
1876 22d6be81 2023-01-28 mark local b2_logmsg2="commit modified file new2 on newbranch2"
1877 22d6be81 2023-01-28 mark local b2_changeset2=" M epsilon/new2"
1878 22d6be81 2023-01-28 mark date=`date -u -r $b2_commit_time +"%a %b %e %X %Y UTC"`
1879 22d6be81 2023-01-28 mark date2=`date -u -r $b2_commit_time2 +"%a %b %e %X %Y UTC"`
1880 466be138 2023-02-01 mark local wt2_sorted=$(printf "$branch2_rev\n$branch2_rev2" | sort)
1882 22d6be81 2023-01-28 mark echo -n > $testroot/stdout.expected
1883 466be138 2023-02-01 mark for r in $wt2_sorted; do
1884 22d6be81 2023-01-28 mark echo $sep >> $testroot/stdout.expected
1885 22d6be81 2023-01-28 mark if [ $r == $branch2_rev ]; then
1886 b584caa3 2023-01-30 mark echo "cherrypick $r" >> $testroot/stdout.expected
1887 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1888 22d6be81 2023-01-28 mark echo "date: $date" >> $testroot/stdout.expected
1889 22d6be81 2023-01-28 mark printf " \n $b2_logmsg\n \n" >> \
1890 22d6be81 2023-01-28 mark $testroot/stdout.expected
1891 22d6be81 2023-01-28 mark printf "$b2_changeset\n\n" >> \
1892 22d6be81 2023-01-28 mark $testroot/stdout.expected
1894 b584caa3 2023-01-30 mark echo "cherrypick $r (newbranch2)" \
1895 22d6be81 2023-01-28 mark >> $testroot/stdout.expected
1896 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1897 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
1898 22d6be81 2023-01-28 mark printf " \n $b2_logmsg2\n \n" >> \
1899 22d6be81 2023-01-28 mark $testroot/stdout.expected
1900 22d6be81 2023-01-28 mark printf "$b2_changeset2\n\n" >> \
1901 22d6be81 2023-01-28 mark $testroot/stdout.expected
1905 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got cherrypick -l > $testroot/stdout)
1907 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1909 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1910 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1911 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1915 466be138 2023-02-01 mark # ensure both wt and wt2 logmsg refs can be retrieved and the
1916 466be138 2023-02-01 mark # work tree UUID is displayed when listing refs from the repo
1917 466be138 2023-02-01 mark local wt_uuid=$(cat $testroot/wt/.got/uuid)
1918 466be138 2023-02-01 mark local wt2_uuid=$(cat $testroot/wt2/.got/uuid)
1919 466be138 2023-02-01 mark local wt_first=`printf "$wt_uuid\n$wt2_uuid" | sort | head -1`
1921 466be138 2023-02-01 mark for r in $wt_sorted; do
1922 466be138 2023-02-01 mark echo -n "cherrypick $r" >> $testroot/wt.list
1923 466be138 2023-02-01 mark if [ $r == $branch_rev2 ]; then
1924 466be138 2023-02-01 mark echo -n " (newbranch)" >> $testroot/wt.list
1926 466be138 2023-02-01 mark echo >> $testroot/wt.list
1927 466be138 2023-02-01 mark echo "work tree: $wt_uuid" >> $testroot/wt.list
1930 466be138 2023-02-01 mark for r in $wt2_sorted; do
1931 466be138 2023-02-01 mark echo -n "cherrypick $r" >> $testroot/wt2.list
1932 466be138 2023-02-01 mark if [ $r == $branch2_rev2 ]; then
1933 466be138 2023-02-01 mark echo -n " (newbranch2)" >> $testroot/wt2.list
1935 466be138 2023-02-01 mark echo >> $testroot/wt2.list
1936 466be138 2023-02-01 mark echo "work tree: $wt2_uuid" >> $testroot/wt2.list
1939 466be138 2023-02-01 mark if [ $wt_uuid == $wt_first ]; then
1940 466be138 2023-02-01 mark mv $testroot/wt.list $testroot/stdout.expected
1941 466be138 2023-02-01 mark cat $testroot/wt2.list >> $testroot/stdout.expected
1943 466be138 2023-02-01 mark mv $testroot/wt2.list $testroot/stdout.expected
1944 466be138 2023-02-01 mark cat $testroot/wt.list >> $testroot/stdout.expected
1947 466be138 2023-02-01 mark (cd $testroot/repo && got cherrypick -l | egrep "^(cherrypick|work)" \
1948 466be138 2023-02-01 mark > $testroot/stdout)
1950 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1952 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1953 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1954 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1958 22d6be81 2023-01-28 mark # delete logmsg ref of the specified commit in work tree 2
1959 22d6be81 2023-01-28 mark ymd=`date -u -r $b2_commit_time +"%F"`
1960 22d6be81 2023-01-28 mark short_id=$(printf '%.7s' $branch2_rev)
1962 378a2540 2023-01-28 stsp echo "Deleted: $ymd $short_id $b2_logmsg" > $testroot/stdout.expected
1963 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got cherrypick -X $branch2_rev > $testroot/stdout)
1965 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1967 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1968 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1969 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1973 22d6be81 2023-01-28 mark # delete all logmsg refs in work tree 1
1974 22d6be81 2023-01-28 mark (cd $testroot && mv stdout.wt_deleted stdout.expected)
1975 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick -X > $testroot/stdout)
1977 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1979 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1980 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1981 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1985 22d6be81 2023-01-28 mark # confirm all work tree 1 refs were deleted
1986 22d6be81 2023-01-28 mark echo -n > $testroot/stdout.expected
1987 22d6be81 2023-01-28 mark (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
1989 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
1991 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
1992 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
1993 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
1997 22d6be81 2023-01-28 mark # make sure the remaining ref in work tree 2 was not also deleted
1998 22d6be81 2023-01-28 mark echo $sep > $testroot/stdout.expected
1999 b584caa3 2023-01-30 mark echo "cherrypick $branch2_rev2 (newbranch2)" \
2000 b584caa3 2023-01-30 mark >> $testroot/stdout.expected
2001 22d6be81 2023-01-28 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
2002 22d6be81 2023-01-28 mark echo "date: $date2" >> $testroot/stdout.expected
2003 22d6be81 2023-01-28 mark printf " \n $b2_logmsg2\n \n" >> $testroot/stdout.expected
2004 22d6be81 2023-01-28 mark printf "$b2_changeset2\n\n" >> $testroot/stdout.expected
2006 22d6be81 2023-01-28 mark (cd $testroot/wt2 && got cherrypick -l > $testroot/stdout)
2008 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
2010 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
2011 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
2012 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
2016 22d6be81 2023-01-28 mark # ensure we can delete work tree refs from the repository dir
2017 22d6be81 2023-01-28 mark ymd=`date -u -r $b2_commit_time2 +"%F"`
2018 378a2540 2023-01-28 stsp echo "Deleted: $ymd newbranch2 $b2_logmsg2" > $testroot/stdout.expected
2019 22d6be81 2023-01-28 mark (cd $testroot/repo && got cherrypick -X > $testroot/stdout)
2021 22d6be81 2023-01-28 mark cmp -s $testroot/stdout.expected $testroot/stdout
2023 22d6be81 2023-01-28 mark if [ $ret -ne 0 ]; then
2024 22d6be81 2023-01-28 mark diff -u $testroot/stdout.expected $testroot/stdout
2027 22d6be81 2023-01-28 mark test_done "$testroot" "$ret"
2030 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2031 234035bc 2019-06-01 stsp run_test test_cherrypick_basic
2032 03415a1a 2019-06-02 stsp run_test test_cherrypick_root_commit
2033 ceb466a7 2020-04-18 stsp run_test test_cherrypick_into_work_tree_with_conflicts
2034 ed99f061 2021-09-03 stsp run_test test_cherrypick_into_work_tree_with_mixed_commits
2035 e7303626 2020-05-14 stsp run_test test_cherrypick_modified_submodule
2036 e7303626 2020-05-14 stsp run_test test_cherrypick_added_submodule
2037 e7303626 2020-05-14 stsp run_test test_cherrypick_conflict_wt_file_vs_repo_submodule
2038 af57b12a 2020-07-23 stsp run_test test_cherrypick_modified_symlinks
2039 e26bafba 2020-07-23 stsp run_test test_cherrypick_symlink_conflicts
2040 69d57f3d 2020-07-31 stsp run_test test_cherrypick_with_path_prefix_and_empty_tree
2041 cce854ad 2021-04-13 stsp run_test test_cherrypick_conflict_no_eol
2042 cce854ad 2021-04-13 stsp run_test test_cherrypick_conflict_no_eol2
2043 3cd22b21 2021-05-31 stsp run_test test_cherrypick_unrelated_changes
2044 0baddd91 2021-09-03 stsp run_test test_cherrypick_same_branch
2045 c1e86b1d 2021-10-08 stsp run_test test_cherrypick_dot_on_a_line_by_itself
2046 0e039681 2021-11-15 stsp run_test test_cherrypick_binary_file
2047 b2b3fce1 2022-10-29 op run_test test_cherrypick_umask
2048 22d6be81 2023-01-28 mark run_test test_cherrypick_logmsg_ref