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"
153 e600f124 2021-03-21 stsp # We should have a backup of old commits
154 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
155 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
156 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
157 3a6b8760 2021-08-31 naddy d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
158 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
159 e600f124 2021-03-21 stsp -----------------------------------------------
160 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
161 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
162 e600f124 2021-03-21 stsp date: $d_orig2
164 e600f124 2021-03-21 stsp committing to zeta on master
166 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
167 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
168 e600f124 2021-03-21 stsp history forked at $orig_commit
169 e600f124 2021-03-21 stsp $d_orig $GOT_AUTHOR_11 adding the test tree
171 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
174 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
175 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
179 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
180 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
181 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
182 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
183 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
184 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
185 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
188 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
192 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
194 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
195 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
196 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
200 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
201 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
202 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
205 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
207 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
210 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
211 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
213 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
215 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
216 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
217 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
218 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
219 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
220 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
222 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
223 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
224 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
226 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
227 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
229 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
231 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
236 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
237 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
239 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
240 0ebf8283 2019-07-24 stsp > $testroot/stdout)
242 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
243 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
245 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
246 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
247 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
248 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
250 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
251 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
252 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
253 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
254 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
255 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
256 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
257 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
258 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
259 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
260 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
262 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
264 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
265 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
270 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
271 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
272 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
274 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
275 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
276 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
280 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
281 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
282 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
286 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
287 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $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"
296 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
298 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
299 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
301 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
302 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
303 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
307 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
308 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
309 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
310 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
311 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
313 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
314 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
315 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
319 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
320 86ac67ee 2019-07-25 stsp > $testroot/diff
321 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
322 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
324 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
325 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
327 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
330 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
331 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
332 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
334 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
335 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
336 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
337 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
338 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
339 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
341 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
342 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
343 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
345 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
346 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
348 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
350 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
351 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
355 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
356 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
358 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
359 0ebf8283 2019-07-24 stsp > $testroot/stdout)
361 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
363 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
364 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
365 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
367 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
368 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
369 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
370 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
371 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
372 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
373 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
374 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
376 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
378 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
379 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
380 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
384 0ebf8283 2019-07-24 stsp for f in alpha beta; do
385 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
386 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
387 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
389 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
390 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
391 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
396 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
397 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
398 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
402 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
404 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
405 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
407 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
408 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
409 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
413 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
414 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
415 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
416 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
418 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
419 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
420 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
424 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
425 86ac67ee 2019-07-25 stsp > $testroot/diff
426 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
427 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
428 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
430 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
431 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
433 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
436 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
437 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
439 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
441 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
442 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
443 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
444 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
445 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
446 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
448 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
449 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
450 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
452 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
453 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
454 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
456 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
458 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
459 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
463 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
464 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
465 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
466 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
468 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
469 0ebf8283 2019-07-24 stsp > $testroot/stdout)
471 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
472 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
474 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
475 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
476 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
477 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
478 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
480 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
481 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
482 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
483 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
484 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
485 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
486 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
487 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
488 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
489 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
490 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
491 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
492 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
493 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
495 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
497 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
498 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
499 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
503 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
504 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
505 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
507 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
508 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
509 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
513 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
514 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
515 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
519 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
520 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
521 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
523 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
524 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
525 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
529 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
531 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
532 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
534 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
535 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
536 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
540 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
541 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
542 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
543 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
545 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
546 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
548 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
551 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
552 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
554 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
556 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
557 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
558 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
559 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
560 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
561 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
563 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
564 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
565 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
567 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
569 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
570 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
574 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
575 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
576 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
578 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
579 0ebf8283 2019-07-24 stsp > $testroot/stdout)
581 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
582 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
584 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
585 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
586 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
587 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
588 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
589 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
591 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
592 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
593 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
597 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
599 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
600 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
601 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
602 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
604 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
605 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
606 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
609 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
610 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
611 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
612 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
613 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
615 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
616 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
617 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
621 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
622 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
624 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
625 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
627 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
628 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
630 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
631 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
632 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
633 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
634 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
635 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
636 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
637 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
639 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
641 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
642 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
643 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
647 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
648 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
649 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
651 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
652 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
653 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
657 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
658 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
659 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
663 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
664 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
665 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
667 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
668 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
669 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
673 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
675 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
676 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
678 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
679 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
680 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
684 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
685 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
686 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
687 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
688 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
690 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
691 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
693 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
696 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
697 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
699 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
701 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
702 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
703 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
704 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
705 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
706 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
708 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
709 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
710 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
712 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
714 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
715 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
719 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
720 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
721 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
723 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
724 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
727 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
728 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
729 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
733 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
734 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
736 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
738 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
739 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
741 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
744 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
745 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
747 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
749 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
750 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
751 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
752 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
753 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
754 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
756 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
757 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
758 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
760 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
762 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
763 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
767 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
768 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
770 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
771 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
774 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
775 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
776 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
780 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
781 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
783 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
785 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
786 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
788 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
791 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
792 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
794 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
796 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
797 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
798 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
799 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
800 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
801 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
803 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
804 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
805 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
807 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
809 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
810 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
814 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
815 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
816 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
818 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
819 0ebf8283 2019-07-24 stsp > $testroot/stdout)
821 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
822 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
824 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
825 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
826 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
827 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
828 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
829 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
831 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
832 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
833 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
837 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
839 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
841 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
842 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
844 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
845 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
846 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
847 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
848 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
849 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
850 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
852 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
854 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
855 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
856 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
860 0ebf8283 2019-07-24 stsp for f in alpha beta; do
861 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
862 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
863 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
865 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
866 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
867 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
872 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
873 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
874 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
876 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
877 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
878 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
882 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
884 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
885 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
887 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
888 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
889 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
893 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
894 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
895 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
896 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
897 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
899 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
900 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
902 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
905 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
906 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
907 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
909 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
910 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
911 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
913 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
914 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
916 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
917 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
921 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
923 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
924 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
927 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
928 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
929 0160a755 2019-07-25 stsp test_done "$testroot" "1"
933 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
934 0160a755 2019-07-25 stsp > $testroot/stderr.expected
935 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
936 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
938 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
940 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
941 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
942 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
946 0160a755 2019-07-25 stsp rm -rf $testroot/wt
947 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
948 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
950 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
951 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
954 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
955 0160a755 2019-07-25 stsp > $testroot/stdout)
957 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
958 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
960 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
961 0160a755 2019-07-25 stsp > $testroot/stdout.expected
962 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
963 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
965 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
968 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
973 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
974 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
975 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
977 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
978 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
979 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
984 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
986 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
987 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
989 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
990 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
991 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
995 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
996 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
997 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
999 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1000 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1005 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1006 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1007 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1009 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1010 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1011 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1013 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1014 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1016 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1017 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1019 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1020 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1024 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1025 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
1027 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1028 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1031 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1032 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1033 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1037 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1038 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1039 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1040 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1042 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1044 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1045 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1050 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1051 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1052 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1054 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1055 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1058 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1059 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1061 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1063 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1064 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1065 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1066 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1068 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
1069 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1070 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1074 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1075 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1076 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1078 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1079 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1080 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1084 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1086 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1087 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1089 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1090 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1091 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1095 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1097 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1098 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1100 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1101 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1102 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1103 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1104 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1106 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1109 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1110 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1114 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1115 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1116 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1117 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1119 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1120 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1121 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1125 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1126 b2c50a0a 2019-07-25 stsp > $testroot/diff
1127 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1128 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1130 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1131 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1133 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1136 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1137 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1138 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1140 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1142 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1143 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1144 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1148 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1150 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1151 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1153 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1154 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1155 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1158 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1160 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1162 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1163 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1164 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1168 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1170 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1171 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1172 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1176 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1177 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1178 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1180 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1181 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1182 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1183 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1184 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1186 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1187 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1189 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1192 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1193 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1195 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1197 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1198 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1199 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1200 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1201 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1202 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1204 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1205 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1206 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1208 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1210 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1211 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1215 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1216 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1217 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1218 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1220 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1221 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1224 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1225 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1226 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1230 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1232 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1233 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1234 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1236 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1237 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1238 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1239 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1240 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1241 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1242 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1243 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1244 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1245 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1246 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1247 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1249 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1251 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1252 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1254 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1257 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1258 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1260 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1262 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1263 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1264 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1265 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1266 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1267 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1268 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1270 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1271 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1272 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1273 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1275 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1277 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1278 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1282 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1283 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1284 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1286 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1287 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1289 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1290 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1291 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1292 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1296 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1297 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1298 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1299 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1300 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1302 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1304 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1305 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1306 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1310 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1312 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1313 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1314 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1318 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1320 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1321 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1322 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1326 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1328 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1329 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1330 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1334 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1335 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1337 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1338 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1339 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1340 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1343 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1344 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1346 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1347 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1348 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1349 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1350 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1351 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1352 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1354 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1356 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1357 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1359 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1363 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1364 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1366 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1368 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1369 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1370 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1371 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1372 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1373 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1375 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1376 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1377 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1379 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1381 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1382 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1386 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1387 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1388 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1389 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1391 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1392 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1394 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1395 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1396 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1397 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1401 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1402 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1403 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1405 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1407 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1408 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1410 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1414 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1415 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1416 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1417 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1419 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1421 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1422 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1423 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1424 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1426 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1427 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1428 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1430 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1431 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1432 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1434 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1436 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1437 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1441 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1442 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1443 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1444 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1446 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1447 ecfff807 2020-09-23 stsp > $testroot/stdout)
1449 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1451 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1452 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1453 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1454 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1456 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1457 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1458 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1459 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1460 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1461 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1462 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1463 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1464 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1465 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1466 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1468 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1470 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1471 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1472 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1476 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1477 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1478 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1482 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1484 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1485 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1487 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1488 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1489 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1493 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1494 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1495 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1497 29c68398 2020-09-24 stsp if [ "$ret" != "0" ]; then
1498 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1499 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1503 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1504 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1505 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1507 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1508 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1510 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1513 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1514 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1516 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1518 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1519 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1520 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1521 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1522 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1523 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1525 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1526 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1527 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1529 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1530 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1531 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1533 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1535 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1536 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1540 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1542 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1544 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1546 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1547 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1549 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1551 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1552 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1553 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1554 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1555 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1557 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1558 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1559 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1560 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1561 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1562 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1563 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1564 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1565 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1566 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1567 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1568 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1569 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1570 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1571 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1573 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1575 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1576 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1577 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1581 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1582 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1583 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1585 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1586 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1587 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1591 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1592 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1593 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1597 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1598 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1599 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1601 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1602 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1603 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1607 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1609 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1610 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1612 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1613 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1614 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1618 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1619 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1620 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1621 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1623 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1624 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1626 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1629 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1630 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1632 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1634 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1635 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1636 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1637 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1638 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1639 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1641 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1642 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1643 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1645 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1646 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1647 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1649 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1651 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1652 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1656 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1658 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1660 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1662 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1663 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1665 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1667 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1668 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1669 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1670 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1671 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1672 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1674 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1675 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1676 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1677 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1678 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1679 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1680 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1681 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1682 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1683 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1684 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1685 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1686 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1687 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1688 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1689 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1691 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1693 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1694 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1695 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1699 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1700 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1701 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1703 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1704 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1705 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1709 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1710 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1711 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1715 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1716 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1717 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1719 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1720 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1721 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1725 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1727 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1728 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1730 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1731 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1732 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1736 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1737 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1738 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1739 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1741 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1742 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1744 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1747 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1748 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1749 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1750 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1751 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1752 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1753 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1754 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1755 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1756 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1757 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
1758 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
1759 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
1760 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
1761 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
1762 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
1763 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
1764 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg