3 0ebf8283 2019-07-24 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 0ebf8283 2019-07-24 stsp # Permission to use, copy, modify, and distribute this software for any
6 0ebf8283 2019-07-24 stsp # purpose with or without fee is hereby granted, provided that the above
7 0ebf8283 2019-07-24 stsp # copyright notice and this permission notice appear in all copies.
9 0ebf8283 2019-07-24 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 0ebf8283 2019-07-24 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 0ebf8283 2019-07-24 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 0ebf8283 2019-07-24 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 0ebf8283 2019-07-24 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 0ebf8283 2019-07-24 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 0ebf8283 2019-07-24 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 0ebf8283 2019-07-24 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_histedit_no_op() {
20 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_no_op`
22 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
23 e600f124 2021-03-21 stsp local orig_author_time=`git_show_author_time $testroot/repo`
25 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
26 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
27 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
28 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
29 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
30 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
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 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
135 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
137 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
138 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
139 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
143 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
145 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
146 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
148 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
149 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
150 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 e600f124 2021-03-21 stsp # We should have a backup of old commits
155 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
156 ad324bf5 2021-09-21 stsp d_orig1=`date -u -r $old_author_time1 +"%G-%m-%d"`
157 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
158 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
159 3a6b8760 2021-08-31 naddy d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
160 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
161 e600f124 2021-03-21 stsp -----------------------------------------------
162 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
163 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
164 e600f124 2021-03-21 stsp date: $d_orig2
166 e600f124 2021-03-21 stsp committing to zeta on master
168 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
169 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
172 ad324bf5 2021-09-21 stsp local is_forked=true d_fork fork_commit fork_commit_msg
174 ad324bf5 2021-09-21 stsp if [ "$old_commit1" = "$new_commit1" ]; then
175 ad324bf5 2021-09-21 stsp if [ "$old_commit2" = "$new_commit2" ]; then
176 ad324bf5 2021-09-21 stsp is_forked=false
178 ad324bf5 2021-09-21 stsp d_fork=$d_orig1
179 ad324bf5 2021-09-21 stsp fork_commit=$new_commit1
180 ad324bf5 2021-09-21 stsp fork_commit_msg="committing changes"
183 ad324bf5 2021-09-21 stsp d_fork=$d_orig
184 ad324bf5 2021-09-21 stsp fork_commit=$orig_commit
185 ad324bf5 2021-09-21 stsp fork_commit_msg="adding the test tree"
188 ad324bf5 2021-09-21 stsp $is_forked && cat >> $testroot/stdout.expected <<EOF
189 ad324bf5 2021-09-21 stsp history forked at $fork_commit
190 ad324bf5 2021-09-21 stsp $d_fork $GOT_AUTHOR_11 $fork_commit_msg
193 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
196 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
197 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
201 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
202 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
203 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
204 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
205 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
206 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
207 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
210 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
211 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
214 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
216 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
217 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
218 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
222 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
223 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
224 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
227 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
232 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
233 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
235 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
237 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
238 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
239 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
240 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
241 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
242 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
244 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
245 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
246 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
248 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
249 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
251 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
253 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
254 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
258 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
259 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
261 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
262 0ebf8283 2019-07-24 stsp > $testroot/stdout)
264 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
265 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
267 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
268 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
269 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
270 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
272 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
273 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
274 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
275 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
276 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
277 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
278 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
279 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
280 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
281 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
282 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
284 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
287 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
288 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
292 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
293 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
294 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
296 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
297 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
298 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
302 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
303 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
304 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
308 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
309 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
310 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
313 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
314 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
318 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
320 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
321 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
323 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
324 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
325 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
329 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
330 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
331 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
332 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
333 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
335 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
336 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
337 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
341 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
342 86ac67ee 2019-07-25 stsp > $testroot/diff
343 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
344 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
346 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
347 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
349 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
352 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
353 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
354 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
356 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
357 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
358 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
359 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
360 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
361 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
363 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
364 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
365 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
367 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
368 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
370 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
372 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
373 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
377 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
378 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
380 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
381 0ebf8283 2019-07-24 stsp > $testroot/stdout)
383 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
385 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
386 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
387 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
389 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
390 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
391 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
392 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
393 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
394 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
395 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
396 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
398 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
400 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
401 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
402 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
406 0ebf8283 2019-07-24 stsp for f in alpha beta; do
407 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
408 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
409 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
411 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
412 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
413 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
418 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
419 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
420 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
424 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
426 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
427 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
429 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
430 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
431 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
435 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
436 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
437 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
438 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
440 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
441 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
442 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
446 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
447 86ac67ee 2019-07-25 stsp > $testroot/diff
448 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
449 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
450 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
453 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
455 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
458 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
459 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
461 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
463 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
464 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
465 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
466 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
467 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
468 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
470 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
471 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
472 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
474 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
475 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
476 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
478 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
480 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
481 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
485 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
486 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
487 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
488 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
490 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
491 0ebf8283 2019-07-24 stsp > $testroot/stdout)
493 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
494 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
496 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
497 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
498 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
499 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
500 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
502 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
503 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
504 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
505 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
506 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
507 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
508 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
509 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
510 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
511 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
512 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
513 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
514 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
515 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
517 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
519 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
520 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
521 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
525 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
526 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
527 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
529 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
530 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
531 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
535 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
536 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
537 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
541 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
542 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
543 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
545 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
546 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
547 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
551 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
553 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
554 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
556 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
557 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
558 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
562 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
563 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
564 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
565 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
567 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
568 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
570 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
573 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
574 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
576 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
578 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
579 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
580 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
581 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
582 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
583 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
585 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
586 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
587 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
589 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
591 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
592 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
596 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
597 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
598 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
600 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
601 0ebf8283 2019-07-24 stsp > $testroot/stdout)
603 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
604 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
606 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
607 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
608 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
609 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
610 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
611 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
613 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
614 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
615 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
619 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
621 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
622 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
623 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
624 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
626 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
627 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
628 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
631 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
632 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
633 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
634 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
635 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
637 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
638 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
639 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
643 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
644 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
646 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
647 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
649 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
650 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
652 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
653 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
654 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
655 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
656 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
657 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
658 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
659 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
661 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
663 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
664 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
665 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
669 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
670 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
671 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
673 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
674 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
675 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
679 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
680 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
681 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
685 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
686 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
687 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
689 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
690 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
691 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
695 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
697 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
698 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
700 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
701 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
702 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
706 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
707 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
708 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
709 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
710 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
712 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
713 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
715 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
718 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
719 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
721 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
723 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
724 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
725 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
726 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
727 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
728 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
730 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
731 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
732 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
734 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
736 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
737 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
741 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
742 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
744 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
745 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
748 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
749 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
750 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
754 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
755 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
757 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
759 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
760 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
762 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
765 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
766 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
768 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
770 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
771 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
772 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
773 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
774 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
775 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
777 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
778 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
779 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
781 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
783 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
784 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
788 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
789 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
791 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
792 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
795 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
796 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
797 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
801 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
802 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
804 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
806 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
807 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
809 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
812 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
813 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
815 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
817 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
818 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
819 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
820 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
821 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
822 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
824 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
825 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
826 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
828 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
830 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
831 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
835 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
836 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
838 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
839 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
840 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
842 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
843 0ebf8283 2019-07-24 stsp > $testroot/stdout)
845 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
846 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
848 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
849 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
850 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
851 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
852 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
853 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
855 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
856 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
857 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
861 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
863 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
865 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
866 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
868 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
869 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
870 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
871 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
872 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
873 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
874 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
876 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
878 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
879 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
880 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
884 0ebf8283 2019-07-24 stsp for f in alpha beta; do
885 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
886 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
887 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
889 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
890 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
891 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
896 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
897 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
898 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
900 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
901 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
902 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
906 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
908 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
909 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
910 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
912 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
913 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
914 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
918 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
919 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
920 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
921 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
922 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
924 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
925 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
927 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
930 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
931 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
932 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
934 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
935 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
936 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
938 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
939 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
941 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
942 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
946 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
948 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
949 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
952 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
953 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
954 0160a755 2019-07-25 stsp test_done "$testroot" "1"
958 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
959 0160a755 2019-07-25 stsp > $testroot/stderr.expected
960 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
961 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
963 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
965 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
966 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
967 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
971 0160a755 2019-07-25 stsp rm -rf $testroot/wt
972 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
973 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
975 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
976 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
979 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
980 0160a755 2019-07-25 stsp > $testroot/stdout)
982 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
983 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
985 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
986 0160a755 2019-07-25 stsp > $testroot/stdout.expected
987 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
988 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
990 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
992 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
993 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
994 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
998 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
999 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1000 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1002 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1003 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1004 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1009 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1011 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
1012 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1014 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1015 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1016 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1020 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1021 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
1022 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1024 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1025 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1027 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1030 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1031 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1032 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1034 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1035 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1036 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1038 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1039 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1041 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1042 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1049 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1050 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
1052 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1053 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1056 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1057 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1058 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1062 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1063 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1064 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1065 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1067 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1069 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1070 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1071 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1075 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1076 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1077 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1079 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1080 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1083 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1084 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1086 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1088 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1089 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1090 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1091 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1093 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1094 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1095 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1099 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1100 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1101 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1104 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1105 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1109 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1111 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1112 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1114 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1115 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1116 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1120 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1122 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1123 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1125 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1126 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1127 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1128 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1129 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1131 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1133 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1134 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1135 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1139 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1140 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1141 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1142 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1144 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1145 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1146 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1150 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1151 b2c50a0a 2019-07-25 stsp > $testroot/diff
1152 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1153 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1155 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1156 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1158 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1161 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1162 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1163 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1165 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1167 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1168 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1169 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1173 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1175 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1176 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1178 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1179 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1180 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1183 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1185 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1189 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1193 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1196 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1197 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1201 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1202 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1203 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1205 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1206 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1207 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1208 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1209 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1211 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1212 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1214 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1217 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1218 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1220 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1222 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1223 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1224 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1225 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1226 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1227 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1229 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1230 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1231 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1233 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1235 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1236 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1240 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1241 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1242 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1243 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1245 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1246 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1249 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1250 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1251 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1255 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1257 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1258 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1259 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1261 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1262 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1263 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1264 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1265 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1266 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1267 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1268 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1269 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1270 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1271 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1272 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1274 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1276 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1277 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1279 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1282 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1283 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1285 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1287 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1288 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1289 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1290 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1291 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1292 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1293 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1295 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1296 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1297 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1298 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1300 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1303 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1307 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1308 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1309 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1311 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1312 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1314 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1315 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1316 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1317 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1321 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1322 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1323 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1324 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1325 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1327 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1330 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1331 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1335 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1337 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1338 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1339 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1343 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1345 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1346 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1347 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1351 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1353 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1354 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1355 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1359 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1360 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1362 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1363 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1364 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1365 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1368 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1369 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1371 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1372 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1373 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1374 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1375 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1376 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1377 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1379 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1381 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1382 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1384 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1388 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1389 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1391 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1393 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1394 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1395 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1396 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1397 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1398 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1400 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1401 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1402 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1404 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1406 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1407 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1411 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1412 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1413 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1414 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1416 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1417 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1419 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1420 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1421 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1422 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1426 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1427 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1428 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1430 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1432 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1433 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1435 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1439 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1440 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1441 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1442 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1444 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1446 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1447 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1448 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1449 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1451 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1452 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1453 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1455 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1456 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1457 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1459 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1461 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1462 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1466 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1467 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1468 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1469 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1471 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1472 ecfff807 2020-09-23 stsp > $testroot/stdout)
1474 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1476 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1477 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1478 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1479 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1481 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1482 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1483 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1484 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1485 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1486 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1487 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1488 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1489 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1490 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1491 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1493 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1496 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1497 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1501 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1502 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1503 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1507 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1509 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1510 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1512 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1513 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1514 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1518 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1519 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1520 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1522 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1523 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1524 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1528 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1529 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1530 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1532 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1533 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1535 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1538 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1539 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1541 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1543 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1544 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1545 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1546 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1547 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1548 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1550 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1551 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1552 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1554 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1555 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1556 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1558 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1560 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1561 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1565 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1567 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1569 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1571 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1572 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1574 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1576 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1577 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1578 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1579 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1580 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1582 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1583 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1584 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1585 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1586 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1587 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1588 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1589 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1590 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1591 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1592 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1593 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1594 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1595 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1596 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1598 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1600 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1601 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1602 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1606 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1607 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1608 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1610 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1611 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1612 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1616 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1617 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1618 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1622 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1623 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1624 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1626 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1627 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1628 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1632 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1634 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1635 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1637 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1638 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1639 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1643 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1644 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1645 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1646 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1648 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1649 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1651 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1654 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1655 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1657 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1659 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1660 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1661 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1662 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1663 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1664 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1666 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1667 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1668 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1670 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1671 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1672 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1674 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1676 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1677 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1681 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1683 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1685 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1687 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1688 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1690 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1692 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1693 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1694 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1695 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1696 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1697 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1699 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1700 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1701 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1702 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1703 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1704 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1705 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1706 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1707 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1708 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1709 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1710 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1711 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1712 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1713 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1714 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1716 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1719 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1720 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1724 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1725 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1726 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1728 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1729 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1730 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1734 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1735 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1736 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1740 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1741 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1742 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1744 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1745 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1746 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1750 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1752 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1753 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1755 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1756 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1757 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1761 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1762 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1763 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1764 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1766 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1767 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1769 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1772 b93c7142 2021-10-01 stsp test_histedit_edit_only() {
1773 b93c7142 2021-10-01 stsp local testroot=`test_init histedit_edit_only`
1775 b93c7142 2021-10-01 stsp local orig_commit=`git_show_head $testroot/repo`
1777 b93c7142 2021-10-01 stsp echo "modified alpha on master" > $testroot/repo/alpha
1778 b93c7142 2021-10-01 stsp (cd $testroot/repo && git rm -q beta)
1779 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/repo/epsilon/new
1780 b93c7142 2021-10-01 stsp (cd $testroot/repo && git add epsilon/new)
1781 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing changes"
1782 b93c7142 2021-10-01 stsp local old_commit1=`git_show_head $testroot/repo`
1784 b93c7142 2021-10-01 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1785 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing to zeta on master"
1786 b93c7142 2021-10-01 stsp local old_commit2=`git_show_head $testroot/repo`
1788 b93c7142 2021-10-01 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1790 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1791 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1795 b93c7142 2021-10-01 stsp (cd $testroot/wt && got histedit -e > $testroot/stdout)
1797 b93c7142 2021-10-01 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1798 b93c7142 2021-10-01 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1800 b93c7142 2021-10-01 stsp echo "G alpha" > $testroot/stdout.expected
1801 b93c7142 2021-10-01 stsp echo "D beta" >> $testroot/stdout.expected
1802 b93c7142 2021-10-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1803 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit1" \
1804 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1805 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1807 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1808 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1809 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1813 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
1815 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
1817 b93c7142 2021-10-01 stsp sed -i 's/.*/committing edited changes 1/' "\$1"
1819 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
1821 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1822 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1824 b93c7142 2021-10-01 stsp local new_commit1=$(cd $testroot/wt && got info | \
1825 b93c7142 2021-10-01 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1826 b93c7142 2021-10-01 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1828 b93c7142 2021-10-01 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1829 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
1830 b93c7142 2021-10-01 stsp echo "committing edited changes 1" >> $testroot/stdout.expected
1831 b93c7142 2021-10-01 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1832 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit2" \
1833 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1834 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1836 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1837 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1838 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1842 b93c7142 2021-10-01 stsp echo "edited zeta on master" > $testroot/wt/epsilon/zeta
1844 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
1846 b93c7142 2021-10-01 stsp sed -i 's/.*/committing edited changes 2/' "\$1"
1848 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
1850 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1851 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1853 b93c7142 2021-10-01 stsp local new_commit2=`git_show_head $testroot/repo`
1854 b93c7142 2021-10-01 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1856 b93c7142 2021-10-01 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
1857 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
1858 b93c7142 2021-10-01 stsp echo "committing edited changes 2" >> $testroot/stdout.expected
1859 b93c7142 2021-10-01 stsp echo "Switching work tree to refs/heads/master" \
1860 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1862 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1864 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1865 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1866 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1870 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/content.expected
1871 b93c7142 2021-10-01 stsp cat $testroot/wt/alpha > $testroot/content
1872 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
1874 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1875 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
1876 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1880 b93c7142 2021-10-01 stsp if [ -e $testroot/wt/beta ]; then
1881 b93c7142 2021-10-01 stsp echo "removed file beta still exists on disk" >&2
1882 b93c7142 2021-10-01 stsp test_done "$testroot" "1"
1886 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/content.expected
1887 b93c7142 2021-10-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
1888 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
1890 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1891 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
1892 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1896 b93c7142 2021-10-01 stsp (cd $testroot/wt && got status > $testroot/stdout)
1898 b93c7142 2021-10-01 stsp echo -n > $testroot/stdout.expected
1899 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1901 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1902 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1903 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1907 b93c7142 2021-10-01 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1908 b93c7142 2021-10-01 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
1909 b93c7142 2021-10-01 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1910 b93c7142 2021-10-01 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1911 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1913 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1914 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1916 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1919 09209b8a 2021-10-08 stsp test_histedit_prepend_line() {
1920 09209b8a 2021-10-08 stsp local testroot=`test_init histedit_prepend_line`
1921 09209b8a 2021-10-08 stsp local orig_commit=`git_show_head $testroot/repo`
1923 09209b8a 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1925 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/alpha" <<EOF
1927 09209b8a 2021-10-08 stsp first line
1932 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content.expected
1934 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
1935 09209b8a 2021-10-08 stsp alpha > /dev/null)
1937 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
1938 09209b8a 2021-10-08 stsp echo "got commit failed unexpectedly" >&2
1939 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
1943 09209b8a 2021-10-08 stsp local top_commit=`git_show_head $testroot/repo`
1944 09209b8a 2021-10-08 stsp echo "pick $top_commit" > "$testroot/histedit-script"
1946 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
1948 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
1949 09209b8a 2021-10-08 stsp echo "got update failed unexpectedly" >&2
1950 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
1954 09209b8a 2021-10-08 stsp (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
1955 09209b8a 2021-10-08 stsp > /dev/null)
1957 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
1958 09209b8a 2021-10-08 stsp echo "got histedit failed unexpectedly" >&2
1959 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
1963 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content
1964 09209b8a 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
1966 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1967 09209b8a 2021-10-08 stsp diff -u $testroot/content.expected $testroot/content
1968 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
1972 09209b8a 2021-10-08 stsp test_done "$testroot" $ret
1975 f1e5aff4 2022-07-12 op test_histedit_mesg_invalid() {
1976 f1e5aff4 2022-07-12 op local testroot=`test_init mesg_invalid`
1978 f1e5aff4 2022-07-12 op local orig_commit=`git_show_head $testroot/repo`
1980 f1e5aff4 2022-07-12 op echo "modified alpha on master" > $testroot/repo/alpha
1981 f1e5aff4 2022-07-12 op (cd $testroot/repo && git rm -q beta)
1982 f1e5aff4 2022-07-12 op echo "new file on master" > $testroot/repo/epsilon/new
1983 f1e5aff4 2022-07-12 op (cd $testroot/repo && git add epsilon/new)
1984 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing changes'
1985 f1e5aff4 2022-07-12 op local old_commit1=`git_show_head $testroot/repo`
1987 f1e5aff4 2022-07-12 op echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1988 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing to zeto on master'
1989 f1e5aff4 2022-07-12 op local old_commit2=`git_show_head $testroot/repo`
1991 f1e5aff4 2022-07-12 op got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1993 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
1994 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
1998 f1e5aff4 2022-07-12 op # try with a leading mesg
2000 f1e5aff4 2022-07-12 op echo "mesg something something" > $testroot/histedit-script
2001 f1e5aff4 2022-07-12 op echo "pick $old_commit1" >> $testroot/histedit-script
2002 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2004 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2005 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2007 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2008 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2009 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2013 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2014 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2016 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2017 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2018 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2022 f1e5aff4 2022-07-12 op # try again with mesg -> mesg
2024 f1e5aff4 2022-07-12 op echo "pick $old_commit1" > $testroot/histedit-script
2025 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2026 f1e5aff4 2022-07-12 op echo "mesg something something else" >> $testroot/histedit-script
2027 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2029 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2030 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2032 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2033 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2034 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2038 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2039 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2041 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2042 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2043 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2047 f1e5aff4 2022-07-12 op # try again with drop -> mesg
2049 f1e5aff4 2022-07-12 op echo "drop $old_commit1" > $testroot/histedit-script
2050 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2051 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2053 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2054 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2056 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2057 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2058 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2062 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2063 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2065 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2066 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2067 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2071 f1e5aff4 2022-07-12 op # try again with fold -> mesg
2073 f1e5aff4 2022-07-12 op echo "fold $old_commit1" > $testroot/histedit-script
2074 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2075 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2077 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2078 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2080 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2081 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2082 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2086 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2087 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2089 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2090 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2092 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2095 598eac43 2022-07-22 stsp test_histedit_resets_committer() {
2096 598eac43 2022-07-22 stsp local testroot=`test_init histedit_resets_committer`
2097 598eac43 2022-07-22 stsp local orig_commit=`git_show_head $testroot/repo`
2098 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
2100 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2102 598eac43 2022-07-22 stsp echo "modified alpha" > $testroot/wt/alpha
2104 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2105 598eac43 2022-07-22 stsp alpha > /dev/null)
2107 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2108 598eac43 2022-07-22 stsp echo "got commit failed unexpectedly" >&2
2109 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2113 598eac43 2022-07-22 stsp local top_commit=`git_show_head $testroot/repo`
2114 598eac43 2022-07-22 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2116 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2118 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2119 598eac43 2022-07-22 stsp echo "got update failed unexpectedly" >&2
2120 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2124 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2125 598eac43 2022-07-22 stsp got histedit -F "$testroot/histedit-script" > /dev/null)
2127 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2128 598eac43 2022-07-22 stsp echo "got histedit failed unexpectedly" >&2
2129 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2132 598eac43 2022-07-22 stsp local edited_commit=`git_show_head $testroot/repo`
2134 598eac43 2022-07-22 stsp # Original commit only had one author
2135 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $top_commit | \
2136 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2137 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2138 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2140 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2141 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2142 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2146 598eac43 2022-07-22 stsp # Edited commit should have new committer name added
2147 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $edited_commit | \
2148 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2149 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2150 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
2152 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2154 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2155 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2157 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2160 b2b3fce1 2022-10-29 op test_histedit_umask() {
2161 b2b3fce1 2022-10-29 op local testroot=`test_init histedit_umask`
2162 b2b3fce1 2022-10-29 op local orig_commit=`git_show_head "$testroot/repo"`
2164 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2166 b2b3fce1 2022-10-29 op echo "modified alpha" > $testroot/wt/alpha
2167 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2168 b2b3fce1 2022-10-29 op local commit1=`git_show_head "$testroot/repo"`
2170 b2b3fce1 2022-10-29 op echo "modified again" > $testroot/wt/alpha
2171 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2172 b2b3fce1 2022-10-29 op local commit2=`git_show_head "$testroot/repo"`
2174 b2b3fce1 2022-10-29 op echo "modified again!" > $testroot/wt/alpha
2175 b2b3fce1 2022-10-29 op echo "modify beta too!" > $testroot/wt/beta
2176 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2177 b2b3fce1 2022-10-29 op local commit3=`git_show_head "$testroot/repo"`
2179 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2181 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2182 b2b3fce1 2022-10-29 op echo "update to $orig_commit failed!" >&2
2183 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2187 b2b3fce1 2022-10-29 op echo fold $commit1 >$testroot/histedit-script
2188 b2b3fce1 2022-10-29 op echo fold $commit2 >>$testroot/histedit-script
2189 b2b3fce1 2022-10-29 op echo pick $commit3 >>$testroot/histedit-script
2190 b2b3fce1 2022-10-29 op echo mesg folding changes >>$testroot/histedit-script
2192 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
2193 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && \
2194 b2b3fce1 2022-10-29 op got histedit -F "$testroot/histedit-script") >/dev/null
2197 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2198 b2b3fce1 2022-10-29 op echo "histedit operation failed" >&2
2199 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
2203 b2b3fce1 2022-10-29 op for f in alpha beta; do
2204 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2205 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
2206 b2b3fce1 2022-10-29 op echo "$f is not 0600 after histedi" >&2
2207 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
2208 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2213 b2b3fce1 2022-10-29 op test_done "$testroot" 0
2216 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2217 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
2218 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
2219 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
2220 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
2221 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
2222 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
2223 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
2224 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
2225 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
2226 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
2227 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
2228 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
2229 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
2230 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
2231 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
2232 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
2233 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg
2234 b93c7142 2021-10-01 stsp run_test test_histedit_edit_only
2235 09209b8a 2021-10-08 stsp run_test test_histedit_prepend_line
2236 f1e5aff4 2022-07-12 op run_test test_histedit_mesg_invalid
2237 598eac43 2022-07-22 stsp run_test test_histedit_resets_committer
2238 b2b3fce1 2022-10-29 op run_test test_histedit_umask