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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
27 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
28 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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`
31 ad324bf5 2021-09-21 stsp local old_author_time1=`git_show_author_time $testroot/repo`
33 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
34 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
35 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
36 e600f124 2021-03-21 stsp local old_author_time2=`git_show_author_time $testroot/repo`
38 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
39 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
41 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
43 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
44 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
48 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
49 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
51 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
52 0ebf8283 2019-07-24 stsp > $testroot/stdout)
54 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
55 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
56 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
58 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
59 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
60 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
61 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
63 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
66 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
67 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
69 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
70 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
71 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
72 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
73 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
75 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
77 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
78 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
83 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
84 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
85 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
89 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
93 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
94 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
95 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
99 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
100 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
101 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
104 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
105 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
109 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
111 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
112 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
114 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
115 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
116 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
120 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
121 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
122 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
123 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
124 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
126 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
127 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
128 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
132 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
133 86ac67ee 2019-07-25 stsp > $testroot/diff
134 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
135 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
138 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
140 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
141 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
142 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
146 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
148 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
149 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
151 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
152 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
157 e600f124 2021-03-21 stsp # We should have a backup of old commits
158 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
159 ad324bf5 2021-09-21 stsp d_orig1=`date -u -r $old_author_time1 +"%G-%m-%d"`
160 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
162 3a6b8760 2021-08-31 naddy d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
163 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
164 e600f124 2021-03-21 stsp -----------------------------------------------
165 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
166 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
167 e600f124 2021-03-21 stsp date: $d_orig2
169 e600f124 2021-03-21 stsp committing to zeta on master
171 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
172 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
175 ad324bf5 2021-09-21 stsp local is_forked=true d_fork fork_commit fork_commit_msg
177 ad324bf5 2021-09-21 stsp if [ "$old_commit1" = "$new_commit1" ]; then
178 ad324bf5 2021-09-21 stsp if [ "$old_commit2" = "$new_commit2" ]; then
179 ad324bf5 2021-09-21 stsp is_forked=false
181 ad324bf5 2021-09-21 stsp d_fork=$d_orig1
182 ad324bf5 2021-09-21 stsp fork_commit=$new_commit1
183 ad324bf5 2021-09-21 stsp fork_commit_msg="committing changes"
186 ad324bf5 2021-09-21 stsp d_fork=$d_orig
187 ad324bf5 2021-09-21 stsp fork_commit=$orig_commit
188 ad324bf5 2021-09-21 stsp fork_commit_msg="adding the test tree"
191 ad324bf5 2021-09-21 stsp $is_forked && cat >> $testroot/stdout.expected <<EOF
192 ad324bf5 2021-09-21 stsp history forked at $fork_commit
193 ad324bf5 2021-09-21 stsp $d_fork $GOT_AUTHOR_11 $fork_commit_msg
196 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
198 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
199 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
200 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
204 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
205 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
206 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
207 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
208 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
209 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
210 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
213 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
217 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
219 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
220 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
225 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
226 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
227 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
235 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
236 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
238 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
240 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
241 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
242 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
243 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
244 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
245 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
247 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
248 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
249 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
251 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
252 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
254 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
257 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
261 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
262 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
264 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
265 0ebf8283 2019-07-24 stsp > $testroot/stdout)
267 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
268 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
270 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
271 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
272 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
273 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
275 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
276 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
277 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
278 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
279 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
280 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
281 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
282 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
283 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
284 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
285 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
287 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
290 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
295 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
296 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
297 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
300 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
301 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
305 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
306 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
307 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
311 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
312 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
313 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
317 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
321 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
323 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
324 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
327 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
332 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
333 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
334 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
335 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
336 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
338 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
339 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
344 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
345 86ac67ee 2019-07-25 stsp > $testroot/diff
346 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
347 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit1/
350 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
353 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
355 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
358 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
359 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
360 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
362 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
363 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
364 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
365 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
366 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
367 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
369 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
370 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
371 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
373 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
374 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
376 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
379 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
383 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
384 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
386 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
387 0ebf8283 2019-07-24 stsp > $testroot/stdout)
389 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
391 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
392 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
393 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
395 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
396 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
397 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
398 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
399 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
400 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
401 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
402 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
404 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
406 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
407 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
412 0ebf8283 2019-07-24 stsp for f in alpha beta; do
413 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
414 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
415 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
419 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
424 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
425 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
426 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
430 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
432 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
433 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
435 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
436 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
441 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
442 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
443 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
444 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
452 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
453 86ac67ee 2019-07-25 stsp > $testroot/diff
454 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
455 885e96df 2023-03-06 naddy ,s/$old_commit1/$orig_commit/
456 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
459 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
461 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
462 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
464 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
467 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
468 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
470 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
472 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
473 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
474 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
475 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
476 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
477 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
479 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
480 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
481 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
483 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
484 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
485 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
487 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
490 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
494 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
496 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
497 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
501 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
503 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
504 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
505 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
507 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
508 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
509 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
511 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
512 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
514 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
515 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
516 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
517 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
518 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
520 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
521 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
522 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
523 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
524 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
525 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
526 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
527 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
528 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
529 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
530 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
531 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
532 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
533 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
535 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
537 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
538 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
543 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
544 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
545 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
549 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
553 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
554 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
555 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
559 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
560 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
561 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
564 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
565 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
569 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
571 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
572 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
575 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
580 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
581 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
582 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
583 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
585 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
586 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
588 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
591 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
592 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
594 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
596 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
597 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
598 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
599 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
600 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
601 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
603 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
604 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
605 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
607 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
609 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
610 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
614 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
615 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
617 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
618 0ebf8283 2019-07-24 stsp > $testroot/stdout)
620 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
621 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
623 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
624 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
625 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
626 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
627 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
628 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
630 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
631 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
632 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
636 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
638 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
639 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
640 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
641 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
643 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
644 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
645 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
648 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
649 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
650 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
651 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
652 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
654 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
655 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
656 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
660 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
662 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
664 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
665 14eb0fef 2023-10-26 stsp ,s/.*/committing changes/
669 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
671 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
672 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
673 14eb0fef 2023-10-26 stsp got histedit -c > $testroot/stdout)
675 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
676 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
678 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
679 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
681 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
682 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
683 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
684 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
685 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
686 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
687 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
688 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
690 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
698 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
699 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
700 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
702 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
703 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
704 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
708 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
709 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
710 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
714 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
715 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
716 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
719 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
720 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
724 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
726 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
727 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
729 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
730 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
731 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
735 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
736 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
737 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
738 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
739 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
741 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
742 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
744 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
747 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
748 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
750 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
752 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
753 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
754 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
755 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
756 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
757 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
759 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
760 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
761 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
763 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
765 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
766 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
770 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
771 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
773 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
774 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
777 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
778 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
779 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
783 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
784 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
786 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
788 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
789 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
791 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
794 14eb0fef 2023-10-26 stsp test_histedit_missing_commit_pick() {
795 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
797 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
799 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
800 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
801 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
802 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
803 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
804 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
806 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
807 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
808 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
810 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
812 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
813 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
817 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
819 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
820 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
823 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
824 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
825 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
829 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
830 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
832 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
834 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
835 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
837 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
840 14eb0fef 2023-10-26 stsp test_histedit_missing_commit_mesg() {
841 14eb0fef 2023-10-26 stsp local testroot=`test_init histedit_missing_commit`
843 14eb0fef 2023-10-26 stsp local orig_commit=`git_show_head $testroot/repo`
845 14eb0fef 2023-10-26 stsp echo "modified alpha on master" > $testroot/repo/alpha
846 14eb0fef 2023-10-26 stsp git -C $testroot/repo rm -q beta
847 14eb0fef 2023-10-26 stsp echo "new file on master" > $testroot/repo/epsilon/new
848 14eb0fef 2023-10-26 stsp git -C $testroot/repo add epsilon/new
849 14eb0fef 2023-10-26 stsp git_commit $testroot/repo -m "committing changes"
850 14eb0fef 2023-10-26 stsp local old_commit1=`git_show_head $testroot/repo`
852 14eb0fef 2023-10-26 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
853 14eb0fef 2023-10-26 stsp git_commit $testroot/repo -m "committing to zeta on master"
854 14eb0fef 2023-10-26 stsp local old_commit2=`git_show_head $testroot/repo`
856 14eb0fef 2023-10-26 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
858 14eb0fef 2023-10-26 stsp if [ $ret -ne 0 ]; then
859 14eb0fef 2023-10-26 stsp test_done "$testroot" "$ret"
863 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
865 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
866 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
870 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
872 14eb0fef 2023-10-26 stsp echo "mesg $old_commit1" > $testroot/histedit-script
874 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
875 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
876 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout \
877 14eb0fef 2023-10-26 stsp 2>$testroot/stderr)
880 14eb0fef 2023-10-26 stsp if [ $ret -eq 0 ]; then
881 14eb0fef 2023-10-26 stsp echo "histedit succeeded unexpectedly" >&2
882 14eb0fef 2023-10-26 stsp test_done "$testroot" "1"
886 14eb0fef 2023-10-26 stsp echo "got: commit $old_commit2 missing from histedit script" \
887 14eb0fef 2023-10-26 stsp > $testroot/stderr.expected
889 14eb0fef 2023-10-26 stsp cmp -s $testroot/stderr.expected $testroot/stderr
891 14eb0fef 2023-10-26 stsp if [ $ret -ne 0 ]; then
892 14eb0fef 2023-10-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
894 14eb0fef 2023-10-26 stsp test_done "$testroot" "$ret"
897 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
898 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
900 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
902 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
903 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
904 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
905 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
906 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
907 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
909 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
910 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
911 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
913 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
915 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
916 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
920 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
921 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
923 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
924 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
926 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
927 0ebf8283 2019-07-24 stsp > $testroot/stdout)
929 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
930 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
932 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
933 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
934 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
935 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
936 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
937 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
940 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
945 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
947 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
949 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
950 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
952 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
953 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
954 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
955 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
956 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
957 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
958 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
960 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
962 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
963 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
964 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
968 0ebf8283 2019-07-24 stsp for f in alpha beta; do
969 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
970 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
971 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
975 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
980 af179be7 2023-04-14 stsp if [ -e $testroot/wt/epsilon/new ]; then
981 af179be7 2023-04-14 stsp echo "removed file new still exists on disk" >&2
982 af179be7 2023-04-14 stsp test_done "$testroot" "1"
986 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
988 af179be7 2023-04-14 stsp echo "? unversioned-file" > $testroot/stdout.expected
989 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
991 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
992 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
993 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
997 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
998 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
999 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1000 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1001 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1004 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1006 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1009 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
1010 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
1011 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1013 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1014 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1015 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1017 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1018 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
1020 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1021 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1025 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
1027 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1028 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1031 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1032 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1033 0160a755 2019-07-25 stsp test_done "$testroot" "1"
1037 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1038 0160a755 2019-07-25 stsp > $testroot/stderr.expected
1039 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1040 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
1042 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1050 0160a755 2019-07-25 stsp rm -rf $testroot/wt
1051 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1052 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
1054 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1055 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1058 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1059 0160a755 2019-07-25 stsp > $testroot/stdout)
1061 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1062 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1064 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
1065 0160a755 2019-07-25 stsp > $testroot/stdout.expected
1066 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1067 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
1069 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1073 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1077 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
1078 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1079 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1081 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1082 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1083 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1088 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1090 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
1091 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1093 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1094 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1095 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1099 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1100 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
1101 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1104 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1106 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1109 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1110 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1111 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1113 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1114 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1115 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1117 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1118 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1120 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1121 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1123 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1124 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1128 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1130 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1131 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1134 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1135 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1136 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1140 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1141 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1142 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1143 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1145 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1147 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1148 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1149 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1153 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1154 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1155 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1157 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1158 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1161 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1162 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1164 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1166 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1167 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1168 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1169 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1173 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1177 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1178 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1179 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1181 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1182 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1183 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1187 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1189 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1190 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1192 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1193 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1194 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1198 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1200 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1201 14eb0fef 2023-10-26 stsp ,s/.*/modified zeta/
1205 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1207 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1208 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1209 14eb0fef 2023-10-26 stsp got histedit -c > $testroot/stdout)
1211 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1212 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1214 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1215 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1216 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1217 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1218 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1220 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1222 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1223 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1224 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1228 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1229 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1230 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1231 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1234 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1239 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1240 b2c50a0a 2019-07-25 stsp > $testroot/diff
1241 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
1242 885e96df 2023-03-06 naddy ,s/$old_commit1/$new_commit1/
1245 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1248 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1250 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1253 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1254 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1255 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1257 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1259 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1260 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1261 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1265 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1267 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1268 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1272 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1275 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1277 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1280 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1281 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1285 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1287 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1288 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1289 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1293 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1294 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1295 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1297 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1298 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1299 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1300 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1301 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1303 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1304 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1306 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1309 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1310 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1312 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1314 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1315 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1316 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1317 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1318 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1319 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1321 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1322 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1323 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1325 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1328 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1332 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1334 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1335 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
1339 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1341 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1342 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1343 14eb0fef 2023-10-26 stsp echo "mesg $old_commit1" >> $testroot/histedit-script
1345 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1346 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1347 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout \
1348 14eb0fef 2023-10-26 stsp 2> $testroot/stderr)
1351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1352 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1353 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1357 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1359 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1360 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1361 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1363 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1364 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1365 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1366 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1367 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1368 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1369 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1370 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1371 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1372 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1373 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1374 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1376 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1379 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1381 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1384 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1385 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1387 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1389 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1390 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1391 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1392 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1393 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1394 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1395 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1397 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1398 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1399 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1400 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1402 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1404 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1405 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1409 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1410 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1411 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1413 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1414 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1416 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1417 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1418 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1419 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1423 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1424 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1425 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1426 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1427 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1429 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1431 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1432 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1433 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1437 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1439 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1440 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1441 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1445 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1447 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1448 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1449 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1453 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1455 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1456 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1457 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1461 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1462 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1465 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1466 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1467 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1470 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1471 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1473 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1474 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1475 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1476 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1477 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1478 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1479 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1481 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1483 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1484 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1486 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1490 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1491 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1493 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1495 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1496 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1497 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1498 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1499 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1500 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1502 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1503 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1504 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1506 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1508 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1509 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1513 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1514 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1515 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1516 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1518 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1519 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1521 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1522 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1523 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1524 ea4ee74a 2023-06-17 op test_done "$testroot" 1
1528 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1529 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1530 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1532 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1534 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1535 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1537 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1541 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1542 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1543 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1544 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1546 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1548 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1549 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/psi
1550 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1551 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1553 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1554 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1555 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1557 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q epsilon/psi
1558 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1559 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1561 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1564 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1568 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1570 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1571 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1575 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1577 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1578 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1579 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1581 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1582 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1583 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1585 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1587 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1588 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1589 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1590 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1592 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1593 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1594 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1595 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1596 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1597 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1598 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1599 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1600 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1601 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1602 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1604 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1607 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1608 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1612 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1613 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1614 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1618 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1620 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1621 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1623 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1624 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1625 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1629 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1630 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1631 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1633 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1634 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1635 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1639 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1640 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1641 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1644 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1646 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1649 c2ba7aa6 2023-07-26 stsp # if a previous commit edits a file, and it is folded into a commit
1650 c2ba7aa6 2023-07-26 stsp # that deletes the same file, the file will be deleted by histedit
1651 c2ba7aa6 2023-07-26 stsp test_histedit_fold_edit_delete() {
1652 c2ba7aa6 2023-07-26 stsp local testroot=`test_init histedit_fold_edit_delete`
1654 c2ba7aa6 2023-07-26 stsp local orig_commit=`git_show_head $testroot/repo`
1656 c2ba7aa6 2023-07-26 stsp echo "modify alpha" > $testroot/repo/alpha
1657 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add alpha
1658 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "modified alpha"
1659 c2ba7aa6 2023-07-26 stsp local old_commit1=`git_show_head $testroot/repo`
1661 c2ba7aa6 2023-07-26 stsp git_rm $testroot/repo alpha
1662 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "deleted alpha"
1663 c2ba7aa6 2023-07-26 stsp local old_commit2=`git_show_head $testroot/repo`
1665 c2ba7aa6 2023-07-26 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1667 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1668 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1672 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1674 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1675 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1679 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1681 c2ba7aa6 2023-07-26 stsp echo "fold $old_commit1" > $testroot/histedit-script
1682 c2ba7aa6 2023-07-26 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1684 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1685 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1686 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1688 c2ba7aa6 2023-07-26 stsp local new_commit1=`git_show_head $testroot/repo`
1690 c2ba7aa6 2023-07-26 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1691 c2ba7aa6 2023-07-26 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1692 c2ba7aa6 2023-07-26 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1694 c2ba7aa6 2023-07-26 stsp echo "G alpha" >> $testroot/stdout.expected
1695 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit1 -> fold commit: modified alpha" \
1696 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1697 c2ba7aa6 2023-07-26 stsp echo "D alpha" >> $testroot/stdout.expected
1698 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1699 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1700 c2ba7aa6 2023-07-26 stsp echo "Switching work tree to refs/heads/master" \
1701 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1703 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1705 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1706 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1707 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1711 c2ba7aa6 2023-07-26 stsp if [ -e $testroot/wt/alpha ]; then
1712 c2ba7aa6 2023-07-26 stsp echo "removed file alpha still exists on disk" >&2
1713 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "1"
1717 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1719 c2ba7aa6 2023-07-26 stsp echo -n > $testroot/stdout.expected
1720 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1722 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1723 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1724 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1728 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1729 c2ba7aa6 2023-07-26 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1730 c2ba7aa6 2023-07-26 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1731 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1733 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1734 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1737 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1740 15aed053 2023-03-07 naddy test_histedit_fold_delete_add() {
1741 15aed053 2023-03-07 naddy local testroot=`test_init histedit_fold_delete_add`
1743 15aed053 2023-03-07 naddy local orig_commit=`git_show_head $testroot/repo`
1745 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q alpha
1746 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "removing alpha"
1747 15aed053 2023-03-07 naddy local old_commit1=`git_show_head $testroot/repo`
1749 15aed053 2023-03-07 naddy echo "modified alpha" >$testroot/repo/alpha
1750 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add alpha
1751 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "add back modified alpha"
1752 15aed053 2023-03-07 naddy local old_commit2=`git_show_head $testroot/repo`
1754 15aed053 2023-03-07 naddy got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1756 15aed053 2023-03-07 naddy if [ $ret -ne 0 ]; then
1757 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1761 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1763 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1764 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1768 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1770 15aed053 2023-03-07 naddy echo "fold $old_commit1" > $testroot/histedit-script
1771 15aed053 2023-03-07 naddy echo "pick $old_commit2" >> $testroot/histedit-script
1773 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1774 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1775 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1777 15aed053 2023-03-07 naddy local new_commit1=`git_show_head $testroot/repo`
1779 15aed053 2023-03-07 naddy local short_old_commit1=`trim_obj_id 28 $old_commit1`
1780 15aed053 2023-03-07 naddy local short_old_commit2=`trim_obj_id 28 $old_commit2`
1781 15aed053 2023-03-07 naddy local short_new_commit1=`trim_obj_id 28 $new_commit1`
1783 15aed053 2023-03-07 naddy echo "D alpha" > $testroot/stdout.expected
1784 15aed053 2023-03-07 naddy echo "$short_old_commit1 -> fold commit: removing alpha" \
1785 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1786 15aed053 2023-03-07 naddy echo "A alpha" >> $testroot/stdout.expected
1787 15aed053 2023-03-07 naddy echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1788 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1789 15aed053 2023-03-07 naddy echo "Switching work tree to refs/heads/master" \
1790 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1792 9a298e5c 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1794 9a298e5c 2023-03-10 stsp if [ $ret -ne 0 ]; then
1795 9a298e5c 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1796 9a298e5c 2023-03-10 stsp test_done "$testroot" "$ret"
1800 15aed053 2023-03-07 naddy if [ ! -e $testroot/wt/alpha ]; then
1801 9a298e5c 2023-03-10 stsp echo "file alpha is missing on disk" >&2
1802 9a298e5c 2023-03-10 stsp test_done "$testroot" "1"
1806 5fdcbbb6 2023-03-14 naddy echo "modified alpha" > $testroot/content.expected
1807 5fdcbbb6 2023-03-14 naddy cat $testroot/wt/alpha > $testroot/content
1808 5fdcbbb6 2023-03-14 naddy cmp -s $testroot/content.expected $testroot/content
1810 5fdcbbb6 2023-03-14 naddy if [ $ret -ne 0 ]; then
1811 5fdcbbb6 2023-03-14 naddy diff -u $testroot/content.expected $testroot/content
1812 5fdcbbb6 2023-03-14 naddy test_done "$testroot" "$ret"
1815 9a298e5c 2023-03-10 stsp test_done "$testroot" "0"
1818 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1819 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1821 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1823 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1824 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1825 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1826 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1827 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1828 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1830 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1831 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1832 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1834 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1835 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1836 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1838 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1840 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1841 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1845 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1847 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1848 885e96df 2023-03-06 naddy ,s/.*/committing folded changes/
1852 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1854 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1855 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1857 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1859 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1860 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1861 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1862 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1863 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1865 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1866 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1867 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1868 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1869 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1870 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1871 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1872 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1873 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1874 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1875 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1876 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1877 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1878 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1879 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1881 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1883 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1884 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1885 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1889 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1890 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1891 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1893 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1894 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1895 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1899 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1900 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1901 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1905 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1906 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1907 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1909 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1910 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1911 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1915 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1917 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1918 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1920 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1921 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1922 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1926 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1927 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1928 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1929 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1931 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1932 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1934 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1937 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1938 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1940 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1942 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1943 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1944 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1945 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1946 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1947 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1949 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1950 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1951 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1953 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1954 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1955 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1957 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1959 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1960 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1964 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1966 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1971 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1973 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1974 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1976 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1978 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1979 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1980 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1981 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1982 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1983 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1985 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1986 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1987 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1988 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1989 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1990 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1991 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1992 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1993 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1994 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1995 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1996 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1997 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1998 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1999 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
2000 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
2002 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2004 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2005 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2006 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2010 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
2011 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
2012 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
2014 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2015 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
2016 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2020 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
2021 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
2022 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
2026 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
2027 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
2028 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
2030 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2031 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
2032 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2036 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
2038 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
2039 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2041 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2042 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2043 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2047 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2048 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
2049 b93c7142 2021-10-01 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2050 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2052 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2053 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2055 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2058 b93c7142 2021-10-01 stsp test_histedit_edit_only() {
2059 b93c7142 2021-10-01 stsp local testroot=`test_init histedit_edit_only`
2061 b93c7142 2021-10-01 stsp local orig_commit=`git_show_head $testroot/repo`
2063 b93c7142 2021-10-01 stsp echo "modified alpha on master" > $testroot/repo/alpha
2064 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
2065 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/repo/epsilon/new
2066 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
2067 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing changes"
2068 b93c7142 2021-10-01 stsp local old_commit1=`git_show_head $testroot/repo`
2070 b93c7142 2021-10-01 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2071 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing to zeta on master"
2072 b93c7142 2021-10-01 stsp local old_commit2=`git_show_head $testroot/repo`
2074 b93c7142 2021-10-01 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2076 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2077 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2081 b93c7142 2021-10-01 stsp (cd $testroot/wt && got histedit -e > $testroot/stdout)
2083 b93c7142 2021-10-01 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2084 b93c7142 2021-10-01 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
2086 b93c7142 2021-10-01 stsp echo "G alpha" > $testroot/stdout.expected
2087 b93c7142 2021-10-01 stsp echo "D beta" >> $testroot/stdout.expected
2088 b93c7142 2021-10-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
2089 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit1" \
2090 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2091 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2093 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2094 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2095 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2099 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
2101 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
2103 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2104 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 1/
2108 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
2110 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2111 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2113 b93c7142 2021-10-01 stsp local new_commit1=$(cd $testroot/wt && got info | \
2114 b93c7142 2021-10-01 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
2115 b93c7142 2021-10-01 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2117 b93c7142 2021-10-01 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
2118 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
2119 b93c7142 2021-10-01 stsp echo "committing edited changes 1" >> $testroot/stdout.expected
2120 b93c7142 2021-10-01 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
2121 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit2" \
2122 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2123 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2125 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2126 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2127 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2131 b93c7142 2021-10-01 stsp echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2133 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
2135 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2136 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 2/
2140 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
2142 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2143 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2145 b93c7142 2021-10-01 stsp local new_commit2=`git_show_head $testroot/repo`
2146 b93c7142 2021-10-01 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
2148 b93c7142 2021-10-01 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
2149 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
2150 b93c7142 2021-10-01 stsp echo "committing edited changes 2" >> $testroot/stdout.expected
2151 b93c7142 2021-10-01 stsp echo "Switching work tree to refs/heads/master" \
2152 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2154 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2156 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2157 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2158 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2162 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/content.expected
2163 b93c7142 2021-10-01 stsp cat $testroot/wt/alpha > $testroot/content
2164 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2166 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2167 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2168 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2172 b93c7142 2021-10-01 stsp if [ -e $testroot/wt/beta ]; then
2173 b93c7142 2021-10-01 stsp echo "removed file beta still exists on disk" >&2
2174 b93c7142 2021-10-01 stsp test_done "$testroot" "1"
2178 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/content.expected
2179 b93c7142 2021-10-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
2180 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2182 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2183 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2184 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2188 b93c7142 2021-10-01 stsp (cd $testroot/wt && got status > $testroot/stdout)
2190 b93c7142 2021-10-01 stsp echo -n > $testroot/stdout.expected
2191 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2193 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2194 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2195 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2199 b93c7142 2021-10-01 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2200 b93c7142 2021-10-01 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2201 b93c7142 2021-10-01 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
2202 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2203 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2205 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2206 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2208 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2211 09209b8a 2021-10-08 stsp test_histedit_prepend_line() {
2212 09209b8a 2021-10-08 stsp local testroot=`test_init histedit_prepend_line`
2213 09209b8a 2021-10-08 stsp local orig_commit=`git_show_head $testroot/repo`
2215 09209b8a 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2217 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/alpha" <<EOF
2219 09209b8a 2021-10-08 stsp first line
2224 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content.expected
2226 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2227 09209b8a 2021-10-08 stsp alpha > /dev/null)
2229 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2230 09209b8a 2021-10-08 stsp echo "got commit failed unexpectedly" >&2
2231 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2235 09209b8a 2021-10-08 stsp local top_commit=`git_show_head $testroot/repo`
2236 09209b8a 2021-10-08 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2238 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2240 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2241 09209b8a 2021-10-08 stsp echo "got update failed unexpectedly" >&2
2242 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2246 09209b8a 2021-10-08 stsp (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2247 09209b8a 2021-10-08 stsp > /dev/null)
2249 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2250 09209b8a 2021-10-08 stsp echo "got histedit failed unexpectedly" >&2
2251 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2255 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content
2256 09209b8a 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
2258 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2259 09209b8a 2021-10-08 stsp diff -u $testroot/content.expected $testroot/content
2260 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2264 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2267 598eac43 2022-07-22 stsp test_histedit_resets_committer() {
2268 598eac43 2022-07-22 stsp local testroot=`test_init histedit_resets_committer`
2269 598eac43 2022-07-22 stsp local orig_commit=`git_show_head $testroot/repo`
2270 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
2272 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2274 598eac43 2022-07-22 stsp echo "modified alpha" > $testroot/wt/alpha
2276 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2277 598eac43 2022-07-22 stsp alpha > /dev/null)
2279 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2280 598eac43 2022-07-22 stsp echo "got commit failed unexpectedly" >&2
2281 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2285 598eac43 2022-07-22 stsp local top_commit=`git_show_head $testroot/repo`
2286 598eac43 2022-07-22 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2288 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2290 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2291 598eac43 2022-07-22 stsp echo "got update failed unexpectedly" >&2
2292 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2296 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2297 598eac43 2022-07-22 stsp got histedit -F "$testroot/histedit-script" > /dev/null)
2299 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2300 598eac43 2022-07-22 stsp echo "got histedit failed unexpectedly" >&2
2301 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2304 598eac43 2022-07-22 stsp local edited_commit=`git_show_head $testroot/repo`
2306 598eac43 2022-07-22 stsp # Original commit only had one author
2307 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $top_commit | \
2308 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2309 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2310 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2312 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2313 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2314 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2318 598eac43 2022-07-22 stsp # Edited commit should have new committer name added
2319 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $edited_commit | \
2320 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2321 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2322 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
2324 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2326 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2327 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2329 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2332 b2b3fce1 2022-10-29 op test_histedit_umask() {
2333 b2b3fce1 2022-10-29 op local testroot=`test_init histedit_umask`
2334 b2b3fce1 2022-10-29 op local orig_commit=`git_show_head "$testroot/repo"`
2336 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2338 b2b3fce1 2022-10-29 op echo "modified alpha" > $testroot/wt/alpha
2339 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2340 b2b3fce1 2022-10-29 op local commit1=`git_show_head "$testroot/repo"`
2342 b2b3fce1 2022-10-29 op echo "modified again" > $testroot/wt/alpha
2343 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2344 b2b3fce1 2022-10-29 op local commit2=`git_show_head "$testroot/repo"`
2346 b2b3fce1 2022-10-29 op echo "modified again!" > $testroot/wt/alpha
2347 b2b3fce1 2022-10-29 op echo "modify beta too!" > $testroot/wt/beta
2348 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2349 b2b3fce1 2022-10-29 op local commit3=`git_show_head "$testroot/repo"`
2351 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2353 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2354 b2b3fce1 2022-10-29 op echo "update to $orig_commit failed!" >&2
2355 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2359 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
2361 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
2362 14eb0fef 2023-10-26 stsp ,s/.*/folding changes/
2366 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
2368 b2b3fce1 2022-10-29 op echo fold $commit1 >$testroot/histedit-script
2369 b2b3fce1 2022-10-29 op echo fold $commit2 >>$testroot/histedit-script
2370 b2b3fce1 2022-10-29 op echo pick $commit3 >>$testroot/histedit-script
2372 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
2373 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && \
2374 14eb0fef 2023-10-26 stsp env EDITOR="$testroot/editor.sh" VISUAL="$testroot/editor.sh" \
2375 b2b3fce1 2022-10-29 op got histedit -F "$testroot/histedit-script") >/dev/null
2378 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2379 b2b3fce1 2022-10-29 op echo "histedit operation failed" >&2
2380 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
2384 b2b3fce1 2022-10-29 op for f in alpha beta; do
2385 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2386 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
2387 b2b3fce1 2022-10-29 op echo "$f is not 0600 after histedi" >&2
2388 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
2389 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2394 b2b3fce1 2022-10-29 op test_done "$testroot" 0
2397 c48f94a4 2023-01-29 stsp test_histedit_mesg_filemode_change() {
2398 c48f94a4 2023-01-29 stsp local testroot=`test_init histedit_mode_change`
2400 c48f94a4 2023-01-29 stsp local orig_commit=`git_show_head $testroot/repo`
2401 c48f94a4 2023-01-29 stsp local orig_author_time=`git_show_author_time $testroot/repo`
2403 c48f94a4 2023-01-29 stsp chmod +x $testroot/repo/alpha
2404 c48f94a4 2023-01-29 stsp git_commit $testroot/repo -m "set x bit on alpha"
2405 c48f94a4 2023-01-29 stsp local old_commit1=`git_show_head $testroot/repo`
2406 c48f94a4 2023-01-29 stsp local old_author_time1=`git_show_author_time $testroot/repo`
2408 c48f94a4 2023-01-29 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2410 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2411 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2415 c48f94a4 2023-01-29 stsp if [ -x $testroot/wt/alpha ]; then
2416 c48f94a4 2023-01-29 stsp echo "file alpha has unexpected executable bit" >&2
2417 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2421 c48f94a4 2023-01-29 stsp cat > $testroot/editor.sh <<EOF
2423 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2424 885e96df 2023-03-06 naddy ,s/ x bit / executable bit /
2429 c48f94a4 2023-01-29 stsp chmod +x $testroot/editor.sh
2431 71a61c8c 2023-01-29 stsp (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2432 c48f94a4 2023-01-29 stsp got histedit -m > $testroot/stdout)
2434 c48f94a4 2023-01-29 stsp local new_commit1=`git_show_head $testroot/repo`
2435 c48f94a4 2023-01-29 stsp local new_author_time1=`git_show_author_time $testroot/repo`
2437 c48f94a4 2023-01-29 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2438 c48f94a4 2023-01-29 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2440 c48f94a4 2023-01-29 stsp echo "G alpha" > $testroot/stdout.expected
2441 c48f94a4 2023-01-29 stsp echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2442 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2443 c48f94a4 2023-01-29 stsp echo "Switching work tree to refs/heads/master" \
2444 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2446 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2448 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2449 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2450 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2454 c48f94a4 2023-01-29 stsp echo "alpha" > $testroot/content.expected
2455 9f31ca1f 2023-01-29 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
2457 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2458 9f31ca1f 2023-01-29 stsp diff -u $testroot/content.expected $testroot/wt/alpha
2459 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2463 c48f94a4 2023-01-29 stsp if [ ! -x $testroot/wt/alpha ]; then
2464 c48f94a4 2023-01-29 stsp echo "file alpha lost its executable bit" >&2
2465 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2469 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got status > $testroot/stdout)
2471 c48f94a4 2023-01-29 stsp echo -n > $testroot/stdout.expected
2472 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2474 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2475 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2476 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2480 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2481 c48f94a4 2023-01-29 stsp > $testroot/stdout)
2483 c48f94a4 2023-01-29 stsp echo ' set executable bit on alpha' > $testroot/stdout.expected
2484 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2486 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2487 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2488 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2492 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2495 f1c9fe20 2023-01-30 mark test_histedit_drop_only() {
2496 f1c9fe20 2023-01-30 mark local testroot=`test_init histedit_drop_only`
2498 f1c9fe20 2023-01-30 mark local orig_commit=`git_show_head $testroot/repo`
2499 f1c9fe20 2023-01-30 mark local drop="-> drop commit:"
2500 f1c9fe20 2023-01-30 mark local dropmsg="commit changes to drop"
2502 f1c9fe20 2023-01-30 mark echo "modified alpha on master" > $testroot/repo/alpha
2503 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
2504 f1c9fe20 2023-01-30 mark echo "new file on master" > $testroot/repo/epsilon/new
2505 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
2507 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 1"
2508 f1c9fe20 2023-01-30 mark local drop_commit1=`git_show_head $testroot/repo`
2510 f1c9fe20 2023-01-30 mark echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2512 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 2"
2513 f1c9fe20 2023-01-30 mark local drop_commit2=`git_show_head $testroot/repo`
2515 f1c9fe20 2023-01-30 mark echo "modified delta on master" > $testroot/repo/gamma/delta
2517 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 3"
2518 f1c9fe20 2023-01-30 mark local drop_commit3=`git_show_head $testroot/repo`
2520 f1c9fe20 2023-01-30 mark got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2522 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2523 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2527 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got histedit -d > $testroot/stdout)
2528 f1c9fe20 2023-01-30 mark local new_commit1=`git_show_head $testroot/repo`
2530 f1c9fe20 2023-01-30 mark local short_commit1=`trim_obj_id 28 $drop_commit1`
2531 f1c9fe20 2023-01-30 mark local short_commit2=`trim_obj_id 28 $drop_commit2`
2532 f1c9fe20 2023-01-30 mark local short_commit3=`trim_obj_id 28 $drop_commit3`
2534 f1c9fe20 2023-01-30 mark echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2535 f1c9fe20 2023-01-30 mark echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2536 f1c9fe20 2023-01-30 mark echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2537 f1c9fe20 2023-01-30 mark echo "Switching work tree to refs/heads/master" \
2538 f1c9fe20 2023-01-30 mark >> $testroot/stdout.expected
2540 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2542 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2543 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2544 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2548 f1c9fe20 2023-01-30 mark echo "alpha" > $testroot/content.expected
2549 f1c9fe20 2023-01-30 mark cat $testroot/wt/alpha > $testroot/content
2550 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2552 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2553 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2554 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2558 f1c9fe20 2023-01-30 mark echo "zeta" > $testroot/content.expected
2559 f1c9fe20 2023-01-30 mark cat $testroot/wt/epsilon/zeta > $testroot/content
2560 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2562 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2563 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2564 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2568 f1c9fe20 2023-01-30 mark echo "delta" > $testroot/content.expected
2569 f1c9fe20 2023-01-30 mark cat $testroot/wt/gamma/delta > $testroot/content
2570 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2572 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2573 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2574 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2578 f1c9fe20 2023-01-30 mark if [ ! -e $testroot/wt/beta ]; then
2579 f1c9fe20 2023-01-30 mark echo "removed file beta should be restored" >&2
2580 f1c9fe20 2023-01-30 mark test_done "$testroot" "1"
2584 f1c9fe20 2023-01-30 mark if [ -e $testroot/wt/new ]; then
2585 f1c9fe20 2023-01-30 mark echo "new file should no longer exist" >&2
2586 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2590 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2592 f1c9fe20 2023-01-30 mark echo -n > $testroot/stdout.expected
2593 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2595 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2596 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2597 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2601 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2602 f1c9fe20 2023-01-30 mark echo "commit $orig_commit (master)" > $testroot/stdout.expected
2603 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2605 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2606 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2608 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2611 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2612 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
2613 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
2614 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
2615 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
2616 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
2617 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
2618 14eb0fef 2023-10-26 stsp run_test test_histedit_missing_commit_pick
2619 14eb0fef 2023-10-26 stsp run_test test_histedit_missing_commit_mesg
2620 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
2621 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
2622 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
2623 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
2624 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
2625 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
2626 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
2627 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
2628 c2ba7aa6 2023-07-26 stsp run_test test_histedit_fold_edit_delete
2629 15aed053 2023-03-07 naddy run_test test_histedit_fold_delete_add
2630 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
2631 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg
2632 b93c7142 2021-10-01 stsp run_test test_histedit_edit_only
2633 09209b8a 2021-10-08 stsp run_test test_histedit_prepend_line
2634 598eac43 2022-07-22 stsp run_test test_histedit_resets_committer
2635 b2b3fce1 2022-10-29 op run_test test_histedit_umask
2636 c48f94a4 2023-01-29 stsp run_test test_histedit_mesg_filemode_change
2637 f1c9fe20 2023-01-30 mark run_test test_histedit_drop_only