Blame


1 5ef14e63 2019-06-02 stsp #!/bin/sh
2 5ef14e63 2019-06-02 stsp #
3 5ef14e63 2019-06-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 5ef14e63 2019-06-02 stsp #
5 5ef14e63 2019-06-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 5ef14e63 2019-06-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 5ef14e63 2019-06-02 stsp # copyright notice and this permission notice appear in all copies.
8 5ef14e63 2019-06-02 stsp #
9 5ef14e63 2019-06-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 5ef14e63 2019-06-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 5ef14e63 2019-06-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 5ef14e63 2019-06-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 5ef14e63 2019-06-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 5ef14e63 2019-06-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 5ef14e63 2019-06-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 5ef14e63 2019-06-02 stsp
17 5ef14e63 2019-06-02 stsp . ./common.sh
18 5ef14e63 2019-06-02 stsp
19 f6cae3ed 2020-09-13 naddy test_backout_basic() {
20 5ef14e63 2019-06-02 stsp local testroot=`test_init backout_basic`
21 5ef14e63 2019-06-02 stsp
22 5ef14e63 2019-06-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
25 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
26 5ef14e63 2019-06-02 stsp return 1
27 5ef14e63 2019-06-02 stsp fi
28 5ef14e63 2019-06-02 stsp
29 5bda3ef8 2020-02-09 stsp echo "new" > $testroot/wt/new
30 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got add new > /dev/null)
31 5ef14e63 2019-06-02 stsp echo "modified alpha" > $testroot/wt/alpha
32 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
33 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "bad changes" > /dev/null)
34 5ef14e63 2019-06-02 stsp
35 5ef14e63 2019-06-02 stsp local bad_commit=`git_show_head $testroot/repo`
36 5ef14e63 2019-06-02 stsp
37 5ef14e63 2019-06-02 stsp
38 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
39 5ef14e63 2019-06-02 stsp
40 5ef14e63 2019-06-02 stsp echo "modified beta" > $testroot/wt/beta
41 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got commit -m "changing beta" > /dev/null)
42 5ef14e63 2019-06-02 stsp
43 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got update > /dev/null)
44 5ef14e63 2019-06-02 stsp
45 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
46 5ef14e63 2019-06-02 stsp
47 5ef14e63 2019-06-02 stsp echo "G alpha" > $testroot/stdout.expected
48 5bda3ef8 2020-02-09 stsp echo "A epsilon/zeta" >> $testroot/stdout.expected
49 5bda3ef8 2020-02-09 stsp echo "D new" >> $testroot/stdout.expected
50 a7648d7a 2019-06-02 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
51 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
52 fc414659 2022-04-16 thomas ret=$?
53 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
54 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
55 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
56 5ef14e63 2019-06-02 stsp return 1
57 5ef14e63 2019-06-02 stsp fi
58 5ef14e63 2019-06-02 stsp
59 5ef14e63 2019-06-02 stsp echo "alpha" > $testroot/content.expected
60 5ef14e63 2019-06-02 stsp cat $testroot/wt/alpha > $testroot/content
61 5ef14e63 2019-06-02 stsp cmp -s $testroot/content.expected $testroot/content
62 fc414659 2022-04-16 thomas ret=$?
63 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
64 5ef14e63 2019-06-02 stsp diff -u $testroot/content.expected $testroot/content
65 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
66 5ef14e63 2019-06-02 stsp return 1
67 5ef14e63 2019-06-02 stsp fi
68 5ef14e63 2019-06-02 stsp
69 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/new" ]; then
70 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/new' still exists on disk" >&2
71 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
72 5bda3ef8 2020-02-09 stsp return 1
73 5bda3ef8 2020-02-09 stsp fi
74 5bda3ef8 2020-02-09 stsp
75 5bda3ef8 2020-02-09 stsp if [ ! -e "$testroot/wt/epsilon/zeta" ]; then
76 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/epsilon/zeta' is missing on disk" >&2
77 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
78 5bda3ef8 2020-02-09 stsp return 1
79 5bda3ef8 2020-02-09 stsp fi
80 5bda3ef8 2020-02-09 stsp
81 5ef14e63 2019-06-02 stsp echo 'M alpha' > $testroot/stdout.expected
82 5bda3ef8 2020-02-09 stsp echo 'A epsilon/zeta' >> $testroot/stdout.expected
83 5bda3ef8 2020-02-09 stsp echo 'D new' >> $testroot/stdout.expected
84 5ef14e63 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
85 5ef14e63 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
86 fc414659 2022-04-16 thomas ret=$?
87 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
88 5ef14e63 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
89 5ef14e63 2019-06-02 stsp fi
90 5ef14e63 2019-06-02 stsp test_done "$testroot" "$ret"
91 5ef14e63 2019-06-02 stsp }
92 5ef14e63 2019-06-02 stsp
93 f6cae3ed 2020-09-13 naddy test_backout_edits_for_file_since_deleted() {
94 5bda3ef8 2020-02-09 stsp local testroot=`test_init backout_edits_for_file_since_deleted`
95 5bda3ef8 2020-02-09 stsp
96 5bda3ef8 2020-02-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
97 fc414659 2022-04-16 thomas ret=$?
98 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
99 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
100 5bda3ef8 2020-02-09 stsp return 1
101 5bda3ef8 2020-02-09 stsp fi
102 5bda3ef8 2020-02-09 stsp
103 5bda3ef8 2020-02-09 stsp echo "modified alpha" > $testroot/wt/alpha
104 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "changing alpha" > /dev/null)
105 5bda3ef8 2020-02-09 stsp
106 5bda3ef8 2020-02-09 stsp local bad_commit=`git_show_head $testroot/repo`
107 5bda3ef8 2020-02-09 stsp
108 5bda3ef8 2020-02-09 stsp
109 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update > /dev/null)
110 5bda3ef8 2020-02-09 stsp
111 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm alpha > /dev/null)
112 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "removing alpha" > /dev/null)
113 5bda3ef8 2020-02-09 stsp
114 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update > /dev/null)
115 5bda3ef8 2020-02-09 stsp
116 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
117 5bda3ef8 2020-02-09 stsp
118 5bda3ef8 2020-02-09 stsp echo "! alpha" > $testroot/stdout.expected
119 5bda3ef8 2020-02-09 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
120 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
121 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
122 0ef68859 2021-09-28 thomas echo "in the work tree: 1" >> $testroot/stdout.expected
123 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
124 fc414659 2022-04-16 thomas ret=$?
125 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
126 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
128 5bda3ef8 2020-02-09 stsp return 1
129 5bda3ef8 2020-02-09 stsp fi
130 5bda3ef8 2020-02-09 stsp
131 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/alpha" ]; then
132 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/alpha' still exists on disk" >&2
133 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
134 5bda3ef8 2020-02-09 stsp return 1
135 5bda3ef8 2020-02-09 stsp fi
136 5bda3ef8 2020-02-09 stsp
137 5bda3ef8 2020-02-09 stsp echo -n '' > $testroot/stdout.expected
138 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got status > $testroot/stdout)
139 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
140 fc414659 2022-04-16 thomas ret=$?
141 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
142 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
143 5bda3ef8 2020-02-09 stsp fi
144 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
145 5bda3ef8 2020-02-09 stsp }
146 5bda3ef8 2020-02-09 stsp
147 f6cae3ed 2020-09-13 naddy test_backout_next_commit() {
148 5bda3ef8 2020-02-09 stsp local testroot=`test_init backout_next_commit`
149 5bda3ef8 2020-02-09 stsp local commit0=`git_show_head $testroot/repo`
150 5bda3ef8 2020-02-09 stsp
151 5bda3ef8 2020-02-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
152 fc414659 2022-04-16 thomas ret=$?
153 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
154 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
155 5bda3ef8 2020-02-09 stsp return 1
156 5bda3ef8 2020-02-09 stsp fi
157 5bda3ef8 2020-02-09 stsp
158 5bda3ef8 2020-02-09 stsp echo "new" > $testroot/wt/new
159 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got add new > /dev/null)
160 5bda3ef8 2020-02-09 stsp echo "modified alpha" > $testroot/wt/alpha
161 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
162 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got commit -m "bad changes" > /dev/null)
163 5bda3ef8 2020-02-09 stsp
164 5bda3ef8 2020-02-09 stsp local bad_commit=`git_show_head $testroot/repo`
165 5bda3ef8 2020-02-09 stsp
166 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got update -c $commit0 > /dev/null)
167 5bda3ef8 2020-02-09 stsp
168 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got backout $bad_commit > $testroot/stdout)
169 5bda3ef8 2020-02-09 stsp
170 5bda3ef8 2020-02-09 stsp echo "G alpha" > $testroot/stdout.expected
171 5bda3ef8 2020-02-09 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
172 5bda3ef8 2020-02-09 stsp echo "! new" >> $testroot/stdout.expected
173 5bda3ef8 2020-02-09 stsp echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
174 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
175 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
176 0ef68859 2021-09-28 thomas echo "in the work tree: 1" >> $testroot/stdout.expected
177 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
178 fc414659 2022-04-16 thomas ret=$?
179 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
180 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
181 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
182 5bda3ef8 2020-02-09 stsp return 1
183 5bda3ef8 2020-02-09 stsp fi
184 5bda3ef8 2020-02-09 stsp
185 5bda3ef8 2020-02-09 stsp if [ -e "$testroot/wt/new" ]; then
186 5bda3ef8 2020-02-09 stsp echo "file '$testroot/wt/new' still exists on disk" >&2
187 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
188 5bda3ef8 2020-02-09 stsp return 1
189 5bda3ef8 2020-02-09 stsp fi
190 5bda3ef8 2020-02-09 stsp
191 5bda3ef8 2020-02-09 stsp echo "zeta" > $testroot/content.expected
192 5bda3ef8 2020-02-09 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
193 5bda3ef8 2020-02-09 stsp cmp -s $testroot/content.expected $testroot/content
194 fc414659 2022-04-16 thomas ret=$?
195 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
196 5bda3ef8 2020-02-09 stsp diff -u $testroot/content.expected $testroot/content
197 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
198 5bda3ef8 2020-02-09 stsp return 1
199 5bda3ef8 2020-02-09 stsp fi
200 5bda3ef8 2020-02-09 stsp
201 5bda3ef8 2020-02-09 stsp echo -n '' > $testroot/stdout.expected
202 5bda3ef8 2020-02-09 stsp (cd $testroot/wt && got status > $testroot/stdout)
203 5bda3ef8 2020-02-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 fc414659 2022-04-16 thomas ret=$?
205 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
206 5bda3ef8 2020-02-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
207 5bda3ef8 2020-02-09 stsp fi
208 5bda3ef8 2020-02-09 stsp test_done "$testroot" "$ret"
209 5bda3ef8 2020-02-09 stsp }
210 5bda3ef8 2020-02-09 stsp
211 a2c162eb 2022-10-30 thomas test_backout_umask() {
212 a2c162eb 2022-10-30 thomas local testroot=`test_init backout_umask`
213 a2c162eb 2022-10-30 thomas
214 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
215 a2c162eb 2022-10-30 thomas echo "edit alpha" >$testroot/wt/alpha
216 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got commit -m 'edit alpha') >/dev/null
217 a2c162eb 2022-10-30 thomas ret=$?
218 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
219 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
220 a2c162eb 2022-10-30 thomas return 1
221 a2c162eb 2022-10-30 thomas fi
222 a2c162eb 2022-10-30 thomas
223 a2c162eb 2022-10-30 thomas local commit=`git_show_head "$testroot/repo"`
224 a2c162eb 2022-10-30 thomas
225 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got update) >/dev/null
226 a2c162eb 2022-10-30 thomas
227 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
228 a2c162eb 2022-10-30 thomas (umask 077 && cd "$testroot/wt" && got backout $commit) >/dev/null
229 a2c162eb 2022-10-30 thomas ret=$?
230 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
231 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
232 a2c162eb 2022-10-30 thomas return 1
233 a2c162eb 2022-10-30 thomas fi
234 a2c162eb 2022-10-30 thomas
235 a2c162eb 2022-10-30 thomas if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
236 a2c162eb 2022-10-30 thomas echo "alpha is not 0600 after backout" >&2
237 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/alpha" >&2
238 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
239 a2c162eb 2022-10-30 thomas return 1
240 a2c162eb 2022-10-30 thomas fi
241 a2c162eb 2022-10-30 thomas
242 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
243 a2c162eb 2022-10-30 thomas }
244 7c82d1d5 2023-01-28 thomas
245 7c82d1d5 2023-01-28 thomas test_backout_logmsg_ref() {
246 7c82d1d5 2023-01-28 thomas local testroot=`test_init backout_logmsg_ref`
247 7c82d1d5 2023-01-28 thomas
248 7c82d1d5 2023-01-28 thomas got checkout $testroot/repo $testroot/wt > /dev/null
249 7c82d1d5 2023-01-28 thomas ret=$?
250 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
251 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
252 7c82d1d5 2023-01-28 thomas return 1
253 7c82d1d5 2023-01-28 thomas fi
254 7c82d1d5 2023-01-28 thomas
255 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
256 7c82d1d5 2023-01-28 thomas
257 7c82d1d5 2023-01-28 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
258 7c82d1d5 2023-01-28 thomas echo "modified alpha on branch" > $testroot/repo/alpha
259 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
260 7c82d1d5 2023-01-28 thomas echo "new file on branch" > $testroot/repo/epsilon/new
261 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
262 a2c162eb 2022-10-30 thomas
263 7c82d1d5 2023-01-28 thomas git_commit $testroot/repo -m "commit changes on newbranch"
264 7c82d1d5 2023-01-28 thomas local commit_time=`git_show_author_time $testroot/repo`
265 7c82d1d5 2023-01-28 thomas local branch_rev=`git_show_head $testroot/repo`
266 7c82d1d5 2023-01-28 thomas
267 7c82d1d5 2023-01-28 thomas echo "modified new file on branch" > $testroot/repo/epsilon/new
268 7c82d1d5 2023-01-28 thomas
269 7c82d1d5 2023-01-28 thomas git_commit $testroot/repo -m "commit modified new file on newbranch"
270 7c82d1d5 2023-01-28 thomas local commit_time2=`git_show_author_time $testroot/repo`
271 7c82d1d5 2023-01-28 thomas local branch_rev2=`git_show_head $testroot/repo`
272 7c82d1d5 2023-01-28 thomas
273 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout $branch_rev > /dev/null)
274 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout $branch_rev2 > /dev/null)
275 7c82d1d5 2023-01-28 thomas
276 7c82d1d5 2023-01-28 thomas # show all backout log message refs in the work tree
277 7c82d1d5 2023-01-28 thomas local sep="-----------------------------------------------"
278 7c82d1d5 2023-01-28 thomas local logmsg="commit changes on newbranch"
279 7c82d1d5 2023-01-28 thomas local changeset=" M alpha\n D beta\n A epsilon/new\n M gamma/delta"
280 7c82d1d5 2023-01-28 thomas local logmsg2="commit modified new file on newbranch"
281 7c82d1d5 2023-01-28 thomas local changeset2=" M epsilon/new"
282 7c82d1d5 2023-01-28 thomas local date=`date -u -r $commit_time +"%a %b %e %X %Y UTC"`
283 7c82d1d5 2023-01-28 thomas local date2=`date -u -r $commit_time2 +"%a %b %e %X %Y UTC"`
284 7c82d1d5 2023-01-28 thomas local ymd=`date -u -r $commit_time +"%F"`
285 7c82d1d5 2023-01-28 thomas local short_id=$(printf '%.7s' $branch_rev)
286 7c82d1d5 2023-01-28 thomas local ymd2=`date -u -r $commit_time2 +"%F"`
287 7c82d1d5 2023-01-28 thomas local short_id2="newbranch"
288 117f997e 2023-02-03 thomas local wt_sorted=$(printf "$branch_rev\n$branch_rev2" | sort)
289 7c82d1d5 2023-01-28 thomas
290 117f997e 2023-02-03 thomas for r in $wt_sorted; do
291 7c82d1d5 2023-01-28 thomas echo $sep >> $testroot/stdout.expected
292 8d6e02ca 2023-03-03 thomas if [ $r = $branch_rev ]; then
293 f35e52a9 2023-01-31 thomas echo "backout $r" >> $testroot/stdout.expected
294 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
295 7c82d1d5 2023-01-28 thomas echo "date: $date" >> $testroot/stdout.expected
296 7c82d1d5 2023-01-28 thomas printf " \n $logmsg\n \n" >> $testroot/stdout.expected
297 7c82d1d5 2023-01-28 thomas printf "$changeset\n\n" >> $testroot/stdout.expected
298 7c82d1d5 2023-01-28 thomas
299 7c82d1d5 2023-01-28 thomas # for forthcoming wt 'backout -X' test
300 46f87436 2023-01-28 thomas echo "Deleted: $ymd $short_id $logmsg" >> \
301 7c82d1d5 2023-01-28 thomas $testroot/stdout.wt_deleted
302 7c82d1d5 2023-01-28 thomas else
303 f35e52a9 2023-01-31 thomas echo "backout $r (newbranch)" \
304 7c82d1d5 2023-01-28 thomas >> $testroot/stdout.expected
305 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
306 7c82d1d5 2023-01-28 thomas echo "date: $date2" >> $testroot/stdout.expected
307 7c82d1d5 2023-01-28 thomas printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
308 7c82d1d5 2023-01-28 thomas printf "$changeset2\n\n" >> $testroot/stdout.expected
309 7c82d1d5 2023-01-28 thomas
310 7c82d1d5 2023-01-28 thomas # for forthcoming wt 'backout -X' test
311 46f87436 2023-01-28 thomas echo "Deleted: $ymd2 $short_id2 $logmsg2" >> \
312 7c82d1d5 2023-01-28 thomas $testroot/stdout.wt_deleted
313 7c82d1d5 2023-01-28 thomas fi
314 7c82d1d5 2023-01-28 thomas done
315 7c82d1d5 2023-01-28 thomas
316 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout -l > $testroot/stdout)
317 7c82d1d5 2023-01-28 thomas
318 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
319 7c82d1d5 2023-01-28 thomas ret=$?
320 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
321 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
322 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
323 7c82d1d5 2023-01-28 thomas return 1
324 7c82d1d5 2023-01-28 thomas fi
325 7c82d1d5 2023-01-28 thomas
326 7c82d1d5 2023-01-28 thomas # only show log message ref of the specified commit id
327 7c82d1d5 2023-01-28 thomas echo $sep > $testroot/stdout.expected
328 f35e52a9 2023-01-31 thomas echo "backout $branch_rev" >> $testroot/stdout.expected
329 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
330 7c82d1d5 2023-01-28 thomas echo "date: $date" >> $testroot/stdout.expected
331 7c82d1d5 2023-01-28 thomas printf " \n $logmsg\n \n" >> $testroot/stdout.expected
332 7c82d1d5 2023-01-28 thomas printf "$changeset\n\n" >> $testroot/stdout.expected
333 7c82d1d5 2023-01-28 thomas
334 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout -l $branch_rev > $testroot/stdout)
335 7c82d1d5 2023-01-28 thomas
336 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
337 7c82d1d5 2023-01-28 thomas ret=$?
338 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
339 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
340 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
341 7c82d1d5 2023-01-28 thomas return 1
342 7c82d1d5 2023-01-28 thomas fi
343 7c82d1d5 2023-01-28 thomas
344 7c82d1d5 2023-01-28 thomas # only show log message ref of the specified symref
345 7c82d1d5 2023-01-28 thomas echo $sep > $testroot/stdout.expected
346 f35e52a9 2023-01-31 thomas echo "backout $branch_rev2 (newbranch)" >> $testroot/stdout.expected
347 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
348 7c82d1d5 2023-01-28 thomas echo "date: $date2" >> $testroot/stdout.expected
349 7c82d1d5 2023-01-28 thomas printf " \n $logmsg2\n \n" >> $testroot/stdout.expected
350 7c82d1d5 2023-01-28 thomas printf "$changeset2\n\n" >> $testroot/stdout.expected
351 7c82d1d5 2023-01-28 thomas
352 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout -l "newbranch" > $testroot/stdout)
353 7c82d1d5 2023-01-28 thomas
354 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
355 7c82d1d5 2023-01-28 thomas ret=$?
356 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
357 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
358 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
359 7c82d1d5 2023-01-28 thomas return 1
360 7c82d1d5 2023-01-28 thomas fi
361 7c82d1d5 2023-01-28 thomas
362 7c82d1d5 2023-01-28 thomas # create a second work tree with backed-out commits and ensure
363 7c82d1d5 2023-01-28 thomas # bo -l within the new work tree only shows the refs it created
364 7c82d1d5 2023-01-28 thomas got checkout $testroot/repo $testroot/wt2 > /dev/null
365 7c82d1d5 2023-01-28 thomas ret=$?
366 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
367 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
368 7c82d1d5 2023-01-28 thomas return 1
369 7c82d1d5 2023-01-28 thomas fi
370 7c82d1d5 2023-01-28 thomas
371 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch2
372 7c82d1d5 2023-01-28 thomas
373 7c82d1d5 2023-01-28 thomas echo "modified delta on branch2" > $testroot/repo/gamma/delta
374 7c82d1d5 2023-01-28 thomas echo "modified alpha on branch2" > $testroot/repo/alpha
375 7c82d1d5 2023-01-28 thomas echo "new file on branch2" > $testroot/repo/epsilon/new2
376 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new2
377 7c82d1d5 2023-01-28 thomas
378 7c82d1d5 2023-01-28 thomas git_commit $testroot/repo -m "commit changes on newbranch2"
379 7c82d1d5 2023-01-28 thomas local b2_commit_time=`git_show_author_time $testroot/repo`
380 7c82d1d5 2023-01-28 thomas local branch2_rev=`git_show_head $testroot/repo`
381 7c82d1d5 2023-01-28 thomas
382 7c82d1d5 2023-01-28 thomas echo "modified file new2 on branch2" > $testroot/repo/epsilon/new2
383 7c82d1d5 2023-01-28 thomas
384 7c82d1d5 2023-01-28 thomas git_commit $testroot/repo -m "commit modified file new2 on newbranch2"
385 7c82d1d5 2023-01-28 thomas local b2_commit_time2=`git_show_author_time $testroot/repo`
386 7c82d1d5 2023-01-28 thomas local branch2_rev2=`git_show_head $testroot/repo`
387 7c82d1d5 2023-01-28 thomas
388 7c82d1d5 2023-01-28 thomas (cd $testroot/wt2 && got backout $branch2_rev > /dev/null)
389 7c82d1d5 2023-01-28 thomas (cd $testroot/wt2 && got backout $branch2_rev2 > /dev/null)
390 7c82d1d5 2023-01-28 thomas
391 7c82d1d5 2023-01-28 thomas local b2_logmsg="commit changes on newbranch2"
392 7c82d1d5 2023-01-28 thomas local b2_changeset=" M alpha\n A epsilon/new2\n M gamma/delta"
393 7c82d1d5 2023-01-28 thomas local b2_logmsg2="commit modified file new2 on newbranch2"
394 7c82d1d5 2023-01-28 thomas local b2_changeset2=" M epsilon/new2"
395 7c82d1d5 2023-01-28 thomas date=`date -u -r $b2_commit_time +"%a %b %e %X %Y UTC"`
396 7c82d1d5 2023-01-28 thomas date2=`date -u -r $b2_commit_time2 +"%a %b %e %X %Y UTC"`
397 117f997e 2023-02-03 thomas local wt2_sorted=$(printf "$branch2_rev\n$branch2_rev2" | sort)
398 7c82d1d5 2023-01-28 thomas
399 7c82d1d5 2023-01-28 thomas echo -n > $testroot/stdout.expected
400 117f997e 2023-02-03 thomas for r in $wt2_sorted; do
401 7c82d1d5 2023-01-28 thomas echo $sep >> $testroot/stdout.expected
402 8d6e02ca 2023-03-03 thomas if [ $r = $branch2_rev ]; then
403 f35e52a9 2023-01-31 thomas echo "backout $r" >> $testroot/stdout.expected
404 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
405 7c82d1d5 2023-01-28 thomas echo "date: $date" >> $testroot/stdout.expected
406 7c82d1d5 2023-01-28 thomas printf " \n $b2_logmsg\n \n" >> \
407 7c82d1d5 2023-01-28 thomas $testroot/stdout.expected
408 7c82d1d5 2023-01-28 thomas printf "$b2_changeset\n\n" >> \
409 7c82d1d5 2023-01-28 thomas $testroot/stdout.expected
410 7c82d1d5 2023-01-28 thomas else
411 f35e52a9 2023-01-31 thomas echo "backout $r (newbranch2)" \
412 7c82d1d5 2023-01-28 thomas >> $testroot/stdout.expected
413 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
414 7c82d1d5 2023-01-28 thomas echo "date: $date2" >> $testroot/stdout.expected
415 7c82d1d5 2023-01-28 thomas printf " \n $b2_logmsg2\n \n" >> \
416 7c82d1d5 2023-01-28 thomas $testroot/stdout.expected
417 7c82d1d5 2023-01-28 thomas printf "$b2_changeset2\n\n" >> \
418 7c82d1d5 2023-01-28 thomas $testroot/stdout.expected
419 7c82d1d5 2023-01-28 thomas fi
420 7c82d1d5 2023-01-28 thomas done
421 7c82d1d5 2023-01-28 thomas
422 7c82d1d5 2023-01-28 thomas (cd $testroot/wt2 && got backout -l > $testroot/stdout)
423 7c82d1d5 2023-01-28 thomas
424 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
425 7c82d1d5 2023-01-28 thomas ret=$?
426 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
427 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
428 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
429 7c82d1d5 2023-01-28 thomas return 1
430 7c82d1d5 2023-01-28 thomas fi
431 7c82d1d5 2023-01-28 thomas
432 117f997e 2023-02-03 thomas # ensure both wt and wt2 logmsg refs can be retrieved and the
433 117f997e 2023-02-03 thomas # work tree UUID is displayed when listing refs from the repo
434 117f997e 2023-02-03 thomas local wt_uuid=$(cat $testroot/wt/.got/uuid)
435 117f997e 2023-02-03 thomas local wt2_uuid=$(cat $testroot/wt2/.got/uuid)
436 117f997e 2023-02-03 thomas local wt_first=`printf "$wt_uuid\n$wt2_uuid" | sort | head -1`
437 7c82d1d5 2023-01-28 thomas
438 117f997e 2023-02-03 thomas for r in $wt_sorted; do
439 117f997e 2023-02-03 thomas echo -n "backout $r" >> $testroot/wt.list
440 8d6e02ca 2023-03-03 thomas if [ $r = $branch_rev2 ]; then
441 117f997e 2023-02-03 thomas echo -n " (newbranch)" >> $testroot/wt.list
442 117f997e 2023-02-03 thomas fi
443 117f997e 2023-02-03 thomas echo >> $testroot/wt.list
444 117f997e 2023-02-03 thomas echo "work tree: $wt_uuid" >> $testroot/wt.list
445 7c82d1d5 2023-01-28 thomas done
446 7c82d1d5 2023-01-28 thomas
447 117f997e 2023-02-03 thomas for r in $wt2_sorted; do
448 117f997e 2023-02-03 thomas echo -n "backout $r" >> $testroot/wt2.list
449 8d6e02ca 2023-03-03 thomas if [ $r = $branch2_rev2 ]; then
450 117f997e 2023-02-03 thomas echo -n " (newbranch2)" >> $testroot/wt2.list
451 117f997e 2023-02-03 thomas fi
452 117f997e 2023-02-03 thomas echo >> $testroot/wt2.list
453 117f997e 2023-02-03 thomas echo "work tree: $wt2_uuid" >> $testroot/wt2.list
454 117f997e 2023-02-03 thomas done
455 7c82d1d5 2023-01-28 thomas
456 8d6e02ca 2023-03-03 thomas if [ $wt_uuid = $wt_first ]; then
457 117f997e 2023-02-03 thomas mv $testroot/wt.list $testroot/stdout.expected
458 117f997e 2023-02-03 thomas cat $testroot/wt2.list >> $testroot/stdout.expected
459 117f997e 2023-02-03 thomas else
460 117f997e 2023-02-03 thomas mv $testroot/wt2.list $testroot/stdout.expected
461 117f997e 2023-02-03 thomas cat $testroot/wt.list >> $testroot/stdout.expected
462 117f997e 2023-02-03 thomas fi
463 117f997e 2023-02-03 thomas
464 117f997e 2023-02-03 thomas (cd $testroot/repo && got backout -l | egrep "^(backout|work)" \
465 117f997e 2023-02-03 thomas > $testroot/stdout)
466 117f997e 2023-02-03 thomas
467 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
468 7c82d1d5 2023-01-28 thomas ret=$?
469 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
470 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
471 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
472 7c82d1d5 2023-01-28 thomas return 1
473 7c82d1d5 2023-01-28 thomas fi
474 7c82d1d5 2023-01-28 thomas
475 7c82d1d5 2023-01-28 thomas # delete logmsg ref of the specified commit in work tree 2
476 7c82d1d5 2023-01-28 thomas ymd=`date -u -r $b2_commit_time +"%F"`
477 7c82d1d5 2023-01-28 thomas short_id=$(printf '%.7s' $branch2_rev)
478 7c82d1d5 2023-01-28 thomas
479 46f87436 2023-01-28 thomas echo "Deleted: $ymd $short_id $b2_logmsg" > $testroot/stdout.expected
480 7c82d1d5 2023-01-28 thomas (cd $testroot/wt2 && got backout -X $branch2_rev > $testroot/stdout)
481 7c82d1d5 2023-01-28 thomas
482 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
483 7c82d1d5 2023-01-28 thomas ret=$?
484 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
485 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
486 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
487 7c82d1d5 2023-01-28 thomas return 1
488 7c82d1d5 2023-01-28 thomas fi
489 7c82d1d5 2023-01-28 thomas
490 7c82d1d5 2023-01-28 thomas # delete all logmsg refs in work tree 1
491 7c82d1d5 2023-01-28 thomas (cd $testroot && mv stdout.wt_deleted stdout.expected)
492 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout -X > $testroot/stdout)
493 7c82d1d5 2023-01-28 thomas
494 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
495 7c82d1d5 2023-01-28 thomas ret=$?
496 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
497 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
498 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
499 7c82d1d5 2023-01-28 thomas return 1
500 7c82d1d5 2023-01-28 thomas fi
501 7c82d1d5 2023-01-28 thomas
502 7c82d1d5 2023-01-28 thomas # confirm all work tree 1 refs were deleted
503 7c82d1d5 2023-01-28 thomas echo -n > $testroot/stdout.expected
504 7c82d1d5 2023-01-28 thomas (cd $testroot/wt && got backout -l > $testroot/stdout)
505 7c82d1d5 2023-01-28 thomas
506 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
507 7c82d1d5 2023-01-28 thomas ret=$?
508 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
509 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
510 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
511 7c82d1d5 2023-01-28 thomas return 1
512 7c82d1d5 2023-01-28 thomas fi
513 7c82d1d5 2023-01-28 thomas
514 7c82d1d5 2023-01-28 thomas # make sure the remaining ref in work tree 2 was not also deleted
515 7c82d1d5 2023-01-28 thomas echo $sep > $testroot/stdout.expected
516 f35e52a9 2023-01-31 thomas echo "backout $branch2_rev2 (newbranch2)" >> $testroot/stdout.expected
517 7c82d1d5 2023-01-28 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
518 7c82d1d5 2023-01-28 thomas echo "date: $date2" >> $testroot/stdout.expected
519 7c82d1d5 2023-01-28 thomas printf " \n $b2_logmsg2\n \n" >> $testroot/stdout.expected
520 7c82d1d5 2023-01-28 thomas printf "$b2_changeset2\n\n" >> $testroot/stdout.expected
521 7c82d1d5 2023-01-28 thomas
522 7c82d1d5 2023-01-28 thomas (cd $testroot/wt2 && got backout -l > $testroot/stdout)
523 7c82d1d5 2023-01-28 thomas
524 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
525 7c82d1d5 2023-01-28 thomas ret=$?
526 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
527 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
528 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
529 7c82d1d5 2023-01-28 thomas return 1
530 7c82d1d5 2023-01-28 thomas fi
531 7c82d1d5 2023-01-28 thomas
532 7c82d1d5 2023-01-28 thomas # ensure we can delete work tree refs from the repository dir
533 7c82d1d5 2023-01-28 thomas ymd=`date -u -r $b2_commit_time2 +"%F"`
534 46f87436 2023-01-28 thomas echo "Deleted: $ymd newbranch2 $b2_logmsg2" > $testroot/stdout.expected
535 7c82d1d5 2023-01-28 thomas (cd $testroot/repo && got backout -X > $testroot/stdout)
536 fb885120 2023-07-19 thomas
537 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
538 fb885120 2023-07-19 thomas ret=$?
539 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
540 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
541 fb885120 2023-07-19 thomas fi
542 fb885120 2023-07-19 thomas
543 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
544 fb885120 2023-07-19 thomas }
545 fb885120 2023-07-19 thomas
546 fb885120 2023-07-19 thomas test_backout_commit_keywords() {
547 fb885120 2023-07-19 thomas local testroot=$(test_init backout_commit_keywords)
548 fb885120 2023-07-19 thomas
549 fb885120 2023-07-19 thomas got checkout $testroot/repo $testroot/wt > /dev/null
550 fb885120 2023-07-19 thomas ret=$?
551 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
552 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
553 fb885120 2023-07-19 thomas return 1
554 fb885120 2023-07-19 thomas fi
555 fb885120 2023-07-19 thomas
556 fb885120 2023-07-19 thomas echo "new" > $testroot/wt/new
557 fb885120 2023-07-19 thomas (cd $testroot/wt && got add new > /dev/null)
558 fb885120 2023-07-19 thomas echo "modified alpha" > $testroot/wt/alpha
559 fb885120 2023-07-19 thomas (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
560 fb885120 2023-07-19 thomas (cd $testroot/wt && got commit -m "bad changes" > /dev/null)
561 fb885120 2023-07-19 thomas
562 fb885120 2023-07-19 thomas local bad_commit=`git_show_head $testroot/repo`
563 fb885120 2023-07-19 thomas
564 fb885120 2023-07-19 thomas (cd $testroot/wt && got update > /dev/null)
565 fb885120 2023-07-19 thomas
566 fb885120 2023-07-19 thomas echo "modified beta" > $testroot/wt/beta
567 fb885120 2023-07-19 thomas (cd $testroot/wt && got commit -m "changing beta" > /dev/null)
568 fb885120 2023-07-19 thomas echo "modified beta again" > $testroot/wt/beta
569 fb885120 2023-07-19 thomas (cd $testroot/wt && got commit -m "changing beta again" > /dev/null)
570 fb885120 2023-07-19 thomas
571 fb885120 2023-07-19 thomas (cd $testroot/wt && got update > /dev/null)
572 fb885120 2023-07-19 thomas
573 fb885120 2023-07-19 thomas (cd $testroot/wt && got bo :head:-2 > $testroot/stdout)
574 fb885120 2023-07-19 thomas
575 fb885120 2023-07-19 thomas echo "G alpha" > $testroot/stdout.expected
576 fb885120 2023-07-19 thomas echo "A epsilon/zeta" >> $testroot/stdout.expected
577 fb885120 2023-07-19 thomas echo "D new" >> $testroot/stdout.expected
578 fb885120 2023-07-19 thomas echo "Backed out commit $bad_commit" >> $testroot/stdout.expected
579 fb885120 2023-07-19 thomas
580 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
581 fb885120 2023-07-19 thomas ret=$?
582 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
583 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
584 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
585 fb885120 2023-07-19 thomas return 1
586 fb885120 2023-07-19 thomas fi
587 7c82d1d5 2023-01-28 thomas
588 fb885120 2023-07-19 thomas echo "alpha" > $testroot/content.expected
589 fb885120 2023-07-19 thomas cat $testroot/wt/alpha > $testroot/content
590 fb885120 2023-07-19 thomas cmp -s $testroot/content.expected $testroot/content
591 fb885120 2023-07-19 thomas ret=$?
592 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
593 fb885120 2023-07-19 thomas diff -u $testroot/content.expected $testroot/content
594 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
595 fb885120 2023-07-19 thomas return 1
596 fb885120 2023-07-19 thomas fi
597 fb885120 2023-07-19 thomas
598 fb885120 2023-07-19 thomas if [ -e "$testroot/wt/new" ]; then
599 fb885120 2023-07-19 thomas echo "file '$testroot/wt/new' still exists on disk" >&2
600 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
601 fb885120 2023-07-19 thomas return 1
602 fb885120 2023-07-19 thomas fi
603 fb885120 2023-07-19 thomas
604 fb885120 2023-07-19 thomas if [ ! -e "$testroot/wt/epsilon/zeta" ]; then
605 fb885120 2023-07-19 thomas echo "file '$testroot/wt/epsilon/zeta' is missing on disk" >&2
606 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
607 fb885120 2023-07-19 thomas return 1
608 fb885120 2023-07-19 thomas fi
609 fb885120 2023-07-19 thomas
610 fb885120 2023-07-19 thomas echo 'M alpha' > $testroot/stdout.expected
611 fb885120 2023-07-19 thomas echo 'A epsilon/zeta' >> $testroot/stdout.expected
612 fb885120 2023-07-19 thomas echo 'D new' >> $testroot/stdout.expected
613 fb885120 2023-07-19 thomas (cd $testroot/wt && got status > $testroot/stdout)
614 fb885120 2023-07-19 thomas
615 7c82d1d5 2023-01-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
616 7c82d1d5 2023-01-28 thomas ret=$?
617 7c82d1d5 2023-01-28 thomas if [ $ret -ne 0 ]; then
618 7c82d1d5 2023-01-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
619 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
620 fb885120 2023-07-19 thomas return 1
621 7c82d1d5 2023-01-28 thomas fi
622 7c82d1d5 2023-01-28 thomas
623 fb885120 2023-07-19 thomas local next_backout=`git_show_head $testroot/repo`
624 fb885120 2023-07-19 thomas
625 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got ci -m "backed-out bad commit" > /dev/null)
626 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got up > /dev/null)
627 fb885120 2023-07-19 thomas
628 fb885120 2023-07-19 thomas echo "G beta" > $testroot/stdout.expected
629 fb885120 2023-07-19 thomas echo "Backed out commit $next_backout" >> $testroot/stdout.expected
630 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got bo :base:- > $testroot/stdout)
631 fb885120 2023-07-19 thomas
632 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
633 fb885120 2023-07-19 thomas ret=$?
634 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
635 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
636 fb885120 2023-07-19 thomas fi
637 fb885120 2023-07-19 thomas
638 7c82d1d5 2023-01-28 thomas test_done "$testroot" "$ret"
639 7c82d1d5 2023-01-28 thomas }
640 7c82d1d5 2023-01-28 thomas
641 7fb414ae 2020-08-08 stsp test_parseargs "$@"
642 5ef14e63 2019-06-02 stsp run_test test_backout_basic
643 5bda3ef8 2020-02-09 stsp run_test test_backout_edits_for_file_since_deleted
644 5bda3ef8 2020-02-09 stsp run_test test_backout_next_commit
645 a2c162eb 2022-10-30 thomas run_test test_backout_umask
646 7c82d1d5 2023-01-28 thomas run_test test_backout_logmsg_ref
647 fb885120 2023-07-19 thomas run_test test_backout_commit_keywords