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 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
37 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
38 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
42 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
43 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
45 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
46 0ebf8283 2019-07-24 stsp > $testroot/stdout)
48 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
49 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
51 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
52 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
53 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
54 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
56 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
57 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
58 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
59 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
60 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
61 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
62 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
63 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
66 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
70 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
71 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
72 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
76 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
77 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
78 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
80 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
81 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
82 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
86 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
87 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
88 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
92 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
93 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
94 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
96 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
97 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
98 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
102 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
104 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
105 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
107 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
108 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
109 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
113 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
114 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
115 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
116 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
117 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
119 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
120 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
125 0ebf8283 2019-07-24 stsp function test_histedit_swap {
126 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
128 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
130 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
131 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
132 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
133 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
134 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
135 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
137 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
138 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
139 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
141 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
143 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
144 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
148 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
149 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
151 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
152 0ebf8283 2019-07-24 stsp > $testroot/stdout)
154 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
155 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
157 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
158 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
159 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
160 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
162 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
163 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
164 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
165 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
166 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
167 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
168 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
169 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
170 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
171 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
172 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
174 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
176 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
177 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
178 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
182 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
183 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
184 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
186 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
187 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
188 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
192 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
193 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
194 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
198 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
199 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
200 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
202 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
203 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
204 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
208 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
210 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
211 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
213 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
214 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
219 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
220 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
221 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
222 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
223 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
225 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
226 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
228 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
231 0ebf8283 2019-07-24 stsp function test_histedit_drop {
232 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
234 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
236 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
237 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
238 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
239 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
240 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
241 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
243 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
244 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
245 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
247 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
249 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
250 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
254 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
255 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
257 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
258 0ebf8283 2019-07-24 stsp > $testroot/stdout)
260 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
261 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
263 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
264 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
265 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
266 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
268 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
269 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
270 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
271 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
272 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
273 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
274 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
275 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
277 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
279 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
280 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
281 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
285 0ebf8283 2019-07-24 stsp for f in alpha beta; do
286 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
287 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
288 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
290 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
291 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
292 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
297 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
298 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
299 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
303 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
305 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
306 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
308 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
309 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
310 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
314 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
315 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
316 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
317 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
319 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
320 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
322 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
325 0ebf8283 2019-07-24 stsp function test_histedit_fold {
326 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
328 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
330 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
331 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
332 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
333 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
334 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
335 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
337 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
338 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
339 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
341 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
343 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
344 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
348 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
349 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
350 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
352 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
353 0ebf8283 2019-07-24 stsp > $testroot/stdout)
355 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
356 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
358 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
359 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
360 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
361 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
363 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
364 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
365 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
366 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
367 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
368 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
369 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
370 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
371 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
372 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
373 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
375 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
377 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
378 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
379 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
383 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
384 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
385 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
387 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
388 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
389 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
393 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
394 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
395 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
399 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
400 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
401 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
403 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
404 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
405 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
409 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
411 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
412 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
414 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
415 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
416 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
420 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
421 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
422 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
423 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
425 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
426 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
431 0ebf8283 2019-07-24 stsp function test_histedit_edit {
432 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
434 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
436 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
437 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
438 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
439 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
440 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
441 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
443 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
444 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
445 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
447 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
449 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
450 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
454 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
455 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
456 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
458 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
459 0ebf8283 2019-07-24 stsp > $testroot/stdout)
461 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
462 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
464 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
465 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
466 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
467 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
468 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
469 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
471 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
472 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
477 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
479 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
481 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
482 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
484 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
485 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
487 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
488 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
489 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
490 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
491 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
492 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
493 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
494 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
496 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
499 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
504 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
505 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
506 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
508 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
509 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
510 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
514 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
515 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
516 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
520 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
521 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
522 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
524 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
525 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
526 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
530 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
532 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
533 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
535 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
536 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
537 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
541 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
542 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
543 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
544 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $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
550 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
553 0ebf8283 2019-07-24 stsp function test_histedit_fold_last_commit {
554 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
556 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
558 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
559 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
560 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
561 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
562 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
563 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
565 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
566 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
567 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
569 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
571 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
572 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
576 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
577 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
578 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
580 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
581 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
584 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
585 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
586 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
590 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
591 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
593 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
595 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
596 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
598 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
601 0ebf8283 2019-07-24 stsp function test_histedit_missing_commit {
602 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
604 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
606 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
607 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
608 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
609 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
610 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
611 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
613 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
614 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
615 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
617 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
619 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
620 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
624 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
625 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
627 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
628 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
631 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
632 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
633 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
637 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
638 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
640 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
642 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
643 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
645 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
648 0ebf8283 2019-07-24 stsp function test_histedit_abort {
649 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
651 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
653 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
654 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
655 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
656 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
657 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
658 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
660 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
661 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
662 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
664 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
666 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
667 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
671 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
672 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
673 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
675 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
676 0ebf8283 2019-07-24 stsp > $testroot/stdout)
678 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
679 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
681 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
682 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
683 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
684 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
685 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
686 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
688 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
689 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
690 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
694 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
696 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
698 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
699 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
701 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
702 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
704 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
705 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
706 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
707 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
708 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
709 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
710 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
712 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
714 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
715 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
716 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
720 0ebf8283 2019-07-24 stsp for f in alpha beta; do
721 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
722 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
723 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
725 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
726 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
727 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
732 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
733 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
734 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
736 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
737 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
738 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
742 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
744 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
745 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
747 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
748 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
749 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
753 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
754 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
755 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
756 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
757 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
759 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
760 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
762 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
765 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
766 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
767 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
768 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
769 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
770 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
771 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
772 0ebf8283 2019-07-24 stsp run_test test_histedit_abort