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`
24 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
25 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
26 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
27 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
28 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
29 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
31 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
32 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
33 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
35 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
36 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
38 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
40 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
41 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
45 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
46 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
48 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
49 0ebf8283 2019-07-24 stsp > $testroot/stdout)
51 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
52 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
54 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
55 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
56 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
57 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
59 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
60 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
61 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
62 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
63 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
66 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
67 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
69 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
71 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
74 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
75 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
79 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
80 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
81 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
83 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
84 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
85 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
89 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
90 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
91 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
95 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
96 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
97 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
99 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
100 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
101 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
105 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
107 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
108 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
110 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
111 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
112 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
116 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
117 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
118 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
119 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
120 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
123 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
128 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
129 86ac67ee 2019-07-25 stsp > $testroot/diff
130 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
131 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
133 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
134 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
135 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
139 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
141 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
142 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
144 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
145 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
147 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
150 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
151 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
153 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
155 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
156 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
157 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
158 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
159 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
160 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
162 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
163 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
164 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
166 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
167 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
169 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
171 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
172 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
176 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
177 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
179 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
180 0ebf8283 2019-07-24 stsp > $testroot/stdout)
182 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
183 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
185 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
186 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
187 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
188 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
190 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
191 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
192 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
193 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
194 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
195 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
196 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
197 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
198 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
199 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
200 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
202 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
205 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
210 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
211 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
212 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
214 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
215 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
216 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
220 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
221 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
222 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
226 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
227 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
228 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
230 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
231 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
236 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
238 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
239 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
241 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
242 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
243 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
247 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
248 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
249 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
250 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
251 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
253 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
254 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
259 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
260 86ac67ee 2019-07-25 stsp > $testroot/diff
261 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
262 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
264 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
265 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
267 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
270 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
271 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
272 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
274 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
275 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
276 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
277 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
278 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
279 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
281 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
282 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
283 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
285 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
286 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
288 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
290 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
295 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
296 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
298 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
299 0ebf8283 2019-07-24 stsp > $testroot/stdout)
301 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
303 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
304 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
305 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
307 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
308 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
309 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
310 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
311 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
312 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
313 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
314 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
316 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
318 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
319 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
320 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
324 0ebf8283 2019-07-24 stsp for f in alpha beta; do
325 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
326 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
327 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
329 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
330 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
331 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
336 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
337 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
338 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
342 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
344 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
345 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
347 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
348 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
349 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
353 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
354 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
355 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
356 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
358 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
359 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
360 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
364 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
365 86ac67ee 2019-07-25 stsp > $testroot/diff
366 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
367 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
368 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
370 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
371 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
373 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
376 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
377 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
379 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
381 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
382 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
383 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
384 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
385 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
386 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
388 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
389 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
390 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
392 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
393 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
394 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
396 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
398 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
399 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
403 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
404 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
405 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
406 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
408 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
409 0ebf8283 2019-07-24 stsp > $testroot/stdout)
411 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
412 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
414 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
415 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
416 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
417 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
418 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
420 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
421 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
422 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
423 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
424 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
425 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
426 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
427 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
428 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
429 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
430 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
431 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
432 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
433 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
435 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
437 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
438 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
443 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
444 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
445 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
447 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
448 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
449 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
453 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
454 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
455 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
459 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
460 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
461 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
463 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
464 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
465 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
469 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
471 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
472 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
474 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
475 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
476 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
480 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
481 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
482 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
483 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
485 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
486 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
488 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
491 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
492 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
494 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
496 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
497 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
498 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
499 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
500 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
501 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
503 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
504 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
505 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
507 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
509 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
510 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
514 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
515 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
516 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
518 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
519 0ebf8283 2019-07-24 stsp > $testroot/stdout)
521 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
522 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
524 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
525 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
526 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
527 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
528 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
529 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
531 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
532 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
533 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
537 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
539 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
540 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
541 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
542 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
544 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
545 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
546 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
549 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
550 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
551 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
552 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
553 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
555 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
556 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
557 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
561 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
562 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
564 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
565 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
567 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
568 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
570 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
571 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
572 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
573 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
574 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
575 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
576 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
577 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
579 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
581 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
582 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
583 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
587 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
588 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
589 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
591 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
592 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
593 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
597 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
598 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
599 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
603 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
604 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
605 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
607 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
608 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
609 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
613 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
615 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
616 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
619 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
624 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
625 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
626 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
627 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
628 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
630 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
631 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
633 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
636 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
637 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
639 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
641 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
642 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
643 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
644 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
645 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
646 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
648 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
649 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
650 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
652 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
654 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
655 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
659 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
660 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
661 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
663 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
664 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
667 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
668 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
669 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
673 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
674 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
676 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
678 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
679 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
681 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
684 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
685 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
687 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
689 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
690 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
691 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
692 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
693 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
694 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
696 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
697 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
698 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
700 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
702 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
703 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
707 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
708 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
710 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
711 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
714 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
715 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
716 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
720 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
721 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
723 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
725 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
726 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
728 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
731 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
732 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
734 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
736 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
737 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
738 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
739 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
740 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
741 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
743 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
744 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
745 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
747 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
749 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
750 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
754 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
755 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
756 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
758 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
759 0ebf8283 2019-07-24 stsp > $testroot/stdout)
761 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
762 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
764 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
765 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
766 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
767 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
768 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
769 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
771 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
772 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
773 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
777 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
779 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
781 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
782 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
784 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
785 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
786 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
787 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
788 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
789 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
790 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
792 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
794 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
795 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
796 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
800 0ebf8283 2019-07-24 stsp for f in alpha beta; do
801 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
802 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
803 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
805 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
806 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
807 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
812 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
813 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
814 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
816 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
817 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
818 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
822 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
824 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
825 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
827 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
828 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
829 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
833 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
834 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
835 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
836 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
837 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
839 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
840 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
842 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
845 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
846 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
847 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
849 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
850 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
851 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
853 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
854 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
856 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
857 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
861 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
863 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
864 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
867 0160a755 2019-07-25 stsp if [ "$ret" == "0" ]; then
868 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
869 0160a755 2019-07-25 stsp test_done "$testroot" "1"
873 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
874 0160a755 2019-07-25 stsp > $testroot/stderr.expected
875 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
876 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
878 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
880 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
881 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
882 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
886 0160a755 2019-07-25 stsp rm -rf $testroot/wt
887 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
888 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
890 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
891 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
894 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
895 0160a755 2019-07-25 stsp > $testroot/stdout)
897 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
898 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
900 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
901 0160a755 2019-07-25 stsp > $testroot/stdout.expected
902 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
903 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
905 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
907 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
908 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
909 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
913 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
914 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
915 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
917 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
918 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
919 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
924 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
926 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
927 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
929 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
930 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
931 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
935 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
936 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
937 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
939 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
940 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
942 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
945 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
946 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
947 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
949 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
950 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
951 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
953 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
954 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
956 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
957 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
959 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
960 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
964 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
965 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
967 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
968 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
971 b2c50a0a 2019-07-25 stsp if [ "$ret" == "0" ]; then
972 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
973 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
977 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
978 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
979 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
980 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
982 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
984 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
985 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
986 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
990 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
991 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
992 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
994 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
995 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
998 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
999 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1001 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1003 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1004 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1005 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1006 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1008 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
1009 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1010 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1014 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1015 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1016 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1018 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1019 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1020 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1024 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1026 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1027 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1030 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1031 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1035 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1037 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1038 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1040 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1041 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1042 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1043 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1044 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1046 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1048 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1049 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1050 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1054 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1055 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1056 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1057 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1059 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1060 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1061 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1065 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1066 b2c50a0a 2019-07-25 stsp > $testroot/diff
1067 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1068 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1070 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1071 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1073 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1076 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1077 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1078 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1080 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1082 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1083 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1084 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1088 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1090 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1091 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1093 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1094 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1095 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1098 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1100 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1102 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1103 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1104 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1108 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1110 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1111 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1112 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1116 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1117 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1118 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1120 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1121 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1122 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1123 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1124 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1126 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1127 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1129 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1132 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1133 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1135 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1137 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1138 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1139 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1140 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1141 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1142 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1144 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1145 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1146 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1148 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1150 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1151 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1155 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1156 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1157 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1158 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1160 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1161 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1164 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1165 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1166 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1170 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1172 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1173 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1174 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1176 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1177 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1178 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1179 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1180 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1181 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1182 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1183 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1184 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1185 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1186 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1187 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1189 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1191 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1192 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1194 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1197 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1198 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1200 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1202 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1203 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1204 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1205 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1206 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1207 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1208 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1210 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1211 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1212 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1213 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1215 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1217 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1218 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1222 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1223 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1224 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1226 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1227 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1229 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1230 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1231 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1232 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1236 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1237 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1238 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1239 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1240 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1242 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1244 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1245 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1246 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1250 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1252 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1253 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1254 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1258 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1260 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1261 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1262 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1266 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1268 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1269 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1270 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1274 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1275 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1277 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1278 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1279 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1280 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1283 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1284 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1286 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1287 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1288 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1289 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1290 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1291 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1292 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1294 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1296 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1297 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1299 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1303 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1304 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1306 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1308 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1309 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1310 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1311 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1312 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1313 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1315 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1316 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1317 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1319 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1321 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1322 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1326 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1327 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1328 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1329 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1331 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1332 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1334 5b87815e 2020-03-05 stsp if [ "$ret" == "0" ]; then
1335 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1336 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1337 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1341 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1342 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1343 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1345 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1347 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1348 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1350 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1354 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1355 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1356 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1357 ecfff807 2020-09-23 stsp local testroot=`test_init histedit_fold`
1359 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1361 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1362 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1363 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1364 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1366 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1367 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1368 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1370 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1371 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1372 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1374 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1376 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1377 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1381 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1382 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1383 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1384 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1386 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1387 ecfff807 2020-09-23 stsp > $testroot/stdout)
1389 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1391 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1392 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1393 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1394 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1396 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1397 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1398 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1399 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1400 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1401 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1402 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1403 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1404 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1405 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1406 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1408 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1410 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1411 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1412 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1416 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1417 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1418 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1422 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1424 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1425 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1427 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1428 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1429 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1433 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1434 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1435 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1437 29c68398 2020-09-24 stsp if [ "$ret" != "0" ]; then
1438 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1443 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1444 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1445 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1447 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1448 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1450 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1453 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1454 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1456 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1458 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1459 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1460 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1461 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1462 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1463 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1465 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1466 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1467 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1469 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1470 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1471 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1473 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1475 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1476 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1480 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1482 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1484 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1486 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1487 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1489 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1491 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1492 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1493 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1494 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1495 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1497 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1498 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1499 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1500 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1501 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1502 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1503 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1504 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1505 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1506 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1507 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1508 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1509 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1510 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1511 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1513 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1515 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1516 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1517 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1521 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1522 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1523 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1525 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1526 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1527 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1531 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1532 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1533 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1537 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1538 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1539 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1541 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1542 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1543 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1547 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1549 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1550 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1552 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1553 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1554 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1558 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1559 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1560 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1561 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1563 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1564 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1566 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1569 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1570 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1572 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1574 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1575 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1576 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1577 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1578 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1579 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1581 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1582 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1583 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1585 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1586 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1587 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1589 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1591 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1592 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1596 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1598 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1600 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1602 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1603 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1605 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1607 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1608 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1609 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1610 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1611 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1612 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1614 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1615 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1616 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1617 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1618 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1619 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1620 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1621 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1622 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1623 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1624 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1625 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1626 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1627 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1628 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1629 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1631 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1633 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1634 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1635 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1639 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1640 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1641 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1643 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1644 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1645 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1649 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1650 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1651 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1655 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1656 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1657 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1659 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1660 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1661 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1665 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1667 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1668 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1670 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1671 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1672 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1676 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1677 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1678 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1679 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1681 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1682 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1684 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1687 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1688 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1689 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1690 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1691 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1692 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1693 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1694 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1695 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1696 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1697 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
1698 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
1699 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
1700 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
1701 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
1702 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
1703 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
1704 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg