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 f6cae3ed 2020-09-13 naddy 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`
23 e600f124 2021-03-21 stsp local orig_author_time=`git_show_author_time $testroot/repo`
25 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
26 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
27 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
28 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
29 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
30 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
32 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
33 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
34 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
35 e600f124 2021-03-21 stsp local old_author_time2=`git_show_author_time $testroot/repo`
37 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
38 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
40 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
42 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
43 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
47 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
48 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
50 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
51 0ebf8283 2019-07-24 stsp > $testroot/stdout)
53 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
54 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
55 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
57 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
58 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
59 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
63 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
66 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
67 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
69 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
70 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
71 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
72 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
74 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
77 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
82 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
83 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
84 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
86 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
87 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
88 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
92 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
93 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
94 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
98 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
99 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
100 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
102 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
103 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
104 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
108 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
110 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
111 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
113 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
114 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
115 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
119 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
120 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
121 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
122 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
123 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
125 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
126 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
131 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
132 86ac67ee 2019-07-25 stsp > $testroot/diff
133 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
134 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
136 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
137 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
138 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
142 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
144 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
145 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
147 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
148 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
149 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
152 e600f124 2021-03-21 stsp # We should have a backup of old commits
153 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
154 e600f124 2021-03-21 stsp d_orig2=`env TZ=UTC date -r $old_author_time2 +"%a %b %e %X %Y UTC"`
155 e600f124 2021-03-21 stsp d_new2=`env TZ=UTC date -r $new_author_time2 +"%G-%m-%d"`
156 e600f124 2021-03-21 stsp d_orig=`env TZ=UTC date -r $orig_author_time +"%G-%m-%d"`
157 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
158 e600f124 2021-03-21 stsp -----------------------------------------------
159 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
160 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
161 e600f124 2021-03-21 stsp date: $d_orig2
163 e600f124 2021-03-21 stsp committing to zeta on master
165 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
166 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
167 e600f124 2021-03-21 stsp history forked at $orig_commit
168 e600f124 2021-03-21 stsp $d_orig $GOT_AUTHOR_11 adding the test tree
170 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
172 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
173 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
174 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
178 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
179 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
180 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
181 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
182 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
183 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
184 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
186 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
187 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
188 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
191 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
193 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
194 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
199 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
200 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
201 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
203 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
204 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
209 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
210 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
212 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
214 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
215 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
216 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
217 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
218 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
219 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
221 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
222 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
223 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
225 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
226 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
228 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
230 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
231 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
235 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
236 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
238 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
239 0ebf8283 2019-07-24 stsp > $testroot/stdout)
241 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
242 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
244 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
245 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
246 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
247 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
249 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
250 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
251 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
252 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
253 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
254 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
255 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
256 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
257 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
258 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
259 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
261 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
264 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
269 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
270 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
271 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
273 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
274 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
275 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
279 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
280 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
281 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
285 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
286 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
287 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
289 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
290 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
295 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
297 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
298 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
300 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
301 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
302 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
306 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
307 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
308 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
309 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
310 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
312 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
313 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
318 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
319 86ac67ee 2019-07-25 stsp > $testroot/diff
320 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
321 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
323 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
324 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
326 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
329 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
330 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
331 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
333 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
334 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
335 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
336 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
337 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
338 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
340 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
341 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
342 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
344 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
345 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
347 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
349 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
350 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
354 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
355 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
357 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
358 0ebf8283 2019-07-24 stsp > $testroot/stdout)
360 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
362 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
363 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
364 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
366 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop 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 to zeta on master" >> $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 for f in alpha beta; do
384 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
385 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
386 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
388 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
389 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
390 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
395 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
396 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
397 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
401 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
403 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
404 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
406 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
407 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
412 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
413 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
414 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
415 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
417 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
418 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
419 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
423 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
424 86ac67ee 2019-07-25 stsp > $testroot/diff
425 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
426 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
427 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
429 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
430 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
432 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
435 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
436 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
438 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
440 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
441 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
442 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
443 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
444 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
445 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
447 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
448 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
449 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
451 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
452 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
453 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
455 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
457 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
458 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
462 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
463 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
464 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
465 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
467 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
468 0ebf8283 2019-07-24 stsp > $testroot/stdout)
470 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
471 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
473 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
474 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
475 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
476 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
477 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
479 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
480 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
481 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
482 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
483 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
484 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
485 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
486 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
487 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
488 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
489 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
490 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
491 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
492 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
494 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
496 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
497 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
502 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
503 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
504 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
506 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
507 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
508 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
512 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
513 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
514 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
518 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
519 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
520 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
522 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
523 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
524 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
528 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
530 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
531 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
533 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
534 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
535 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
539 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
540 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
541 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
542 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
544 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
545 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
547 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
550 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
551 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
553 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
555 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
556 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
557 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
558 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
559 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
560 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
562 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
563 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
564 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
566 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
568 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
569 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
573 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
574 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
575 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
577 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
578 0ebf8283 2019-07-24 stsp > $testroot/stdout)
580 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
581 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
583 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
584 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
585 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
586 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
587 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
588 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
590 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
591 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
596 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
598 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
599 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
600 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
601 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
603 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
604 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
605 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
608 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
609 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
610 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
611 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
612 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
614 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
615 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
616 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
620 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
621 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
623 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
624 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
626 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
627 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
629 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
630 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
631 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
632 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
633 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
634 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
635 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
636 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
638 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
640 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
641 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
642 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
646 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
647 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
648 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
650 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
651 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
652 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
656 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
657 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
658 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
662 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
663 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
664 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
666 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
667 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
668 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
672 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
674 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
675 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
677 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
678 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
679 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
683 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
684 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
685 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
686 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
687 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
689 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
690 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
692 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
695 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
696 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
698 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
700 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
701 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
702 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
703 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
704 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
705 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
707 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
708 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
709 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
711 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
713 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
714 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
718 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
719 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
720 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
722 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
723 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
726 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
727 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
728 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
732 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
733 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
735 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
737 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
738 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
740 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
743 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
744 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
746 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
748 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
749 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
750 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
751 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
752 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
753 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
755 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
756 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
757 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
759 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
761 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
762 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
766 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
767 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
769 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
770 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
773 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
774 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
775 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
779 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
780 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
782 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
784 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
785 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
787 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
790 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
791 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
793 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
795 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
796 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
797 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
798 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
799 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
800 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
802 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
803 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
804 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
806 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
808 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
809 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
813 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
814 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
815 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
817 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
818 0ebf8283 2019-07-24 stsp > $testroot/stdout)
820 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
821 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
823 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
824 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
825 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
826 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
827 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
828 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
830 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
831 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
832 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
836 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
838 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
840 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
841 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
843 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
844 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
845 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
846 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
847 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
848 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
849 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
851 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
853 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
854 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
855 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
859 0ebf8283 2019-07-24 stsp for f in alpha beta; do
860 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
861 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
862 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
864 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
865 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
866 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
871 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
872 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
873 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
875 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
876 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
877 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
881 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
883 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
884 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
886 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
887 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
888 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
892 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
893 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
894 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
895 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
896 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
898 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
899 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
901 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
904 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
905 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
906 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
908 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
909 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
910 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
912 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
913 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
915 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
916 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
920 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
922 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
923 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
926 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
927 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
928 0160a755 2019-07-25 stsp test_done "$testroot" "1"
932 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
933 0160a755 2019-07-25 stsp > $testroot/stderr.expected
934 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
935 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
937 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
939 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
940 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
941 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
945 0160a755 2019-07-25 stsp rm -rf $testroot/wt
946 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
947 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
949 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
950 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
953 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
954 0160a755 2019-07-25 stsp > $testroot/stdout)
956 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
957 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
959 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
960 0160a755 2019-07-25 stsp > $testroot/stdout.expected
961 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
962 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
964 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
967 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
968 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
972 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
973 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
974 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
976 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
977 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
978 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
983 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
985 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
986 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
988 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
989 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
990 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
994 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
995 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
996 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
998 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
999 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1001 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1004 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1005 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1006 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1008 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1009 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1010 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1012 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1013 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1015 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1016 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1018 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1019 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1023 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1024 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
1026 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1027 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1030 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1031 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1032 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1036 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1037 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1038 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1039 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1041 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1043 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1044 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1045 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1049 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1050 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1051 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1053 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1054 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1057 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1058 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1060 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1062 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1063 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1064 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1065 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1067 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
1068 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1069 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1073 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1074 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1075 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1077 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1078 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1079 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1083 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1085 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1086 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1088 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1089 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1090 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1094 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1096 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1097 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1099 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1100 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1101 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1102 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1103 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1105 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1107 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1108 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1109 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1113 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1114 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1115 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1116 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1118 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1119 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1120 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1124 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1125 b2c50a0a 2019-07-25 stsp > $testroot/diff
1126 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1127 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1129 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1130 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1132 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1135 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1136 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1137 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1139 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1141 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1142 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1143 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1147 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1149 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1150 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1152 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1153 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1154 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1157 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1159 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1161 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1162 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1163 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1167 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1169 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1170 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1171 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1175 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1176 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1177 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1179 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1180 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1181 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1182 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1183 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1185 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1186 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1188 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1191 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1192 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1194 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1196 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1197 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1198 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1199 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1200 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1201 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1203 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1204 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1205 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1207 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1209 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1210 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1214 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1215 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1216 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1217 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1219 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1220 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1223 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1224 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1225 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1229 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1231 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1232 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1233 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1235 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1236 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1237 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1238 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1239 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1240 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1241 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1242 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1243 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1244 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1245 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1246 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1248 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1250 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1251 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1253 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1256 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1257 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1259 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1261 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1262 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1263 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1264 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1265 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1266 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1267 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1269 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1270 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1271 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1272 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1274 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1276 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1277 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1281 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1282 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1283 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1285 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1286 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1288 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1289 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1290 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1291 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1295 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1296 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1297 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1298 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1299 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1301 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1303 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1304 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1305 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1309 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1311 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1312 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1313 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1317 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1319 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1320 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1321 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1325 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1327 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1328 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1329 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1333 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1334 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1336 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1337 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1338 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1339 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1342 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1343 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1345 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1346 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1347 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1348 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1349 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1350 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1351 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1353 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1355 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1356 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1358 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1362 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1363 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1365 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1367 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1368 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1369 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1370 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1371 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1372 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1374 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1375 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1376 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1378 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1380 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1381 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1385 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1386 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1387 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1388 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1390 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1391 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1393 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1394 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1395 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1396 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1400 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1401 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1402 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1404 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1406 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1407 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1409 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1413 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1414 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1415 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1416 ecfff807 2020-09-23 stsp local testroot=`test_init histedit_fold`
1418 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1420 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1421 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1422 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1423 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1425 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1426 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1427 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1429 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1430 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1431 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1433 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1435 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1436 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1440 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1441 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1442 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1443 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1445 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1446 ecfff807 2020-09-23 stsp > $testroot/stdout)
1448 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1450 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1451 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1452 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1453 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1455 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1456 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1457 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1458 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1459 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1460 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1461 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1462 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1463 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1464 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1465 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1467 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1469 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1470 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1471 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1475 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1476 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1477 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1481 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1483 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1484 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1486 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1487 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1488 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1492 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1493 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1494 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1496 29c68398 2020-09-24 stsp if [ "$ret" != "0" ]; then
1497 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1498 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1502 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1503 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1504 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1506 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1507 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1509 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1512 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1513 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1515 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1517 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1518 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1519 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1520 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1521 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1522 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1524 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1525 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1526 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1528 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1529 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1530 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1532 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1534 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1535 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1539 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1541 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1543 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1545 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1546 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1548 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1550 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1551 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1552 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1553 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1554 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1556 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1557 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1558 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1559 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1560 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1561 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1562 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1563 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1564 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1565 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1566 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1567 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1568 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1569 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1570 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1572 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1574 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1575 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1576 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1580 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1581 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1582 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1584 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1585 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1586 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1590 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1591 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1592 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1596 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1597 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1598 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1600 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1601 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1602 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1606 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1608 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1609 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1611 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1612 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1613 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1617 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1618 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1619 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1620 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1622 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1623 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1625 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1628 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1629 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1631 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1633 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1634 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1635 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1636 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1637 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1638 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1640 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1641 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1642 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1644 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1645 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1646 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1648 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1650 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1651 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1655 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1657 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1659 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1661 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1662 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1664 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1666 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1667 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1668 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1669 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1670 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1671 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1673 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1674 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1675 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1676 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1677 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1678 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1679 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1680 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1681 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1682 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1683 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1684 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1685 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1686 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1687 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1688 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1690 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1692 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1693 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1694 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1698 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1699 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1700 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1702 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1703 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1704 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1708 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1709 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1710 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1714 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1715 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1716 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1718 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1719 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1720 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1724 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1726 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1727 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1729 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1730 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1731 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1735 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1736 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1737 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1738 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1740 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1741 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1743 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1746 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1747 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1748 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1749 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1750 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1751 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1752 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1753 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1754 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1755 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1756 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
1757 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
1758 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
1759 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
1760 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
1761 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
1762 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
1763 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg