3 0ebf8283 2019-07-24 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 0ebf8283 2019-07-24 stsp # Permission to use, copy, modify, and distribute this software for any
6 0ebf8283 2019-07-24 stsp # purpose with or without fee is hereby granted, provided that the above
7 0ebf8283 2019-07-24 stsp # copyright notice and this permission notice appear in all copies.
9 0ebf8283 2019-07-24 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 0ebf8283 2019-07-24 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 0ebf8283 2019-07-24 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 0ebf8283 2019-07-24 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 0ebf8283 2019-07-24 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 0ebf8283 2019-07-24 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 0ebf8283 2019-07-24 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 0ebf8283 2019-07-24 stsp . ./common.sh
19 0ebf8283 2019-07-24 stsp function test_histedit_no_op {
20 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_no_op`
22 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
24 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
25 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
26 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
27 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
28 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
29 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
31 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
32 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
33 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
35 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
36 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
38 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
40 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
41 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
45 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
46 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
48 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
49 0ebf8283 2019-07-24 stsp > $testroot/stdout)
51 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
52 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
54 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
55 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
56 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
57 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
59 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
60 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
61 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
62 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
63 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
66 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
67 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
69 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
71 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
74 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
75 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
79 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
80 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
81 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
83 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
84 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
85 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
89 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
90 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
91 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
95 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
96 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
97 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
99 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
100 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
101 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
105 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
107 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
108 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
110 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
111 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
112 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
116 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
117 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
118 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
119 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
120 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
123 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
128 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
129 86ac67ee 2019-07-25 stsp > $testroot/diff
130 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
131 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
133 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
134 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
136 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
139 0ebf8283 2019-07-24 stsp function test_histedit_swap {
140 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
142 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
144 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
145 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
146 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
147 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
148 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
149 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
151 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
152 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
153 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
155 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
156 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
158 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
160 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
161 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
165 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
166 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
168 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
169 0ebf8283 2019-07-24 stsp > $testroot/stdout)
171 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
172 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
174 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
175 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
176 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
177 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
179 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
180 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
181 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
182 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
183 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
184 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
185 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
186 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
187 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
188 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
189 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
191 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
193 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
194 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
195 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
199 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
200 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
201 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
203 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
204 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
205 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
209 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
210 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
211 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
215 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
216 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
217 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
219 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
220 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
221 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
225 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
227 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
228 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
230 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
231 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
236 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
237 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
238 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
239 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
240 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
242 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
243 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
244 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
248 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
249 86ac67ee 2019-07-25 stsp > $testroot/diff
250 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
251 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
253 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
254 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
256 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
259 0ebf8283 2019-07-24 stsp function test_histedit_drop {
260 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
261 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
263 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
264 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
265 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
266 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
267 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
268 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
270 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
271 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
272 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
274 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
275 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
277 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
279 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
280 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
284 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
285 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
287 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
288 0ebf8283 2019-07-24 stsp > $testroot/stdout)
290 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
292 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
293 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
294 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
296 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
297 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
298 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
299 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
300 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
301 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
302 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
303 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
305 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
307 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
308 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
313 0ebf8283 2019-07-24 stsp for f in alpha beta; do
314 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
315 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
316 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
318 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
319 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
320 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
325 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
326 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
327 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
331 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
333 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
334 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
336 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
337 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
338 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
342 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
343 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
344 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
345 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
347 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
348 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
349 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
353 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
354 86ac67ee 2019-07-25 stsp > $testroot/diff
355 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
356 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
357 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
359 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
360 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
362 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
365 0ebf8283 2019-07-24 stsp function test_histedit_fold {
366 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
368 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
370 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
371 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
372 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
373 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
374 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
375 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
377 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
378 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
379 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
381 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
382 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
383 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
385 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
387 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
388 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
392 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
393 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
394 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
395 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
397 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
398 0ebf8283 2019-07-24 stsp > $testroot/stdout)
400 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
401 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
403 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
404 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
405 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
406 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
407 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
409 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
410 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
411 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
412 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
413 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
414 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
415 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
416 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
417 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
418 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
419 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
420 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
421 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
422 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
424 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
426 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
427 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
432 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
433 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
434 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
436 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
437 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
438 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
442 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
443 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
444 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
448 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
449 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
450 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
452 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
453 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
454 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
458 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
460 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
461 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
463 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
464 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
465 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
469 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
470 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
471 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
472 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
474 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
475 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
480 0ebf8283 2019-07-24 stsp function test_histedit_edit {
481 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
483 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
485 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
486 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
487 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
488 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
489 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
490 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
492 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
493 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
494 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
496 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
498 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
499 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
503 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
504 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
505 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
507 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
508 0ebf8283 2019-07-24 stsp > $testroot/stdout)
510 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
511 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
513 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
514 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
515 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
516 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
517 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
518 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
520 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
521 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
526 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
528 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
530 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
531 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
533 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
534 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
536 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
537 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
538 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
539 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
540 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
541 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
542 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
543 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
545 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
547 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
548 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
549 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
553 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
554 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
555 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
557 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
558 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
559 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
563 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
564 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
565 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
569 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
570 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
571 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
573 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
574 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
575 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
579 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
581 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
582 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
584 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
585 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
586 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
590 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
591 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
592 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
593 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
594 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
596 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
597 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
599 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
602 0ebf8283 2019-07-24 stsp function test_histedit_fold_last_commit {
603 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
605 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
607 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
608 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
609 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
610 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
611 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
612 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
614 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
615 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
616 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
618 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
620 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
621 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
625 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
626 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
627 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
629 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
630 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
633 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
634 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
635 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
639 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
640 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
642 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
644 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
645 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
647 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
650 0ebf8283 2019-07-24 stsp function test_histedit_missing_commit {
651 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
653 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
655 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
656 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
657 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
658 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
659 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
660 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
662 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
663 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
664 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
666 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
668 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
669 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
673 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
674 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
676 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
677 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
680 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
681 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
682 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
686 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
687 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
689 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
691 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
692 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
694 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
697 0ebf8283 2019-07-24 stsp function test_histedit_abort {
698 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
700 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
702 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
703 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
704 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
705 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
706 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
707 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
709 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
710 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
711 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
713 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
715 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
716 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
720 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
721 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
722 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
724 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
725 0ebf8283 2019-07-24 stsp > $testroot/stdout)
727 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
728 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
730 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
731 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
732 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
733 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
734 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
735 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
737 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
738 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
743 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
745 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
747 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
748 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
750 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
751 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
752 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
753 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
754 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
755 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
756 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
758 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
760 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
761 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
762 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
766 0ebf8283 2019-07-24 stsp for f in alpha beta; do
767 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
768 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
769 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
771 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
772 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
773 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
778 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
779 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
780 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
782 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
783 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
784 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
788 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
790 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
791 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
793 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
794 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
795 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
799 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
800 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
801 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
802 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
803 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
805 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
806 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
808 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
811 a4027091 2019-07-25 stsp function test_histedit_path_prefix_drop {
812 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
813 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
815 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
816 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
817 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
819 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
820 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
822 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
823 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
827 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
829 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
830 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
833 0160a755 2019-07-25 stsp if [ "$ret" == "0" ]; then
834 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
835 0160a755 2019-07-25 stsp test_done "$testroot" "1"
839 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
840 0160a755 2019-07-25 stsp > $testroot/stderr.expected
841 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
842 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
844 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
846 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
847 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
848 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
852 0160a755 2019-07-25 stsp rm -rf $testroot/wt
853 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
854 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
856 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
857 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
860 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
861 0160a755 2019-07-25 stsp > $testroot/stdout)
863 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
864 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
866 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
867 0160a755 2019-07-25 stsp > $testroot/stdout.expected
868 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
869 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
871 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
873 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
874 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
875 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
879 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
880 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
881 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
883 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
884 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
885 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
890 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
892 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
893 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
895 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
896 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
901 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
902 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
903 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
905 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
906 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
911 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
912 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
913 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
914 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
915 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
916 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
917 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
918 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
919 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop