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
175 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
178 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
179 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
181 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
183 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
184 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
185 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
186 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
187 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
188 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
190 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
191 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
192 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
194 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
195 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
197 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
199 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
200 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
204 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
205 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
207 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
208 0ebf8283 2019-07-24 stsp > $testroot/stdout)
210 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
211 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
213 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
214 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
215 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
216 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
218 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
219 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
220 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
221 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
222 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
223 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
224 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
225 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
226 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
227 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
228 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
230 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
232 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
233 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
234 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
238 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
239 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
240 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
242 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
243 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
244 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
248 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
249 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
250 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
254 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
255 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
256 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
258 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
259 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
260 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
264 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
266 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
267 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
269 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
270 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
271 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
275 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
276 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
277 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
278 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
279 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
281 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
282 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
287 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
288 86ac67ee 2019-07-25 stsp > $testroot/diff
289 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
290 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
292 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
293 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
295 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
298 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
299 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
300 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
302 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
303 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
304 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
305 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
306 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
307 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
309 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
310 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
311 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
313 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
314 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
316 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
318 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
319 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
323 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
324 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
326 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
327 0ebf8283 2019-07-24 stsp > $testroot/stdout)
329 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
331 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
332 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
333 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
335 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
336 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
337 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
338 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
339 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
340 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
341 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
342 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
344 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
346 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
347 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
348 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
352 0ebf8283 2019-07-24 stsp for f in alpha beta; do
353 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
354 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
355 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
357 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
358 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
359 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
364 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
365 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
366 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
370 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
372 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
373 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
375 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
376 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
381 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
382 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
383 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
384 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
386 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
387 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
388 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
392 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
393 86ac67ee 2019-07-25 stsp > $testroot/diff
394 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
395 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
396 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
398 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
399 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
401 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
404 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
405 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
407 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
409 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
410 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
411 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
412 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
413 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
414 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
416 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
417 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
418 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
420 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
421 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
422 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
424 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
426 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
427 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
431 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
432 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
433 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
434 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
436 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
437 0ebf8283 2019-07-24 stsp > $testroot/stdout)
439 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
440 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
442 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
443 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
444 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
445 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
446 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
448 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
449 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
450 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
451 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
452 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
453 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
454 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
455 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
456 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
457 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
458 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
459 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
460 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
461 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
463 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
465 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
466 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
467 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
471 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
472 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
473 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
475 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
476 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
477 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
481 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
482 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
483 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
487 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
488 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
489 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
491 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
492 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
493 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
497 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
499 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
500 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
502 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
503 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
504 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
508 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
509 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
510 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
511 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
513 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
514 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
516 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
519 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
520 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
522 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
524 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
525 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
526 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
527 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
528 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
529 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
531 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
532 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
533 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
535 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
537 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
538 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
542 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
543 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
544 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
546 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
547 0ebf8283 2019-07-24 stsp > $testroot/stdout)
549 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
550 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
552 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
553 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
554 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
555 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
556 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
557 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
559 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
560 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
561 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
565 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
567 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
568 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
569 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
570 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
572 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
573 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
574 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
577 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
578 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
579 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
580 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
581 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
583 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
584 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
585 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
589 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
590 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
592 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
593 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
595 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
596 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
598 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
599 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
600 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
601 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
602 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
603 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
604 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
605 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
607 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
609 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
610 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
611 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
615 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
616 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
617 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
619 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
620 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
621 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
625 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
626 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
627 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
631 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
632 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
633 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
635 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
636 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
637 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
641 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
643 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
644 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
646 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
647 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
652 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
653 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
654 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
655 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
656 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
658 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
659 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
661 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
664 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
665 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
667 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
669 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
670 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
671 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
672 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
673 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
674 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
676 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
677 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
678 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
680 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
682 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
683 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
687 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
688 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
689 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
691 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
692 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
695 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
696 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
697 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
701 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
702 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
704 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
706 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
707 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
709 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
712 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
713 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
715 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
717 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
718 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
719 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
720 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
721 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
722 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
724 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
725 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
726 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
728 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
730 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
731 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
735 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
736 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
738 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
739 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
742 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
743 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
744 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
748 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
749 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
751 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
753 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
754 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
756 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
759 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
760 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
762 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
764 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
765 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
766 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
767 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
768 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
769 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
771 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
772 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
773 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
775 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
777 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
778 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
782 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
783 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
784 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
786 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
787 0ebf8283 2019-07-24 stsp > $testroot/stdout)
789 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
790 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
792 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
793 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
794 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
795 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
796 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
797 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
799 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
800 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
801 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
805 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
807 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
809 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
810 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
812 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
813 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
814 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
815 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
816 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
817 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
818 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
820 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
822 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
823 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
824 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
828 0ebf8283 2019-07-24 stsp for f in alpha beta; do
829 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
830 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
831 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
833 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
834 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
835 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
840 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
841 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
842 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
844 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
845 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
846 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
850 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
852 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
853 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
855 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
856 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
857 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
861 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
862 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
863 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
864 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
865 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
867 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
868 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
870 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
873 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
874 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
875 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
877 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
878 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
879 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
881 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
882 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
884 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
885 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
889 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
891 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
892 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
895 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
896 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
897 0160a755 2019-07-25 stsp test_done "$testroot" "1"
901 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
902 0160a755 2019-07-25 stsp > $testroot/stderr.expected
903 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
904 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
906 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
908 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
909 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
910 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
914 0160a755 2019-07-25 stsp rm -rf $testroot/wt
915 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
916 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
918 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
919 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
922 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
923 0160a755 2019-07-25 stsp > $testroot/stdout)
925 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
926 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
928 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
929 0160a755 2019-07-25 stsp > $testroot/stdout.expected
930 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
931 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
933 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
935 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
936 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
937 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
941 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
942 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
943 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
945 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
946 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
947 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
952 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
954 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
955 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
957 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
958 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
959 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
963 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
964 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
965 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
968 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
970 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
973 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
974 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
975 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
977 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
978 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
979 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
981 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
982 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
984 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
985 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
987 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
988 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
992 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
993 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
995 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
996 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
999 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1000 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1001 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1005 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1006 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1007 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1008 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1010 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1012 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1013 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1014 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1018 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1019 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1020 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1022 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1023 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1026 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1027 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1029 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1031 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1032 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1033 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1034 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1036 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
1037 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1038 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1042 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1043 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1044 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1046 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1047 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1048 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1052 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1054 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1055 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1057 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1058 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1059 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1063 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1065 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1066 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1068 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1069 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1070 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1071 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1072 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1074 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1076 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1077 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1078 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1082 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1083 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1084 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1085 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1087 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1088 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1089 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1093 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1094 b2c50a0a 2019-07-25 stsp > $testroot/diff
1095 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1096 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1098 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1099 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1101 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1104 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1105 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1106 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1108 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1110 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1111 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1112 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1116 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1118 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1119 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1121 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1122 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1123 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1126 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1128 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1130 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1131 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1132 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1136 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1138 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1139 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1140 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1144 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1145 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1146 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1148 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1149 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1150 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1151 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1152 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1154 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1155 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1157 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1160 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1161 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1163 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1165 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1166 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1167 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1168 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1169 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1170 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1172 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1173 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1174 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1176 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1178 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1179 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1183 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1184 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1185 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1186 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1188 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1189 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1192 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1193 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1194 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1198 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1200 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1201 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1202 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1204 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1205 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1206 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1207 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1208 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1209 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1210 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1211 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1212 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1213 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1214 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1215 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1217 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1219 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1220 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1222 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1225 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1226 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1228 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1230 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1231 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1232 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1233 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1234 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1235 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1236 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1238 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1239 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1240 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1241 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1243 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1245 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1246 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1250 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1251 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1252 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1254 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1255 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1257 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1258 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1259 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1260 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1264 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1265 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1266 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1267 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1268 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1270 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1272 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1273 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1278 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1280 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1281 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1282 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1286 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1288 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1289 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1290 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1294 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1296 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1297 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1298 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1302 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1303 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1305 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1306 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1307 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1308 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1311 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1312 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1314 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1315 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1316 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1317 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1318 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1319 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1320 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1322 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1324 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1325 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1327 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1331 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1332 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1334 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1336 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1337 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1338 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1339 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1340 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1341 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1343 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1344 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1345 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1347 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1349 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1350 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1354 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1355 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1356 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1357 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1359 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1360 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1362 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1363 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1364 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1365 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1369 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1370 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1371 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1373 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1375 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1376 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1378 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1382 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1383 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1384 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1385 ecfff807 2020-09-23 stsp local testroot=`test_init histedit_fold`
1387 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1389 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1390 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1391 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1392 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1394 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1395 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1396 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1398 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1399 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1400 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1402 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1404 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1405 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1409 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1410 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1411 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1412 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1414 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1415 ecfff807 2020-09-23 stsp > $testroot/stdout)
1417 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1419 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1420 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1421 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1422 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1424 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1425 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1426 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1427 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1428 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1429 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1430 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1431 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1432 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1433 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1434 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1436 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1438 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1439 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1440 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1444 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1445 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1446 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1450 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1452 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1453 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1455 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1456 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1457 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1461 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1462 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1463 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1465 29c68398 2020-09-24 stsp if [ "$ret" != "0" ]; then
1466 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1467 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1471 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1472 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1473 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1475 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1476 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1478 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1481 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1482 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1484 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1486 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1487 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1488 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1489 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1490 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1491 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1493 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1494 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1495 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1497 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1498 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1499 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1501 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1503 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1504 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1508 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1510 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1512 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1514 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1515 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1517 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1519 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1520 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1521 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1522 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1523 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1525 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1526 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1527 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1528 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1529 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1530 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1531 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1532 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1533 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1534 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1535 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1536 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1537 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1538 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1539 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1541 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1543 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1544 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1545 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1549 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1550 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1551 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1553 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1554 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1555 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1559 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1560 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1561 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1565 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1566 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1567 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1569 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1570 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1571 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1575 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1577 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1578 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1580 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1581 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1582 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1586 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1587 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1588 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1589 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1591 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1592 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1594 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1597 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1598 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1600 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1602 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1603 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1604 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1605 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1606 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1607 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1609 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1610 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1611 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1613 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1614 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1615 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1617 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1619 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1620 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1624 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1626 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1628 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1630 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1631 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1633 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1635 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1636 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1637 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1638 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1639 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1640 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1642 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1643 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1644 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1645 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1646 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1647 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1648 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1649 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1650 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1651 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1652 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1653 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1654 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1655 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1656 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1657 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1659 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1661 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1662 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1663 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1667 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1668 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1669 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1671 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1672 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1673 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1677 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1678 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1679 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1683 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1684 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1685 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1687 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1688 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1689 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1693 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1695 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1696 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1698 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1699 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1700 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1704 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1705 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1706 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1707 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1709 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1710 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1712 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1715 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1716 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1717 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1718 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1719 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1720 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1721 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1722 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1723 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1724 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1725 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
1726 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
1727 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
1728 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
1729 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
1730 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
1731 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
1732 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg