Blame


1 0ebf8283 2019-07-24 stsp #!/bin/sh
2 0ebf8283 2019-07-24 stsp #
3 0ebf8283 2019-07-24 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 0ebf8283 2019-07-24 stsp #
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.
8 0ebf8283 2019-07-24 stsp #
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.
16 0ebf8283 2019-07-24 stsp
17 0ebf8283 2019-07-24 stsp . ./common.sh
18 0ebf8283 2019-07-24 stsp
19 f6cae3ed 2020-09-13 naddy test_histedit_no_op() {
20 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_no_op`
21 0ebf8283 2019-07-24 stsp
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`
24 0ebf8283 2019-07-24 stsp
25 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
26 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
27 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
28 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
29 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
30 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
31 ad324bf5 2021-09-21 stsp local old_author_time1=`git_show_author_time $testroot/repo`
32 0ebf8283 2019-07-24 stsp
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`
37 0ebf8283 2019-07-24 stsp
38 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
39 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
40 86ac67ee 2019-07-25 stsp
41 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
42 49c543a6 2022-03-31 naddy ret=$?
43 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
44 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
45 0ebf8283 2019-07-24 stsp return 1
46 0ebf8283 2019-07-24 stsp fi
47 0ebf8283 2019-07-24 stsp
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
50 0ebf8283 2019-07-24 stsp
51 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
52 0ebf8283 2019-07-24 stsp > $testroot/stdout)
53 0ebf8283 2019-07-24 stsp
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`
57 0ebf8283 2019-07-24 stsp
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`
62 0ebf8283 2019-07-24 stsp
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
74 0ebf8283 2019-07-24 stsp
75 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 49c543a6 2022-03-31 naddy ret=$?
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"
80 0ebf8283 2019-07-24 stsp return 1
81 0ebf8283 2019-07-24 stsp fi
82 0ebf8283 2019-07-24 stsp
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
86 49c543a6 2022-03-31 naddy ret=$?
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"
90 0ebf8283 2019-07-24 stsp return 1
91 0ebf8283 2019-07-24 stsp fi
92 0ebf8283 2019-07-24 stsp
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"
96 0ebf8283 2019-07-24 stsp return 1
97 0ebf8283 2019-07-24 stsp fi
98 0ebf8283 2019-07-24 stsp
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
102 49c543a6 2022-03-31 naddy ret=$?
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"
106 0ebf8283 2019-07-24 stsp return 1
107 0ebf8283 2019-07-24 stsp fi
108 0ebf8283 2019-07-24 stsp
109 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
110 0ebf8283 2019-07-24 stsp
111 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
112 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
113 49c543a6 2022-03-31 naddy ret=$?
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"
117 0ebf8283 2019-07-24 stsp return 1
118 0ebf8283 2019-07-24 stsp fi
119 0ebf8283 2019-07-24 stsp
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
125 49c543a6 2022-03-31 naddy ret=$?
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"
129 86ac67ee 2019-07-25 stsp return 1
130 0ebf8283 2019-07-24 stsp fi
131 86ac67ee 2019-07-25 stsp
132 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
133 86ac67ee 2019-07-25 stsp > $testroot/diff
134 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
135 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
136 885e96df 2023-03-06 naddy w
137 885e96df 2023-03-06 naddy EOF
138 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
139 49c543a6 2022-03-31 naddy ret=$?
140 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
141 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
142 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
143 a615e0e7 2020-12-16 stsp return 1
144 86ac67ee 2019-07-25 stsp fi
145 a615e0e7 2020-12-16 stsp
146 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
147 a615e0e7 2020-12-16 stsp
148 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
149 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
150 49c543a6 2022-03-31 naddy ret=$?
151 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
152 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 a9662115 2021-08-29 naddy return 1
155 e600f124 2021-03-21 stsp fi
156 e600f124 2021-03-21 stsp
157 e600f124 2021-03-21 stsp # We should have a backup of old commits
158 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
159 283939fb 2024-04-23 op d_orig1=`date -u -r $old_author_time1 +"%F"`
160 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 283939fb 2024-04-23 op d_new2=`date -u -r $new_author_time2 +"%F"`
162 283939fb 2024-04-23 op d_orig=`date -u -r $orig_author_time +"%F"`
163 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
164 e600f124 2021-03-21 stsp -----------------------------------------------
165 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
166 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
167 e600f124 2021-03-21 stsp date: $d_orig2
168 e600f124 2021-03-21 stsp
169 e600f124 2021-03-21 stsp committing to zeta on master
170 e600f124 2021-03-21 stsp
171 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
172 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
173 ad324bf5 2021-09-21 stsp EOF
174 ad324bf5 2021-09-21 stsp
175 ad324bf5 2021-09-21 stsp local is_forked=true d_fork fork_commit fork_commit_msg
176 ad324bf5 2021-09-21 stsp
177 ad324bf5 2021-09-21 stsp if [ "$old_commit1" = "$new_commit1" ]; then
178 ad324bf5 2021-09-21 stsp if [ "$old_commit2" = "$new_commit2" ]; then
179 ad324bf5 2021-09-21 stsp is_forked=false
180 ad324bf5 2021-09-21 stsp else
181 ad324bf5 2021-09-21 stsp d_fork=$d_orig1
182 ad324bf5 2021-09-21 stsp fork_commit=$new_commit1
183 ad324bf5 2021-09-21 stsp fork_commit_msg="committing changes"
184 ad324bf5 2021-09-21 stsp fi
185 ad324bf5 2021-09-21 stsp else
186 ad324bf5 2021-09-21 stsp d_fork=$d_orig
187 ad324bf5 2021-09-21 stsp fork_commit=$orig_commit
188 ad324bf5 2021-09-21 stsp fork_commit_msg="adding the test tree"
189 ad324bf5 2021-09-21 stsp fi
190 ad324bf5 2021-09-21 stsp
191 ad324bf5 2021-09-21 stsp $is_forked && cat >> $testroot/stdout.expected <<EOF
192 ad324bf5 2021-09-21 stsp history forked at $fork_commit
193 ad324bf5 2021-09-21 stsp $d_fork $GOT_AUTHOR_11 $fork_commit_msg
194 e600f124 2021-03-21 stsp EOF
195 ad324bf5 2021-09-21 stsp
196 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
197 49c543a6 2022-03-31 naddy ret=$?
198 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
199 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
200 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
201 643b85bc 2021-07-16 stsp return 1
202 a615e0e7 2020-12-16 stsp fi
203 643b85bc 2021-07-16 stsp
204 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
205 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
206 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
207 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
208 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
209 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
210 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
211 49c543a6 2022-03-31 naddy ret=$?
212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
213 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
215 643b85bc 2021-07-16 stsp return 1
216 643b85bc 2021-07-16 stsp fi
217 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
218 49c543a6 2022-03-31 naddy ret=$?
219 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
220 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
222 643b85bc 2021-07-16 stsp return 1
223 643b85bc 2021-07-16 stsp fi
224 643b85bc 2021-07-16 stsp
225 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
226 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
227 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
228 49c543a6 2022-03-31 naddy ret=$?
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
231 643b85bc 2021-07-16 stsp fi
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
233 0ebf8283 2019-07-24 stsp }
234 0ebf8283 2019-07-24 stsp
235 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
236 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
237 0ebf8283 2019-07-24 stsp
238 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
239 0ebf8283 2019-07-24 stsp
240 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
241 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
242 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
243 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
244 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
245 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
246 0ebf8283 2019-07-24 stsp
247 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
248 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
249 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
250 0ebf8283 2019-07-24 stsp
251 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
252 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
253 86ac67ee 2019-07-25 stsp
254 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
255 49c543a6 2022-03-31 naddy ret=$?
256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
257 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
258 0ebf8283 2019-07-24 stsp return 1
259 0ebf8283 2019-07-24 stsp fi
260 0ebf8283 2019-07-24 stsp
261 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
262 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
263 0ebf8283 2019-07-24 stsp
264 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
265 0ebf8283 2019-07-24 stsp > $testroot/stdout)
266 0ebf8283 2019-07-24 stsp
267 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
268 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
269 0ebf8283 2019-07-24 stsp
270 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
271 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
272 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
273 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
274 0ebf8283 2019-07-24 stsp
275 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
276 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
277 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
278 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
279 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
280 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
281 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
282 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
283 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
284 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
285 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
286 0ebf8283 2019-07-24 stsp
287 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
288 49c543a6 2022-03-31 naddy ret=$?
289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
290 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
292 0ebf8283 2019-07-24 stsp return 1
293 0ebf8283 2019-07-24 stsp fi
294 0ebf8283 2019-07-24 stsp
295 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
296 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
297 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
298 49c543a6 2022-03-31 naddy ret=$?
299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
300 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
301 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
302 0ebf8283 2019-07-24 stsp return 1
303 0ebf8283 2019-07-24 stsp fi
304 0ebf8283 2019-07-24 stsp
305 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
306 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
307 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
308 0ebf8283 2019-07-24 stsp return 1
309 0ebf8283 2019-07-24 stsp fi
310 0ebf8283 2019-07-24 stsp
311 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
312 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
313 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
314 49c543a6 2022-03-31 naddy ret=$?
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
317 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
318 0ebf8283 2019-07-24 stsp return 1
319 0ebf8283 2019-07-24 stsp fi
320 0ebf8283 2019-07-24 stsp
321 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
322 0ebf8283 2019-07-24 stsp
323 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
324 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 49c543a6 2022-03-31 naddy ret=$?
326 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
327 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
329 0ebf8283 2019-07-24 stsp return 1
330 0ebf8283 2019-07-24 stsp fi
331 0ebf8283 2019-07-24 stsp
332 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
333 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
334 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
335 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
336 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
337 49c543a6 2022-03-31 naddy ret=$?
338 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
339 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
341 86ac67ee 2019-07-25 stsp return 1
342 86ac67ee 2019-07-25 stsp fi
343 86ac67ee 2019-07-25 stsp
344 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
345 86ac67ee 2019-07-25 stsp > $testroot/diff
346 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
347 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit1/
348 885e96df 2023-03-06 naddy w
349 885e96df 2023-03-06 naddy EOF
350 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
351 49c543a6 2022-03-31 naddy ret=$?
352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
353 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
354 0ebf8283 2019-07-24 stsp fi
355 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
356 0ebf8283 2019-07-24 stsp }
357 0ebf8283 2019-07-24 stsp
358 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
359 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
360 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
361 0ebf8283 2019-07-24 stsp
362 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
363 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
364 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
365 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
366 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
367 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
368 0ebf8283 2019-07-24 stsp
369 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
370 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
371 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
372 0ebf8283 2019-07-24 stsp
373 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
374 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
375 86ac67ee 2019-07-25 stsp
376 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
377 49c543a6 2022-03-31 naddy ret=$?
378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
379 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
380 0ebf8283 2019-07-24 stsp return 1
381 0ebf8283 2019-07-24 stsp fi
382 0ebf8283 2019-07-24 stsp
383 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
384 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
385 0ebf8283 2019-07-24 stsp
386 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
387 0ebf8283 2019-07-24 stsp > $testroot/stdout)
388 0ebf8283 2019-07-24 stsp
389 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
390 0ebf8283 2019-07-24 stsp
391 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
392 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
393 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
394 0ebf8283 2019-07-24 stsp
395 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
396 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
397 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
398 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
399 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
400 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
401 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
402 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
403 0ebf8283 2019-07-24 stsp
404 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
405 49c543a6 2022-03-31 naddy ret=$?
406 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
407 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
409 0ebf8283 2019-07-24 stsp return 1
410 0ebf8283 2019-07-24 stsp fi
411 0ebf8283 2019-07-24 stsp
412 0ebf8283 2019-07-24 stsp for f in alpha beta; do
413 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
414 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
415 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
416 49c543a6 2022-03-31 naddy ret=$?
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
419 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
420 0ebf8283 2019-07-24 stsp return 1
421 0ebf8283 2019-07-24 stsp fi
422 0ebf8283 2019-07-24 stsp done
423 0ebf8283 2019-07-24 stsp
424 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
425 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
426 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
427 0ebf8283 2019-07-24 stsp return 1
428 0ebf8283 2019-07-24 stsp fi
429 0ebf8283 2019-07-24 stsp
430 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
431 0ebf8283 2019-07-24 stsp
432 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
433 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
434 49c543a6 2022-03-31 naddy ret=$?
435 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
436 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
438 0ebf8283 2019-07-24 stsp return 1
439 0ebf8283 2019-07-24 stsp fi
440 0ebf8283 2019-07-24 stsp
441 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
442 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
443 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
444 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 49c543a6 2022-03-31 naddy ret=$?
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
449 86ac67ee 2019-07-25 stsp return 1
450 86ac67ee 2019-07-25 stsp fi
451 86ac67ee 2019-07-25 stsp
452 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
453 86ac67ee 2019-07-25 stsp > $testroot/diff
454 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
455 885e96df 2023-03-06 naddy ,s/$old_commit1/$orig_commit/
456 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
457 885e96df 2023-03-06 naddy w
458 885e96df 2023-03-06 naddy EOF
459 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
460 49c543a6 2022-03-31 naddy ret=$?
461 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
462 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
463 0ebf8283 2019-07-24 stsp fi
464 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
465 0ebf8283 2019-07-24 stsp }
466 0ebf8283 2019-07-24 stsp
467 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
468 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
469 0ebf8283 2019-07-24 stsp
470 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
471 0ebf8283 2019-07-24 stsp
472 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
473 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
474 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
475 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
476 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
477 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
478 0ebf8283 2019-07-24 stsp
479 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
480 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
481 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
482 3f9de99f 2019-07-24 stsp
483 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
484 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
485 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
486 0ebf8283 2019-07-24 stsp
487 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
488 49c543a6 2022-03-31 naddy ret=$?
489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
490 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
491 0ebf8283 2019-07-24 stsp return 1
492 0ebf8283 2019-07-24 stsp fi
493 14eb0fef 2023-10-26 stsp
494 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
495 14eb0fef 2023-10-26 stsp #!/bin/sh
496 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
497 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
498 14eb0fef 2023-10-26 stsp w
499 14eb0fef 2023-10-26 stsp EOF
500 14eb0fef 2023-10-26 stsp EOF
501 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
502 0ebf8283 2019-07-24 stsp
503 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
504 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
505 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
506 0ebf8283 2019-07-24 stsp
507 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
508 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
509 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
510 0ebf8283 2019-07-24 stsp
511 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
512 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
513 0ebf8283 2019-07-24 stsp
514 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
515 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
516 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
517 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
518 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
519 0ebf8283 2019-07-24 stsp
520 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
521 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
522 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
523 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
524 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
525 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
526 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
527 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
528 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
529 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
530 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
531 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
532 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
533 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
534 0ebf8283 2019-07-24 stsp
535 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
536 49c543a6 2022-03-31 naddy ret=$?
537 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
538 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
540 0ebf8283 2019-07-24 stsp return 1
541 0ebf8283 2019-07-24 stsp fi
542 0ebf8283 2019-07-24 stsp
543 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
544 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
545 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
546 49c543a6 2022-03-31 naddy ret=$?
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
549 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
550 0ebf8283 2019-07-24 stsp return 1
551 0ebf8283 2019-07-24 stsp fi
552 0ebf8283 2019-07-24 stsp
553 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
554 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
555 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
556 0ebf8283 2019-07-24 stsp return 1
557 0ebf8283 2019-07-24 stsp fi
558 0ebf8283 2019-07-24 stsp
559 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
560 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
561 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
562 49c543a6 2022-03-31 naddy ret=$?
563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
564 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
565 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
566 0ebf8283 2019-07-24 stsp return 1
567 0ebf8283 2019-07-24 stsp fi
568 0ebf8283 2019-07-24 stsp
569 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
570 0ebf8283 2019-07-24 stsp
571 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
572 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
573 49c543a6 2022-03-31 naddy ret=$?
574 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
575 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
577 0ebf8283 2019-07-24 stsp return 1
578 0ebf8283 2019-07-24 stsp fi
579 0ebf8283 2019-07-24 stsp
580 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
581 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
582 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
583 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
584 49c543a6 2022-03-31 naddy ret=$?
585 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
586 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
587 0ebf8283 2019-07-24 stsp fi
588 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
589 0ebf8283 2019-07-24 stsp }
590 0ebf8283 2019-07-24 stsp
591 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
592 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
593 0ebf8283 2019-07-24 stsp
594 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
595 0ebf8283 2019-07-24 stsp
596 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
597 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
598 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
599 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
600 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
601 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
602 0ebf8283 2019-07-24 stsp
603 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
604 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
605 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
606 0ebf8283 2019-07-24 stsp
607 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
608 49c543a6 2022-03-31 naddy ret=$?
609 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
610 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
611 0ebf8283 2019-07-24 stsp return 1
612 0ebf8283 2019-07-24 stsp fi
613 0ebf8283 2019-07-24 stsp
614 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
615 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
616 0ebf8283 2019-07-24 stsp
617 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
618 0ebf8283 2019-07-24 stsp > $testroot/stdout)
619 0ebf8283 2019-07-24 stsp
620 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
621 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
622 0ebf8283 2019-07-24 stsp
623 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
624 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
625 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
626 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
627 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
628 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
629 49c543a6 2022-03-31 naddy ret=$?
630 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
631 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
632 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
633 0ebf8283 2019-07-24 stsp return 1
634 0ebf8283 2019-07-24 stsp fi
635 0ebf8283 2019-07-24 stsp
636 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
637 0ebf8283 2019-07-24 stsp
638 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
639 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
640 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
641 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
642 49c543a6 2022-03-31 naddy ret=$?
643 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
644 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
645 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
646 f032f1f7 2019-08-04 stsp return 1
647 f032f1f7 2019-08-04 stsp fi
648 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
649 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
650 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
651 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
652 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
653 49c543a6 2022-03-31 naddy ret=$?
654 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
655 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
656 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
657 f032f1f7 2019-08-04 stsp return 1
658 f032f1f7 2019-08-04 stsp fi
659 f032f1f7 2019-08-04 stsp
660 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
661 0ebf8283 2019-07-24 stsp
662 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
663 14eb0fef 2023-10-26 stsp #!/bin/sh
664 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
665 14eb0fef 2023-10-26 stsp ,s/.*/committing changes/
666 14eb0fef 2023-10-26 stsp w
667 14eb0fef 2023-10-26 stsp EOF
668 14eb0fef 2023-10-26 stsp EOF
669 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
670 14eb0fef 2023-10-26 stsp
671 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
672 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
673 14eb0fef 2023-10-26 stsp got histedit -c > $testroot/stdout)
674 14eb0fef 2023-10-26 stsp
675 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
676 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
677 0ebf8283 2019-07-24 stsp
678 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
679 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
680 0ebf8283 2019-07-24 stsp
681 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
682 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
683 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
684 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
685 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
686 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
687 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
688 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
689 0ebf8283 2019-07-24 stsp
690 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
691 49c543a6 2022-03-31 naddy ret=$?
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
695 0ebf8283 2019-07-24 stsp return 1
696 0ebf8283 2019-07-24 stsp fi
697 0ebf8283 2019-07-24 stsp
698 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
699 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
700 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
701 49c543a6 2022-03-31 naddy ret=$?
702 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
703 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
704 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
705 0ebf8283 2019-07-24 stsp return 1
706 0ebf8283 2019-07-24 stsp fi
707 0ebf8283 2019-07-24 stsp
708 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
709 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
710 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
711 0ebf8283 2019-07-24 stsp return 1
712 0ebf8283 2019-07-24 stsp fi
713 0ebf8283 2019-07-24 stsp
714 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
715 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
716 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
717 49c543a6 2022-03-31 naddy ret=$?
718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
719 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
720 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
721 0ebf8283 2019-07-24 stsp return 1
722 0ebf8283 2019-07-24 stsp fi
723 0ebf8283 2019-07-24 stsp
724 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
725 0ebf8283 2019-07-24 stsp
726 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
727 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
728 49c543a6 2022-03-31 naddy ret=$?
729 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
730 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
731 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
732 0ebf8283 2019-07-24 stsp return 1
733 0ebf8283 2019-07-24 stsp fi
734 0ebf8283 2019-07-24 stsp
735 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
736 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
737 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
738 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
739 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
740 49c543a6 2022-03-31 naddy ret=$?
741 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
742 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
743 0ebf8283 2019-07-24 stsp fi
744 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
745 0ebf8283 2019-07-24 stsp }
746 0ebf8283 2019-07-24 stsp
747 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
748 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
749 0ebf8283 2019-07-24 stsp
750 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
751 0ebf8283 2019-07-24 stsp
752 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
753 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
754 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
755 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
756 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
757 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
758 0ebf8283 2019-07-24 stsp
759 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
760 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
761 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
762 0ebf8283 2019-07-24 stsp
763 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
764 49c543a6 2022-03-31 naddy ret=$?
765 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
766 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
767 0ebf8283 2019-07-24 stsp return 1
768 0ebf8283 2019-07-24 stsp fi
769 0ebf8283 2019-07-24 stsp
770 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
771 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
772 0ebf8283 2019-07-24 stsp
773 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
774 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
775 0ebf8283 2019-07-24 stsp
776 49c543a6 2022-03-31 naddy ret=$?
777 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
778 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
779 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
780 0ebf8283 2019-07-24 stsp return 1
781 0ebf8283 2019-07-24 stsp fi
782 0ebf8283 2019-07-24 stsp
783 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
784 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
785 0ebf8283 2019-07-24 stsp
786 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
787 49c543a6 2022-03-31 naddy ret=$?
788 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
789 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
790 0ebf8283 2019-07-24 stsp fi
791 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
792 0ebf8283 2019-07-24 stsp }
793 0ebf8283 2019-07-24 stsp
794 14eb0fef 2023-10-26 stsp test_histedit_missing_commit_pick() {
795 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
796 0ebf8283 2019-07-24 stsp
797 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
798 0ebf8283 2019-07-24 stsp
799 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
800 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
801 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
802 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
803 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
804 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
805 0ebf8283 2019-07-24 stsp
806 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
807 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
808 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
809 0ebf8283 2019-07-24 stsp
810 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
811 49c543a6 2022-03-31 naddy ret=$?
812 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
813 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
814 0ebf8283 2019-07-24 stsp return 1
815 0ebf8283 2019-07-24 stsp fi
816 0ebf8283 2019-07-24 stsp
817 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
818 0ebf8283 2019-07-24 stsp
819 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
820 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
821 0ebf8283 2019-07-24 stsp
822 49c543a6 2022-03-31 naddy ret=$?
823 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
824 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
825 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
826 0ebf8283 2019-07-24 stsp return 1
827 0ebf8283 2019-07-24 stsp fi
828 0ebf8283 2019-07-24 stsp
829 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
830 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
831 0ebf8283 2019-07-24 stsp
832 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
833 49c543a6 2022-03-31 naddy ret=$?
834 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
835 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
836 0ebf8283 2019-07-24 stsp fi
837 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
838 0ebf8283 2019-07-24 stsp }
839 0ebf8283 2019-07-24 stsp
840 14eb0fef 2023-10-26 stsp test_histedit_missing_commit_mesg() {
841 14eb0fef 2023-10-26 stsp local testroot=`test_init histedit_missing_commit`
842 14eb0fef 2023-10-26 stsp
843 14eb0fef 2023-10-26 stsp local orig_commit=`git_show_head $testroot/repo`
844 14eb0fef 2023-10-26 stsp
845 14eb0fef 2023-10-26 stsp echo "modified alpha on master" > $testroot/repo/alpha
846 14eb0fef 2023-10-26 stsp git -C $testroot/repo rm -q beta
847 14eb0fef 2023-10-26 stsp echo "new file on master" > $testroot/repo/epsilon/new
848 14eb0fef 2023-10-26 stsp git -C $testroot/repo add epsilon/new
849 14eb0fef 2023-10-26 stsp git_commit $testroot/repo -m "committing changes"
850 14eb0fef 2023-10-26 stsp local old_commit1=`git_show_head $testroot/repo`
851 14eb0fef 2023-10-26 stsp
852 14eb0fef 2023-10-26 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
853 14eb0fef 2023-10-26 stsp git_commit $testroot/repo -m "committing to zeta on master"
854 14eb0fef 2023-10-26 stsp local old_commit2=`git_show_head $testroot/repo`
855 14eb0fef 2023-10-26 stsp
856 14eb0fef 2023-10-26 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
857 14eb0fef 2023-10-26 stsp ret=$?
858 14eb0fef 2023-10-26 stsp if [ $ret -ne 0 ]; then
859 14eb0fef 2023-10-26 stsp test_done "$testroot" "$ret"
860 14eb0fef 2023-10-26 stsp return 1
861 14eb0fef 2023-10-26 stsp fi
862 14eb0fef 2023-10-26 stsp
863 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
864 14eb0fef 2023-10-26 stsp #!/bin/sh
865 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
866 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
867 14eb0fef 2023-10-26 stsp w
868 14eb0fef 2023-10-26 stsp EOF
869 14eb0fef 2023-10-26 stsp EOF
870 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
871 14eb0fef 2023-10-26 stsp
872 14eb0fef 2023-10-26 stsp echo "mesg $old_commit1" > $testroot/histedit-script
873 14eb0fef 2023-10-26 stsp
874 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
875 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
876 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout \
877 14eb0fef 2023-10-26 stsp 2>$testroot/stderr)
878 14eb0fef 2023-10-26 stsp
879 14eb0fef 2023-10-26 stsp ret=$?
880 14eb0fef 2023-10-26 stsp if [ $ret -eq 0 ]; then
881 14eb0fef 2023-10-26 stsp echo "histedit succeeded unexpectedly" >&2
882 14eb0fef 2023-10-26 stsp test_done "$testroot" "1"
883 14eb0fef 2023-10-26 stsp return 1
884 14eb0fef 2023-10-26 stsp fi
885 14eb0fef 2023-10-26 stsp
886 14eb0fef 2023-10-26 stsp echo "got: commit $old_commit2 missing from histedit script" \
887 14eb0fef 2023-10-26 stsp > $testroot/stderr.expected
888 14eb0fef 2023-10-26 stsp
889 14eb0fef 2023-10-26 stsp cmp -s $testroot/stderr.expected $testroot/stderr
890 14eb0fef 2023-10-26 stsp ret=$?
891 14eb0fef 2023-10-26 stsp if [ $ret -ne 0 ]; then
892 14eb0fef 2023-10-26 stsp diff -u $testroot/stderr.expected $testroot/stderr
893 14eb0fef 2023-10-26 stsp fi
894 14eb0fef 2023-10-26 stsp test_done "$testroot" "$ret"
895 14eb0fef 2023-10-26 stsp }
896 14eb0fef 2023-10-26 stsp
897 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
898 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
899 0ebf8283 2019-07-24 stsp
900 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
901 0ebf8283 2019-07-24 stsp
902 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
903 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
904 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
905 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
906 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
907 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
908 0ebf8283 2019-07-24 stsp
909 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
910 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
911 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
912 0ebf8283 2019-07-24 stsp
913 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
914 49c543a6 2022-03-31 naddy ret=$?
915 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
916 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
917 0ebf8283 2019-07-24 stsp return 1
918 0ebf8283 2019-07-24 stsp fi
919 41f061b2 2021-10-05 stsp
920 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
921 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
922 0ebf8283 2019-07-24 stsp
923 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
924 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
925 0ebf8283 2019-07-24 stsp
926 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
927 0ebf8283 2019-07-24 stsp > $testroot/stdout)
928 0ebf8283 2019-07-24 stsp
929 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
930 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
931 0ebf8283 2019-07-24 stsp
932 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
933 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
934 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
935 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
936 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
937 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
938 49c543a6 2022-03-31 naddy ret=$?
939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
940 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
942 0ebf8283 2019-07-24 stsp return 1
943 0ebf8283 2019-07-24 stsp fi
944 0ebf8283 2019-07-24 stsp
945 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
946 0ebf8283 2019-07-24 stsp
947 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
948 0ebf8283 2019-07-24 stsp
949 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
950 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
951 0ebf8283 2019-07-24 stsp
952 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
953 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
954 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
955 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
956 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
957 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
958 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
959 0ebf8283 2019-07-24 stsp
960 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
961 49c543a6 2022-03-31 naddy ret=$?
962 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
963 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
964 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
965 0ebf8283 2019-07-24 stsp return 1
966 0ebf8283 2019-07-24 stsp fi
967 0ebf8283 2019-07-24 stsp
968 0ebf8283 2019-07-24 stsp for f in alpha beta; do
969 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
970 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
971 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
972 49c543a6 2022-03-31 naddy ret=$?
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
975 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
976 0ebf8283 2019-07-24 stsp return 1
977 0ebf8283 2019-07-24 stsp fi
978 0ebf8283 2019-07-24 stsp done
979 0ebf8283 2019-07-24 stsp
980 af179be7 2023-04-14 stsp if [ -e $testroot/wt/epsilon/new ]; then
981 af179be7 2023-04-14 stsp echo "removed file new still exists on disk" >&2
982 af179be7 2023-04-14 stsp test_done "$testroot" "1"
983 0ebf8283 2019-07-24 stsp return 1
984 0ebf8283 2019-07-24 stsp fi
985 0ebf8283 2019-07-24 stsp
986 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
987 0ebf8283 2019-07-24 stsp
988 af179be7 2023-04-14 stsp echo "? unversioned-file" > $testroot/stdout.expected
989 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
990 49c543a6 2022-03-31 naddy ret=$?
991 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
992 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
993 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
994 0ebf8283 2019-07-24 stsp return 1
995 0ebf8283 2019-07-24 stsp fi
996 0ebf8283 2019-07-24 stsp
997 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
998 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
999 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1000 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1001 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1002 49c543a6 2022-03-31 naddy ret=$?
1003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1004 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1005 0160a755 2019-07-25 stsp fi
1006 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1007 0160a755 2019-07-25 stsp }
1008 0160a755 2019-07-25 stsp
1009 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
1010 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
1011 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1012 0160a755 2019-07-25 stsp
1013 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1014 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1015 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1016 0160a755 2019-07-25 stsp
1017 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1018 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
1019 49c543a6 2022-03-31 naddy ret=$?
1020 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1021 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1022 0160a755 2019-07-25 stsp return 1
1023 0160a755 2019-07-25 stsp fi
1024 0160a755 2019-07-25 stsp
1025 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
1026 0160a755 2019-07-25 stsp
1027 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1028 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1029 0160a755 2019-07-25 stsp
1030 49c543a6 2022-03-31 naddy ret=$?
1031 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1032 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1033 0160a755 2019-07-25 stsp test_done "$testroot" "1"
1034 0160a755 2019-07-25 stsp return 1
1035 0160a755 2019-07-25 stsp fi
1036 0160a755 2019-07-25 stsp
1037 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1038 0160a755 2019-07-25 stsp > $testroot/stderr.expected
1039 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1040 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
1041 0160a755 2019-07-25 stsp
1042 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1043 49c543a6 2022-03-31 naddy ret=$?
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1046 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1047 0160a755 2019-07-25 stsp return 1
1048 0160a755 2019-07-25 stsp fi
1049 0160a755 2019-07-25 stsp
1050 0160a755 2019-07-25 stsp rm -rf $testroot/wt
1051 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1052 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
1053 49c543a6 2022-03-31 naddy ret=$?
1054 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1055 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1056 0160a755 2019-07-25 stsp return 1
1057 0160a755 2019-07-25 stsp fi
1058 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1059 0160a755 2019-07-25 stsp > $testroot/stdout)
1060 0160a755 2019-07-25 stsp
1061 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1062 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1063 0160a755 2019-07-25 stsp
1064 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
1065 0160a755 2019-07-25 stsp > $testroot/stdout.expected
1066 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1067 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
1068 0160a755 2019-07-25 stsp
1069 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1070 49c543a6 2022-03-31 naddy ret=$?
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1073 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1074 0160a755 2019-07-25 stsp return 1
1075 0ebf8283 2019-07-24 stsp fi
1076 0160a755 2019-07-25 stsp
1077 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
1078 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1079 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1080 49c543a6 2022-03-31 naddy ret=$?
1081 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1082 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1083 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1084 0160a755 2019-07-25 stsp return 1
1085 0160a755 2019-07-25 stsp fi
1086 0160a755 2019-07-25 stsp
1087 0160a755 2019-07-25 stsp
1088 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1089 0160a755 2019-07-25 stsp
1090 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
1091 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1092 49c543a6 2022-03-31 naddy ret=$?
1093 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1094 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1095 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1096 0160a755 2019-07-25 stsp return 1
1097 0160a755 2019-07-25 stsp fi
1098 0160a755 2019-07-25 stsp
1099 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1100 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
1101 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1102 49c543a6 2022-03-31 naddy ret=$?
1103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1104 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1105 b2c50a0a 2019-07-25 stsp fi
1106 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1107 b2c50a0a 2019-07-25 stsp }
1108 b2c50a0a 2019-07-25 stsp
1109 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1110 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1111 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1112 b2c50a0a 2019-07-25 stsp
1113 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1114 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1115 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1116 b2c50a0a 2019-07-25 stsp
1117 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1118 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1119 b2c50a0a 2019-07-25 stsp
1120 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1121 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1122 49c543a6 2022-03-31 naddy ret=$?
1123 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1124 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1125 b2c50a0a 2019-07-25 stsp return 1
1126 b2c50a0a 2019-07-25 stsp fi
1127 b2c50a0a 2019-07-25 stsp
1128 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1129 b2c50a0a 2019-07-25 stsp
1130 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1131 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1132 b2c50a0a 2019-07-25 stsp
1133 49c543a6 2022-03-31 naddy ret=$?
1134 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1135 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1136 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1137 b2c50a0a 2019-07-25 stsp return 1
1138 b2c50a0a 2019-07-25 stsp fi
1139 b2c50a0a 2019-07-25 stsp
1140 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1141 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1142 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1143 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1144 b2c50a0a 2019-07-25 stsp
1145 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1146 49c543a6 2022-03-31 naddy ret=$?
1147 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1148 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1149 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1150 b2c50a0a 2019-07-25 stsp return 1
1151 b2c50a0a 2019-07-25 stsp fi
1152 b2c50a0a 2019-07-25 stsp
1153 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1154 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1155 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1156 49c543a6 2022-03-31 naddy ret=$?
1157 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1158 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1159 b2c50a0a 2019-07-25 stsp return 1
1160 b2c50a0a 2019-07-25 stsp fi
1161 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1162 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1163 b2c50a0a 2019-07-25 stsp
1164 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1165 b2c50a0a 2019-07-25 stsp
1166 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1167 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1168 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1169 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1170 49c543a6 2022-03-31 naddy ret=$?
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1173 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1174 b2c50a0a 2019-07-25 stsp return 1
1175 0160a755 2019-07-25 stsp fi
1176 b2c50a0a 2019-07-25 stsp
1177 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1178 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1179 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1180 49c543a6 2022-03-31 naddy ret=$?
1181 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1182 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1183 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1184 b2c50a0a 2019-07-25 stsp return 1
1185 b2c50a0a 2019-07-25 stsp fi
1186 b2c50a0a 2019-07-25 stsp
1187 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1188 b2c50a0a 2019-07-25 stsp
1189 f4ab0e57 2024-03-28 stsp cat > $testroot/stdout.expected <<EOF
1190 f4ab0e57 2024-03-28 stsp M zeta
1191 f4ab0e57 2024-03-28 stsp Work tree is editing the history of refs/heads/master
1192 f4ab0e57 2024-03-28 stsp EOF
1193 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1194 49c543a6 2022-03-31 naddy ret=$?
1195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1196 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1197 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1198 b2c50a0a 2019-07-25 stsp return 1
1199 b2c50a0a 2019-07-25 stsp fi
1200 14eb0fef 2023-10-26 stsp
1201 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1202 14eb0fef 2023-10-26 stsp #!/bin/sh
1203 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1204 14eb0fef 2023-10-26 stsp ,s/.*/modified zeta/
1205 14eb0fef 2023-10-26 stsp w
1206 14eb0fef 2023-10-26 stsp EOF
1207 14eb0fef 2023-10-26 stsp EOF
1208 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1209 b2c50a0a 2019-07-25 stsp
1210 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1211 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1212 14eb0fef 2023-10-26 stsp got histedit -c > $testroot/stdout)
1213 b2c50a0a 2019-07-25 stsp
1214 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1215 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1216 b2c50a0a 2019-07-25 stsp
1217 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1218 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1219 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1220 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1221 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1222 b2c50a0a 2019-07-25 stsp
1223 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1224 49c543a6 2022-03-31 naddy ret=$?
1225 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1226 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1227 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1228 b2c50a0a 2019-07-25 stsp return 1
1229 b2c50a0a 2019-07-25 stsp fi
1230 b2c50a0a 2019-07-25 stsp
1231 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1232 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1233 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1234 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1235 49c543a6 2022-03-31 naddy ret=$?
1236 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1237 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1239 b2c50a0a 2019-07-25 stsp return 1
1240 b2c50a0a 2019-07-25 stsp fi
1241 b2c50a0a 2019-07-25 stsp
1242 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1243 b2c50a0a 2019-07-25 stsp > $testroot/diff
1244 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
1245 885e96df 2023-03-06 naddy ,s/$old_commit1/$new_commit1/
1246 885e96df 2023-03-06 naddy w
1247 885e96df 2023-03-06 naddy EOF
1248 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1249 49c543a6 2022-03-31 naddy ret=$?
1250 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1251 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1252 b2c50a0a 2019-07-25 stsp fi
1253 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1254 0ebf8283 2019-07-24 stsp }
1255 c7d20a3f 2019-07-30 stsp
1256 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1257 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1258 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1259 c7d20a3f 2019-07-30 stsp
1260 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1261 49c543a6 2022-03-31 naddy ret=$?
1262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1263 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1264 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1265 c7d20a3f 2019-07-30 stsp return 1
1266 c7d20a3f 2019-07-30 stsp fi
1267 c7d20a3f 2019-07-30 stsp
1268 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1269 c7d20a3f 2019-07-30 stsp
1270 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1271 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1272 49c543a6 2022-03-31 naddy ret=$?
1273 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1274 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1275 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1276 c7d20a3f 2019-07-30 stsp return 1
1277 c7d20a3f 2019-07-30 stsp fi
1278 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1279 0ebf8283 2019-07-24 stsp
1280 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1281 49c543a6 2022-03-31 naddy ret=$?
1282 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1283 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1284 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1285 c7d20a3f 2019-07-30 stsp return 1
1286 c7d20a3f 2019-07-30 stsp fi
1287 c7d20a3f 2019-07-30 stsp
1288 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1289 49c543a6 2022-03-31 naddy ret=$?
1290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1291 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1292 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1293 c7d20a3f 2019-07-30 stsp return 1
1294 c7d20a3f 2019-07-30 stsp fi
1295 c7d20a3f 2019-07-30 stsp
1296 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1297 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1298 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1299 c7d20a3f 2019-07-30 stsp
1300 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1301 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1302 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1303 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1304 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1305 49c543a6 2022-03-31 naddy ret=$?
1306 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1307 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1308 0def28b1 2019-08-17 stsp fi
1309 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1310 0def28b1 2019-08-17 stsp }
1311 0def28b1 2019-08-17 stsp
1312 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1313 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1314 0def28b1 2019-08-17 stsp
1315 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1316 0def28b1 2019-08-17 stsp
1317 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1318 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1319 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1320 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1321 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1322 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1323 0def28b1 2019-08-17 stsp
1324 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1325 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1326 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1327 0def28b1 2019-08-17 stsp
1328 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1329 49c543a6 2022-03-31 naddy ret=$?
1330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1331 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1332 0def28b1 2019-08-17 stsp return 1
1333 0def28b1 2019-08-17 stsp fi
1334 0def28b1 2019-08-17 stsp
1335 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1336 14eb0fef 2023-10-26 stsp #!/bin/sh
1337 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1338 14eb0fef 2023-10-26 stsp ,s/.*/committing folded changes/
1339 14eb0fef 2023-10-26 stsp w
1340 14eb0fef 2023-10-26 stsp EOF
1341 14eb0fef 2023-10-26 stsp EOF
1342 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1343 14eb0fef 2023-10-26 stsp
1344 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1345 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1346 14eb0fef 2023-10-26 stsp echo "mesg $old_commit1" >> $testroot/histedit-script
1347 0def28b1 2019-08-17 stsp
1348 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1349 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1350 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout \
1351 14eb0fef 2023-10-26 stsp 2> $testroot/stderr)
1352 0def28b1 2019-08-17 stsp
1353 49c543a6 2022-03-31 naddy ret=$?
1354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1355 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1356 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1357 0def28b1 2019-08-17 stsp return 1
1358 c7d20a3f 2019-07-30 stsp fi
1359 0def28b1 2019-08-17 stsp
1360 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1361 0def28b1 2019-08-17 stsp
1362 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1363 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1364 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1365 0def28b1 2019-08-17 stsp
1366 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1367 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1368 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1369 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1370 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1371 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1372 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1373 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1374 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1375 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1376 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1377 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1378 0def28b1 2019-08-17 stsp
1379 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1380 49c543a6 2022-03-31 naddy ret=$?
1381 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1382 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1383 0def28b1 2019-08-17 stsp fi
1384 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1385 c7d20a3f 2019-07-30 stsp }
1386 de05890f 2020-03-05 stsp
1387 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1388 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1389 de05890f 2020-03-05 stsp
1390 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1391 de05890f 2020-03-05 stsp
1392 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1393 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1394 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1395 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1396 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1397 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1398 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1399 de05890f 2020-03-05 stsp
1400 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1401 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1402 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1403 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1404 c7d20a3f 2019-07-30 stsp
1405 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1406 49c543a6 2022-03-31 naddy ret=$?
1407 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1408 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1409 de05890f 2020-03-05 stsp return 1
1410 de05890f 2020-03-05 stsp fi
1411 de05890f 2020-03-05 stsp
1412 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1413 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1414 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1415 de05890f 2020-03-05 stsp
1416 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1417 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1418 49c543a6 2022-03-31 naddy ret=$?
1419 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1420 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1421 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1422 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1423 de05890f 2020-03-05 stsp return 1
1424 de05890f 2020-03-05 stsp fi
1425 de05890f 2020-03-05 stsp
1426 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1427 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1428 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1429 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1430 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1431 de05890f 2020-03-05 stsp
1432 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1433 49c543a6 2022-03-31 naddy ret=$?
1434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1435 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1436 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1437 de05890f 2020-03-05 stsp return 1
1438 de05890f 2020-03-05 stsp fi
1439 de05890f 2020-03-05 stsp
1440 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1441 49c543a6 2022-03-31 naddy ret=$?
1442 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1443 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1444 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1445 de05890f 2020-03-05 stsp return 1
1446 de05890f 2020-03-05 stsp fi
1447 de05890f 2020-03-05 stsp
1448 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1449 49c543a6 2022-03-31 naddy ret=$?
1450 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1451 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1452 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1453 de05890f 2020-03-05 stsp return 1
1454 de05890f 2020-03-05 stsp fi
1455 de05890f 2020-03-05 stsp
1456 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1457 49c543a6 2022-03-31 naddy ret=$?
1458 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1459 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1460 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1461 de05890f 2020-03-05 stsp return 1
1462 de05890f 2020-03-05 stsp fi
1463 de05890f 2020-03-05 stsp
1464 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1465 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1466 49c543a6 2022-03-31 naddy ret=$?
1467 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1468 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1469 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1470 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1471 de05890f 2020-03-05 stsp return 1
1472 de05890f 2020-03-05 stsp fi
1473 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1474 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1475 de05890f 2020-03-05 stsp
1476 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1477 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1478 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1479 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1480 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1481 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1482 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1483 de05890f 2020-03-05 stsp
1484 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1485 49c543a6 2022-03-31 naddy ret=$?
1486 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1487 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1488 5b87815e 2020-03-05 stsp fi
1489 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1490 5b87815e 2020-03-05 stsp
1491 5b87815e 2020-03-05 stsp }
1492 5b87815e 2020-03-05 stsp
1493 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1494 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1495 5b87815e 2020-03-05 stsp
1496 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1497 5b87815e 2020-03-05 stsp
1498 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1499 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1500 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1501 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1502 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1503 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1504 5b87815e 2020-03-05 stsp
1505 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1506 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1507 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1508 5b87815e 2020-03-05 stsp
1509 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1510 49c543a6 2022-03-31 naddy ret=$?
1511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1512 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1513 5b87815e 2020-03-05 stsp return 1
1514 5b87815e 2020-03-05 stsp fi
1515 5b87815e 2020-03-05 stsp
1516 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1517 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1518 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1519 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1520 5b87815e 2020-03-05 stsp
1521 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1522 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1523 49c543a6 2022-03-31 naddy ret=$?
1524 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1525 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1526 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1527 ea4ee74a 2023-06-17 op test_done "$testroot" 1
1528 5b87815e 2020-03-05 stsp return 1
1529 de05890f 2020-03-05 stsp fi
1530 5b87815e 2020-03-05 stsp
1531 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1532 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1533 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1534 5b87815e 2020-03-05 stsp
1535 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1536 49c543a6 2022-03-31 naddy ret=$?
1537 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1538 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1539 5b87815e 2020-03-05 stsp fi
1540 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1541 de05890f 2020-03-05 stsp
1542 de05890f 2020-03-05 stsp }
1543 ecfff807 2020-09-23 stsp
1544 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1545 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1546 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1547 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1548 ecfff807 2020-09-23 stsp
1549 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1550 ecfff807 2020-09-23 stsp
1551 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1552 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/psi
1553 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1554 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1555 ecfff807 2020-09-23 stsp
1556 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1557 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1558 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1559 ecfff807 2020-09-23 stsp
1560 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q epsilon/psi
1561 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1562 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1563 ecfff807 2020-09-23 stsp
1564 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1565 49c543a6 2022-03-31 naddy ret=$?
1566 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1567 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1568 ecfff807 2020-09-23 stsp return 1
1569 ecfff807 2020-09-23 stsp fi
1570 de05890f 2020-03-05 stsp
1571 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1572 14eb0fef 2023-10-26 stsp #!/bin/sh
1573 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1574 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1575 14eb0fef 2023-10-26 stsp w
1576 14eb0fef 2023-10-26 stsp EOF
1577 14eb0fef 2023-10-26 stsp EOF
1578 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1579 14eb0fef 2023-10-26 stsp
1580 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1581 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1582 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1583 ecfff807 2020-09-23 stsp
1584 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1585 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1586 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1587 ecfff807 2020-09-23 stsp
1588 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1589 ecfff807 2020-09-23 stsp
1590 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1591 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1592 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1593 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1594 ecfff807 2020-09-23 stsp
1595 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1596 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1597 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1598 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1599 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1600 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1601 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1602 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1603 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1604 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1605 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1606 ecfff807 2020-09-23 stsp
1607 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1608 49c543a6 2022-03-31 naddy ret=$?
1609 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1610 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1611 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1612 ecfff807 2020-09-23 stsp return 1
1613 ecfff807 2020-09-23 stsp fi
1614 ecfff807 2020-09-23 stsp
1615 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1616 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1617 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1618 ecfff807 2020-09-23 stsp return 1
1619 ecfff807 2020-09-23 stsp fi
1620 ecfff807 2020-09-23 stsp
1621 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1622 ecfff807 2020-09-23 stsp
1623 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1624 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1625 49c543a6 2022-03-31 naddy ret=$?
1626 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1627 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1628 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1629 ecfff807 2020-09-23 stsp return 1
1630 ecfff807 2020-09-23 stsp fi
1631 ecfff807 2020-09-23 stsp
1632 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1633 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1634 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1635 49c543a6 2022-03-31 naddy ret=$?
1636 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1637 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1638 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1639 29c68398 2020-09-24 stsp return 1
1640 29c68398 2020-09-24 stsp fi
1641 29c68398 2020-09-24 stsp
1642 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1643 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1644 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1645 49c543a6 2022-03-31 naddy ret=$?
1646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1647 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1648 15aed053 2023-03-07 naddy fi
1649 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1650 15aed053 2023-03-07 naddy }
1651 c2ba7aa6 2023-07-26 stsp
1652 c2ba7aa6 2023-07-26 stsp # if a previous commit edits a file, and it is folded into a commit
1653 c2ba7aa6 2023-07-26 stsp # that deletes the same file, the file will be deleted by histedit
1654 c2ba7aa6 2023-07-26 stsp test_histedit_fold_edit_delete() {
1655 c2ba7aa6 2023-07-26 stsp local testroot=`test_init histedit_fold_edit_delete`
1656 c2ba7aa6 2023-07-26 stsp
1657 c2ba7aa6 2023-07-26 stsp local orig_commit=`git_show_head $testroot/repo`
1658 c2ba7aa6 2023-07-26 stsp
1659 c2ba7aa6 2023-07-26 stsp echo "modify alpha" > $testroot/repo/alpha
1660 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add alpha
1661 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "modified alpha"
1662 c2ba7aa6 2023-07-26 stsp local old_commit1=`git_show_head $testroot/repo`
1663 15aed053 2023-03-07 naddy
1664 c2ba7aa6 2023-07-26 stsp git_rm $testroot/repo alpha
1665 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "deleted alpha"
1666 c2ba7aa6 2023-07-26 stsp local old_commit2=`git_show_head $testroot/repo`
1667 c2ba7aa6 2023-07-26 stsp
1668 c2ba7aa6 2023-07-26 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1669 c2ba7aa6 2023-07-26 stsp ret=$?
1670 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1671 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1672 c2ba7aa6 2023-07-26 stsp return 1
1673 c2ba7aa6 2023-07-26 stsp fi
1674 c2ba7aa6 2023-07-26 stsp
1675 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1676 14eb0fef 2023-10-26 stsp #!/bin/sh
1677 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1678 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1679 14eb0fef 2023-10-26 stsp w
1680 14eb0fef 2023-10-26 stsp EOF
1681 14eb0fef 2023-10-26 stsp EOF
1682 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1683 14eb0fef 2023-10-26 stsp
1684 c2ba7aa6 2023-07-26 stsp echo "fold $old_commit1" > $testroot/histedit-script
1685 c2ba7aa6 2023-07-26 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1686 c2ba7aa6 2023-07-26 stsp
1687 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1688 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1689 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1690 c2ba7aa6 2023-07-26 stsp
1691 c2ba7aa6 2023-07-26 stsp local new_commit1=`git_show_head $testroot/repo`
1692 c2ba7aa6 2023-07-26 stsp
1693 c2ba7aa6 2023-07-26 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1694 c2ba7aa6 2023-07-26 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1695 c2ba7aa6 2023-07-26 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1696 c2ba7aa6 2023-07-26 stsp
1697 c2ba7aa6 2023-07-26 stsp echo "G alpha" >> $testroot/stdout.expected
1698 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit1 -> fold commit: modified alpha" \
1699 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1700 c2ba7aa6 2023-07-26 stsp echo "D alpha" >> $testroot/stdout.expected
1701 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1702 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1703 c2ba7aa6 2023-07-26 stsp echo "Switching work tree to refs/heads/master" \
1704 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1705 c2ba7aa6 2023-07-26 stsp
1706 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1707 c2ba7aa6 2023-07-26 stsp ret=$?
1708 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1709 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1710 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1711 c2ba7aa6 2023-07-26 stsp return 1
1712 c2ba7aa6 2023-07-26 stsp fi
1713 c2ba7aa6 2023-07-26 stsp
1714 c2ba7aa6 2023-07-26 stsp if [ -e $testroot/wt/alpha ]; then
1715 c2ba7aa6 2023-07-26 stsp echo "removed file alpha still exists on disk" >&2
1716 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "1"
1717 c2ba7aa6 2023-07-26 stsp return 1
1718 c2ba7aa6 2023-07-26 stsp fi
1719 c2ba7aa6 2023-07-26 stsp
1720 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1721 c2ba7aa6 2023-07-26 stsp
1722 c2ba7aa6 2023-07-26 stsp echo -n > $testroot/stdout.expected
1723 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1724 c2ba7aa6 2023-07-26 stsp ret=$?
1725 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1726 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1727 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1728 c2ba7aa6 2023-07-26 stsp return 1
1729 c2ba7aa6 2023-07-26 stsp fi
1730 c2ba7aa6 2023-07-26 stsp
1731 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1732 c2ba7aa6 2023-07-26 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1733 c2ba7aa6 2023-07-26 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1734 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1735 c2ba7aa6 2023-07-26 stsp ret=$?
1736 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1737 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1738 c2ba7aa6 2023-07-26 stsp fi
1739 c2ba7aa6 2023-07-26 stsp
1740 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1741 c2ba7aa6 2023-07-26 stsp }
1742 c2ba7aa6 2023-07-26 stsp
1743 15aed053 2023-03-07 naddy test_histedit_fold_delete_add() {
1744 15aed053 2023-03-07 naddy local testroot=`test_init histedit_fold_delete_add`
1745 15aed053 2023-03-07 naddy
1746 15aed053 2023-03-07 naddy local orig_commit=`git_show_head $testroot/repo`
1747 15aed053 2023-03-07 naddy
1748 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q alpha
1749 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "removing alpha"
1750 15aed053 2023-03-07 naddy local old_commit1=`git_show_head $testroot/repo`
1751 15aed053 2023-03-07 naddy
1752 15aed053 2023-03-07 naddy echo "modified alpha" >$testroot/repo/alpha
1753 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add alpha
1754 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "add back modified alpha"
1755 15aed053 2023-03-07 naddy local old_commit2=`git_show_head $testroot/repo`
1756 15aed053 2023-03-07 naddy
1757 15aed053 2023-03-07 naddy got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1758 15aed053 2023-03-07 naddy ret=$?
1759 15aed053 2023-03-07 naddy if [ $ret -ne 0 ]; then
1760 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1761 15aed053 2023-03-07 naddy return 1
1762 15aed053 2023-03-07 naddy fi
1763 15aed053 2023-03-07 naddy
1764 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
1765 14eb0fef 2023-10-26 stsp #!/bin/sh
1766 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
1767 14eb0fef 2023-10-26 stsp ,s/.*/folded changes/
1768 14eb0fef 2023-10-26 stsp w
1769 14eb0fef 2023-10-26 stsp EOF
1770 14eb0fef 2023-10-26 stsp EOF
1771 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
1772 14eb0fef 2023-10-26 stsp
1773 15aed053 2023-03-07 naddy echo "fold $old_commit1" > $testroot/histedit-script
1774 15aed053 2023-03-07 naddy echo "pick $old_commit2" >> $testroot/histedit-script
1775 14eb0fef 2023-10-26 stsp
1776 14eb0fef 2023-10-26 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1777 14eb0fef 2023-10-26 stsp VISUAL="$testroot/editor.sh" \
1778 14eb0fef 2023-10-26 stsp got histedit -F $testroot/histedit-script > $testroot/stdout)
1779 15aed053 2023-03-07 naddy
1780 15aed053 2023-03-07 naddy local new_commit1=`git_show_head $testroot/repo`
1781 15aed053 2023-03-07 naddy
1782 15aed053 2023-03-07 naddy local short_old_commit1=`trim_obj_id 28 $old_commit1`
1783 15aed053 2023-03-07 naddy local short_old_commit2=`trim_obj_id 28 $old_commit2`
1784 15aed053 2023-03-07 naddy local short_new_commit1=`trim_obj_id 28 $new_commit1`
1785 15aed053 2023-03-07 naddy
1786 15aed053 2023-03-07 naddy echo "D alpha" > $testroot/stdout.expected
1787 15aed053 2023-03-07 naddy echo "$short_old_commit1 -> fold commit: removing alpha" \
1788 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1789 15aed053 2023-03-07 naddy echo "A alpha" >> $testroot/stdout.expected
1790 15aed053 2023-03-07 naddy echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1791 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1792 15aed053 2023-03-07 naddy echo "Switching work tree to refs/heads/master" \
1793 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1794 15aed053 2023-03-07 naddy
1795 9a298e5c 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1796 9a298e5c 2023-03-10 stsp ret=$?
1797 9a298e5c 2023-03-10 stsp if [ $ret -ne 0 ]; then
1798 9a298e5c 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1799 9a298e5c 2023-03-10 stsp test_done "$testroot" "$ret"
1800 9a298e5c 2023-03-10 stsp return 1
1801 9a298e5c 2023-03-10 stsp fi
1802 15aed053 2023-03-07 naddy
1803 15aed053 2023-03-07 naddy if [ ! -e $testroot/wt/alpha ]; then
1804 9a298e5c 2023-03-10 stsp echo "file alpha is missing on disk" >&2
1805 9a298e5c 2023-03-10 stsp test_done "$testroot" "1"
1806 5fdcbbb6 2023-03-14 naddy return 1
1807 5fdcbbb6 2023-03-14 naddy fi
1808 5fdcbbb6 2023-03-14 naddy
1809 5fdcbbb6 2023-03-14 naddy echo "modified alpha" > $testroot/content.expected
1810 5fdcbbb6 2023-03-14 naddy cat $testroot/wt/alpha > $testroot/content
1811 5fdcbbb6 2023-03-14 naddy cmp -s $testroot/content.expected $testroot/content
1812 5fdcbbb6 2023-03-14 naddy ret=$?
1813 5fdcbbb6 2023-03-14 naddy if [ $ret -ne 0 ]; then
1814 5fdcbbb6 2023-03-14 naddy diff -u $testroot/content.expected $testroot/content
1815 5fdcbbb6 2023-03-14 naddy test_done "$testroot" "$ret"
1816 9a298e5c 2023-03-10 stsp return 1
1817 ecfff807 2020-09-23 stsp fi
1818 9a298e5c 2023-03-10 stsp test_done "$testroot" "0"
1819 ecfff807 2020-09-23 stsp }
1820 239f5c5a 2020-12-13 stsp
1821 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1822 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1823 239f5c5a 2020-12-13 stsp
1824 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1825 239f5c5a 2020-12-13 stsp
1826 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1827 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1828 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1829 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1830 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1831 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1832 239f5c5a 2020-12-13 stsp
1833 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1834 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1835 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1836 239f5c5a 2020-12-13 stsp
1837 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1838 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1839 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1840 239f5c5a 2020-12-13 stsp
1841 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1842 49c543a6 2022-03-31 naddy ret=$?
1843 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1844 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1845 239f5c5a 2020-12-13 stsp return 1
1846 239f5c5a 2020-12-13 stsp fi
1847 239f5c5a 2020-12-13 stsp
1848 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1849 239f5c5a 2020-12-13 stsp #!/bin/sh
1850 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1851 885e96df 2023-03-06 naddy ,s/.*/committing folded changes/
1852 885e96df 2023-03-06 naddy w
1853 885e96df 2023-03-06 naddy EOF
1854 239f5c5a 2020-12-13 stsp EOF
1855 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1856 239f5c5a 2020-12-13 stsp
1857 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1858 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1859 239f5c5a 2020-12-13 stsp
1860 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1861 239f5c5a 2020-12-13 stsp
1862 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1863 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1864 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1865 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1866 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1867 239f5c5a 2020-12-13 stsp
1868 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1869 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1870 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1871 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1872 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1873 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1874 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1875 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1876 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1877 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1878 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1879 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1880 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1881 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1882 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1883 ecfff807 2020-09-23 stsp
1884 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1885 49c543a6 2022-03-31 naddy ret=$?
1886 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1887 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1888 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1889 239f5c5a 2020-12-13 stsp return 1
1890 239f5c5a 2020-12-13 stsp fi
1891 ecfff807 2020-09-23 stsp
1892 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1893 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1894 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1895 49c543a6 2022-03-31 naddy ret=$?
1896 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1897 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1898 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1899 239f5c5a 2020-12-13 stsp return 1
1900 239f5c5a 2020-12-13 stsp fi
1901 239f5c5a 2020-12-13 stsp
1902 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1903 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1904 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1905 239f5c5a 2020-12-13 stsp return 1
1906 239f5c5a 2020-12-13 stsp fi
1907 239f5c5a 2020-12-13 stsp
1908 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1909 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1910 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1911 49c543a6 2022-03-31 naddy ret=$?
1912 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1913 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1914 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1915 239f5c5a 2020-12-13 stsp return 1
1916 239f5c5a 2020-12-13 stsp fi
1917 239f5c5a 2020-12-13 stsp
1918 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1919 239f5c5a 2020-12-13 stsp
1920 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1921 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1922 49c543a6 2022-03-31 naddy ret=$?
1923 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1924 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1925 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1926 239f5c5a 2020-12-13 stsp return 1
1927 239f5c5a 2020-12-13 stsp fi
1928 239f5c5a 2020-12-13 stsp
1929 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1930 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1931 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1932 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1933 49c543a6 2022-03-31 naddy ret=$?
1934 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1935 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1936 239f5c5a 2020-12-13 stsp fi
1937 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1938 239f5c5a 2020-12-13 stsp }
1939 a347e6bb 2020-12-13 stsp
1940 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1941 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1942 a347e6bb 2020-12-13 stsp
1943 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1944 a347e6bb 2020-12-13 stsp
1945 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1946 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1947 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1948 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1949 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1950 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1951 239f5c5a 2020-12-13 stsp
1952 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1953 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1954 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1955 a347e6bb 2020-12-13 stsp
1956 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1957 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1958 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1959 a347e6bb 2020-12-13 stsp
1960 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1961 49c543a6 2022-03-31 naddy ret=$?
1962 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1963 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1964 a347e6bb 2020-12-13 stsp return 1
1965 a347e6bb 2020-12-13 stsp fi
1966 a347e6bb 2020-12-13 stsp
1967 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1968 a347e6bb 2020-12-13 stsp #!/bin/sh
1969 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1970 885e96df 2023-03-06 naddy ,d
1971 885e96df 2023-03-06 naddy w
1972 885e96df 2023-03-06 naddy EOF
1973 a347e6bb 2020-12-13 stsp EOF
1974 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1975 a347e6bb 2020-12-13 stsp
1976 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1977 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1978 a347e6bb 2020-12-13 stsp
1979 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1980 a347e6bb 2020-12-13 stsp
1981 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1982 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1983 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1984 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1985 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1986 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1987 a347e6bb 2020-12-13 stsp
1988 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1989 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1990 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1991 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1992 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1993 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1994 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1995 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1996 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1997 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1998 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1999 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
2000 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
2001 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
2002 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
2003 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
2004 a347e6bb 2020-12-13 stsp
2005 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2006 49c543a6 2022-03-31 naddy ret=$?
2007 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2008 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2009 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2010 a347e6bb 2020-12-13 stsp return 1
2011 a347e6bb 2020-12-13 stsp fi
2012 a347e6bb 2020-12-13 stsp
2013 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
2014 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
2015 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
2016 49c543a6 2022-03-31 naddy ret=$?
2017 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2018 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
2019 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2020 a347e6bb 2020-12-13 stsp return 1
2021 a347e6bb 2020-12-13 stsp fi
2022 a347e6bb 2020-12-13 stsp
2023 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
2024 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
2025 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
2026 a347e6bb 2020-12-13 stsp return 1
2027 a347e6bb 2020-12-13 stsp fi
2028 a347e6bb 2020-12-13 stsp
2029 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
2030 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
2031 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
2032 49c543a6 2022-03-31 naddy ret=$?
2033 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2034 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
2035 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2036 a347e6bb 2020-12-13 stsp return 1
2037 a347e6bb 2020-12-13 stsp fi
2038 a347e6bb 2020-12-13 stsp
2039 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
2040 a347e6bb 2020-12-13 stsp
2041 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
2042 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2043 49c543a6 2022-03-31 naddy ret=$?
2044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2045 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2046 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2047 a347e6bb 2020-12-13 stsp return 1
2048 a347e6bb 2020-12-13 stsp fi
2049 a347e6bb 2020-12-13 stsp
2050 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2051 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
2052 b93c7142 2021-10-01 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2053 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2054 49c543a6 2022-03-31 naddy ret=$?
2055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2056 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2057 b93c7142 2021-10-01 stsp fi
2058 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2059 b93c7142 2021-10-01 stsp }
2060 b93c7142 2021-10-01 stsp
2061 b93c7142 2021-10-01 stsp test_histedit_edit_only() {
2062 b93c7142 2021-10-01 stsp local testroot=`test_init histedit_edit_only`
2063 b93c7142 2021-10-01 stsp
2064 b93c7142 2021-10-01 stsp local orig_commit=`git_show_head $testroot/repo`
2065 b93c7142 2021-10-01 stsp
2066 b93c7142 2021-10-01 stsp echo "modified alpha on master" > $testroot/repo/alpha
2067 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
2068 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/repo/epsilon/new
2069 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
2070 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing changes"
2071 b93c7142 2021-10-01 stsp local old_commit1=`git_show_head $testroot/repo`
2072 b93c7142 2021-10-01 stsp
2073 b93c7142 2021-10-01 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2074 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing to zeta on master"
2075 b93c7142 2021-10-01 stsp local old_commit2=`git_show_head $testroot/repo`
2076 b93c7142 2021-10-01 stsp
2077 b93c7142 2021-10-01 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2078 49c543a6 2022-03-31 naddy ret=$?
2079 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2080 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2081 b93c7142 2021-10-01 stsp return 1
2082 b93c7142 2021-10-01 stsp fi
2083 b93c7142 2021-10-01 stsp
2084 b93c7142 2021-10-01 stsp (cd $testroot/wt && got histedit -e > $testroot/stdout)
2085 b93c7142 2021-10-01 stsp
2086 b93c7142 2021-10-01 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2087 b93c7142 2021-10-01 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
2088 b93c7142 2021-10-01 stsp
2089 b93c7142 2021-10-01 stsp echo "G alpha" > $testroot/stdout.expected
2090 b93c7142 2021-10-01 stsp echo "D beta" >> $testroot/stdout.expected
2091 b93c7142 2021-10-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
2092 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit1" \
2093 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2094 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2095 49c543a6 2022-03-31 naddy ret=$?
2096 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2097 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2098 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2099 b93c7142 2021-10-01 stsp return 1
2100 b93c7142 2021-10-01 stsp fi
2101 b93c7142 2021-10-01 stsp
2102 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
2103 b93c7142 2021-10-01 stsp
2104 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
2105 b93c7142 2021-10-01 stsp #!/bin/sh
2106 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2107 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 1/
2108 885e96df 2023-03-06 naddy w
2109 885e96df 2023-03-06 naddy EOF
2110 b93c7142 2021-10-01 stsp EOF
2111 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
2112 b93c7142 2021-10-01 stsp
2113 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2114 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2115 b93c7142 2021-10-01 stsp
2116 b93c7142 2021-10-01 stsp local new_commit1=$(cd $testroot/wt && got info | \
2117 b93c7142 2021-10-01 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
2118 b93c7142 2021-10-01 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2119 b93c7142 2021-10-01 stsp
2120 b93c7142 2021-10-01 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
2121 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
2122 b93c7142 2021-10-01 stsp echo "committing edited changes 1" >> $testroot/stdout.expected
2123 b93c7142 2021-10-01 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
2124 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit2" \
2125 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2126 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2127 49c543a6 2022-03-31 naddy ret=$?
2128 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2129 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2130 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2131 b93c7142 2021-10-01 stsp return 1
2132 b93c7142 2021-10-01 stsp fi
2133 b93c7142 2021-10-01 stsp
2134 b93c7142 2021-10-01 stsp echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2135 b93c7142 2021-10-01 stsp
2136 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
2137 b93c7142 2021-10-01 stsp #!/bin/sh
2138 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2139 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 2/
2140 885e96df 2023-03-06 naddy w
2141 885e96df 2023-03-06 naddy EOF
2142 b93c7142 2021-10-01 stsp EOF
2143 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
2144 b93c7142 2021-10-01 stsp
2145 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2146 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2147 b93c7142 2021-10-01 stsp
2148 b93c7142 2021-10-01 stsp local new_commit2=`git_show_head $testroot/repo`
2149 b93c7142 2021-10-01 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
2150 b93c7142 2021-10-01 stsp
2151 b93c7142 2021-10-01 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
2152 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
2153 b93c7142 2021-10-01 stsp echo "committing edited changes 2" >> $testroot/stdout.expected
2154 b93c7142 2021-10-01 stsp echo "Switching work tree to refs/heads/master" \
2155 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2156 b93c7142 2021-10-01 stsp
2157 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2158 49c543a6 2022-03-31 naddy ret=$?
2159 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2160 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2161 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2162 b93c7142 2021-10-01 stsp return 1
2163 b93c7142 2021-10-01 stsp fi
2164 b93c7142 2021-10-01 stsp
2165 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/content.expected
2166 b93c7142 2021-10-01 stsp cat $testroot/wt/alpha > $testroot/content
2167 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2168 49c543a6 2022-03-31 naddy ret=$?
2169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2170 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2171 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2172 b93c7142 2021-10-01 stsp return 1
2173 b93c7142 2021-10-01 stsp fi
2174 b93c7142 2021-10-01 stsp
2175 b93c7142 2021-10-01 stsp if [ -e $testroot/wt/beta ]; then
2176 b93c7142 2021-10-01 stsp echo "removed file beta still exists on disk" >&2
2177 b93c7142 2021-10-01 stsp test_done "$testroot" "1"
2178 b93c7142 2021-10-01 stsp return 1
2179 b93c7142 2021-10-01 stsp fi
2180 b93c7142 2021-10-01 stsp
2181 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/content.expected
2182 b93c7142 2021-10-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
2183 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2184 49c543a6 2022-03-31 naddy ret=$?
2185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2186 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2187 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2188 b93c7142 2021-10-01 stsp return 1
2189 b93c7142 2021-10-01 stsp fi
2190 b93c7142 2021-10-01 stsp
2191 b93c7142 2021-10-01 stsp (cd $testroot/wt && got status > $testroot/stdout)
2192 b93c7142 2021-10-01 stsp
2193 b93c7142 2021-10-01 stsp echo -n > $testroot/stdout.expected
2194 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2195 49c543a6 2022-03-31 naddy ret=$?
2196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2197 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2198 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2199 b93c7142 2021-10-01 stsp return 1
2200 b93c7142 2021-10-01 stsp fi
2201 b93c7142 2021-10-01 stsp
2202 b93c7142 2021-10-01 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2203 b93c7142 2021-10-01 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2204 b93c7142 2021-10-01 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
2205 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2206 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2207 49c543a6 2022-03-31 naddy ret=$?
2208 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2209 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2210 a347e6bb 2020-12-13 stsp fi
2211 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2212 a347e6bb 2020-12-13 stsp }
2213 09209b8a 2021-10-08 stsp
2214 09209b8a 2021-10-08 stsp test_histedit_prepend_line() {
2215 09209b8a 2021-10-08 stsp local testroot=`test_init histedit_prepend_line`
2216 09209b8a 2021-10-08 stsp local orig_commit=`git_show_head $testroot/repo`
2217 09209b8a 2021-10-08 stsp
2218 09209b8a 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2219 09209b8a 2021-10-08 stsp
2220 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/alpha" <<EOF
2221 b4e0802f 2021-10-14 naddy 1i
2222 09209b8a 2021-10-08 stsp first line
2223 09209b8a 2021-10-08 stsp .
2224 09209b8a 2021-10-08 stsp wq
2225 09209b8a 2021-10-08 stsp EOF
2226 09209b8a 2021-10-08 stsp
2227 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content.expected
2228 a347e6bb 2020-12-13 stsp
2229 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2230 09209b8a 2021-10-08 stsp alpha > /dev/null)
2231 49c543a6 2022-03-31 naddy ret=$?
2232 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2233 09209b8a 2021-10-08 stsp echo "got commit failed unexpectedly" >&2
2234 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2235 09209b8a 2021-10-08 stsp return 1
2236 09209b8a 2021-10-08 stsp fi
2237 09209b8a 2021-10-08 stsp
2238 09209b8a 2021-10-08 stsp local top_commit=`git_show_head $testroot/repo`
2239 09209b8a 2021-10-08 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2240 09209b8a 2021-10-08 stsp
2241 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2242 49c543a6 2022-03-31 naddy ret=$?
2243 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2244 09209b8a 2021-10-08 stsp echo "got update failed unexpectedly" >&2
2245 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2246 09209b8a 2021-10-08 stsp return 1
2247 09209b8a 2021-10-08 stsp fi
2248 09209b8a 2021-10-08 stsp
2249 09209b8a 2021-10-08 stsp (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2250 09209b8a 2021-10-08 stsp > /dev/null)
2251 49c543a6 2022-03-31 naddy ret=$?
2252 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2253 09209b8a 2021-10-08 stsp echo "got histedit failed unexpectedly" >&2
2254 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2255 09209b8a 2021-10-08 stsp return 1
2256 09209b8a 2021-10-08 stsp fi
2257 09209b8a 2021-10-08 stsp
2258 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content
2259 09209b8a 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
2260 49c543a6 2022-03-31 naddy ret=$?
2261 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2262 09209b8a 2021-10-08 stsp diff -u $testroot/content.expected $testroot/content
2263 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2264 f1e5aff4 2022-07-12 op return 1
2265 f1e5aff4 2022-07-12 op fi
2266 f1e5aff4 2022-07-12 op
2267 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2268 598eac43 2022-07-22 stsp }
2269 598eac43 2022-07-22 stsp
2270 598eac43 2022-07-22 stsp test_histedit_resets_committer() {
2271 598eac43 2022-07-22 stsp local testroot=`test_init histedit_resets_committer`
2272 598eac43 2022-07-22 stsp local orig_commit=`git_show_head $testroot/repo`
2273 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
2274 598eac43 2022-07-22 stsp
2275 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2276 598eac43 2022-07-22 stsp
2277 598eac43 2022-07-22 stsp echo "modified alpha" > $testroot/wt/alpha
2278 598eac43 2022-07-22 stsp
2279 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2280 598eac43 2022-07-22 stsp alpha > /dev/null)
2281 598eac43 2022-07-22 stsp ret=$?
2282 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2283 598eac43 2022-07-22 stsp echo "got commit failed unexpectedly" >&2
2284 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2285 598eac43 2022-07-22 stsp return 1
2286 598eac43 2022-07-22 stsp fi
2287 598eac43 2022-07-22 stsp
2288 598eac43 2022-07-22 stsp local top_commit=`git_show_head $testroot/repo`
2289 598eac43 2022-07-22 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2290 598eac43 2022-07-22 stsp
2291 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2292 598eac43 2022-07-22 stsp ret=$?
2293 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2294 598eac43 2022-07-22 stsp echo "got update failed unexpectedly" >&2
2295 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2296 598eac43 2022-07-22 stsp return 1
2297 598eac43 2022-07-22 stsp fi
2298 598eac43 2022-07-22 stsp
2299 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2300 598eac43 2022-07-22 stsp got histedit -F "$testroot/histedit-script" > /dev/null)
2301 598eac43 2022-07-22 stsp ret=$?
2302 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2303 598eac43 2022-07-22 stsp echo "got histedit failed unexpectedly" >&2
2304 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2305 598eac43 2022-07-22 stsp return 1
2306 598eac43 2022-07-22 stsp fi
2307 598eac43 2022-07-22 stsp local edited_commit=`git_show_head $testroot/repo`
2308 598eac43 2022-07-22 stsp
2309 598eac43 2022-07-22 stsp # Original commit only had one author
2310 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $top_commit | \
2311 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2312 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2313 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2314 598eac43 2022-07-22 stsp ret=$?
2315 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2316 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2317 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2318 598eac43 2022-07-22 stsp return 1
2319 598eac43 2022-07-22 stsp fi
2320 598eac43 2022-07-22 stsp
2321 598eac43 2022-07-22 stsp # Edited commit should have new committer name added
2322 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $edited_commit | \
2323 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2324 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2325 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
2326 598eac43 2022-07-22 stsp
2327 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2328 598eac43 2022-07-22 stsp ret=$?
2329 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2330 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2331 598eac43 2022-07-22 stsp fi
2332 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2333 f1e5aff4 2022-07-12 op }
2334 b2b3fce1 2022-10-29 op
2335 b2b3fce1 2022-10-29 op test_histedit_umask() {
2336 b2b3fce1 2022-10-29 op local testroot=`test_init histedit_umask`
2337 b2b3fce1 2022-10-29 op local orig_commit=`git_show_head "$testroot/repo"`
2338 b2b3fce1 2022-10-29 op
2339 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2340 b2b3fce1 2022-10-29 op
2341 b2b3fce1 2022-10-29 op echo "modified alpha" > $testroot/wt/alpha
2342 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2343 b2b3fce1 2022-10-29 op local commit1=`git_show_head "$testroot/repo"`
2344 b2b3fce1 2022-10-29 op
2345 b2b3fce1 2022-10-29 op echo "modified again" > $testroot/wt/alpha
2346 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2347 b2b3fce1 2022-10-29 op local commit2=`git_show_head "$testroot/repo"`
2348 b2b3fce1 2022-10-29 op
2349 b2b3fce1 2022-10-29 op echo "modified again!" > $testroot/wt/alpha
2350 b2b3fce1 2022-10-29 op echo "modify beta too!" > $testroot/wt/beta
2351 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2352 b2b3fce1 2022-10-29 op local commit3=`git_show_head "$testroot/repo"`
2353 f1e5aff4 2022-07-12 op
2354 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2355 b2b3fce1 2022-10-29 op ret=$?
2356 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2357 b2b3fce1 2022-10-29 op echo "update to $orig_commit failed!" >&2
2358 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2359 b2b3fce1 2022-10-29 op return 1
2360 b2b3fce1 2022-10-29 op fi
2361 b2b3fce1 2022-10-29 op
2362 14eb0fef 2023-10-26 stsp cat > $testroot/editor.sh <<EOF
2363 14eb0fef 2023-10-26 stsp #!/bin/sh
2364 14eb0fef 2023-10-26 stsp ed -s "\$1" <<-EOF
2365 14eb0fef 2023-10-26 stsp ,s/.*/folding changes/
2366 14eb0fef 2023-10-26 stsp w
2367 14eb0fef 2023-10-26 stsp EOF
2368 14eb0fef 2023-10-26 stsp EOF
2369 14eb0fef 2023-10-26 stsp chmod +x $testroot/editor.sh
2370 14eb0fef 2023-10-26 stsp
2371 b2b3fce1 2022-10-29 op echo fold $commit1 >$testroot/histedit-script
2372 b2b3fce1 2022-10-29 op echo fold $commit2 >>$testroot/histedit-script
2373 b2b3fce1 2022-10-29 op echo pick $commit3 >>$testroot/histedit-script
2374 b2b3fce1 2022-10-29 op
2375 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
2376 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && \
2377 14eb0fef 2023-10-26 stsp env EDITOR="$testroot/editor.sh" VISUAL="$testroot/editor.sh" \
2378 b2b3fce1 2022-10-29 op got histedit -F "$testroot/histedit-script") >/dev/null
2379 b2b3fce1 2022-10-29 op ret=$?
2380 b2b3fce1 2022-10-29 op
2381 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2382 b2b3fce1 2022-10-29 op echo "histedit operation failed" >&2
2383 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
2384 b2b3fce1 2022-10-29 op return 1
2385 b2b3fce1 2022-10-29 op fi
2386 b2b3fce1 2022-10-29 op
2387 b2b3fce1 2022-10-29 op for f in alpha beta; do
2388 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2389 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
2390 b2b3fce1 2022-10-29 op echo "$f is not 0600 after histedi" >&2
2391 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
2392 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2393 b2b3fce1 2022-10-29 op return 1
2394 b2b3fce1 2022-10-29 op fi
2395 b2b3fce1 2022-10-29 op done
2396 b2b3fce1 2022-10-29 op
2397 b2b3fce1 2022-10-29 op test_done "$testroot" 0
2398 b2b3fce1 2022-10-29 op }
2399 c48f94a4 2023-01-29 stsp
2400 c48f94a4 2023-01-29 stsp test_histedit_mesg_filemode_change() {
2401 c48f94a4 2023-01-29 stsp local testroot=`test_init histedit_mode_change`
2402 c48f94a4 2023-01-29 stsp
2403 c48f94a4 2023-01-29 stsp local orig_commit=`git_show_head $testroot/repo`
2404 c48f94a4 2023-01-29 stsp local orig_author_time=`git_show_author_time $testroot/repo`
2405 c48f94a4 2023-01-29 stsp
2406 c48f94a4 2023-01-29 stsp chmod +x $testroot/repo/alpha
2407 c48f94a4 2023-01-29 stsp git_commit $testroot/repo -m "set x bit on alpha"
2408 c48f94a4 2023-01-29 stsp local old_commit1=`git_show_head $testroot/repo`
2409 c48f94a4 2023-01-29 stsp local old_author_time1=`git_show_author_time $testroot/repo`
2410 c48f94a4 2023-01-29 stsp
2411 c48f94a4 2023-01-29 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2412 c48f94a4 2023-01-29 stsp ret=$?
2413 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2414 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2415 c48f94a4 2023-01-29 stsp return 1
2416 c48f94a4 2023-01-29 stsp fi
2417 c48f94a4 2023-01-29 stsp
2418 c48f94a4 2023-01-29 stsp if [ -x $testroot/wt/alpha ]; then
2419 c48f94a4 2023-01-29 stsp echo "file alpha has unexpected executable bit" >&2
2420 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2421 c48f94a4 2023-01-29 stsp return 1
2422 c48f94a4 2023-01-29 stsp fi
2423 c48f94a4 2023-01-29 stsp
2424 c48f94a4 2023-01-29 stsp cat > $testroot/editor.sh <<EOF
2425 c48f94a4 2023-01-29 stsp #!/bin/sh
2426 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2427 885e96df 2023-03-06 naddy ,s/ x bit / executable bit /
2428 885e96df 2023-03-06 naddy w
2429 885e96df 2023-03-06 naddy EOF
2430 c48f94a4 2023-01-29 stsp EOF
2431 b2b3fce1 2022-10-29 op
2432 c48f94a4 2023-01-29 stsp chmod +x $testroot/editor.sh
2433 c48f94a4 2023-01-29 stsp
2434 71a61c8c 2023-01-29 stsp (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2435 c48f94a4 2023-01-29 stsp got histedit -m > $testroot/stdout)
2436 c48f94a4 2023-01-29 stsp
2437 c48f94a4 2023-01-29 stsp local new_commit1=`git_show_head $testroot/repo`
2438 c48f94a4 2023-01-29 stsp local new_author_time1=`git_show_author_time $testroot/repo`
2439 c48f94a4 2023-01-29 stsp
2440 c48f94a4 2023-01-29 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2441 c48f94a4 2023-01-29 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2442 c48f94a4 2023-01-29 stsp
2443 c48f94a4 2023-01-29 stsp echo "G alpha" > $testroot/stdout.expected
2444 c48f94a4 2023-01-29 stsp echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2445 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2446 c48f94a4 2023-01-29 stsp echo "Switching work tree to refs/heads/master" \
2447 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2448 c48f94a4 2023-01-29 stsp
2449 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2450 c48f94a4 2023-01-29 stsp ret=$?
2451 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2452 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2453 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2454 c48f94a4 2023-01-29 stsp return 1
2455 c48f94a4 2023-01-29 stsp fi
2456 c48f94a4 2023-01-29 stsp
2457 c48f94a4 2023-01-29 stsp echo "alpha" > $testroot/content.expected
2458 9f31ca1f 2023-01-29 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
2459 c48f94a4 2023-01-29 stsp ret=$?
2460 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2461 9f31ca1f 2023-01-29 stsp diff -u $testroot/content.expected $testroot/wt/alpha
2462 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2463 c48f94a4 2023-01-29 stsp return 1
2464 c48f94a4 2023-01-29 stsp fi
2465 c48f94a4 2023-01-29 stsp
2466 c48f94a4 2023-01-29 stsp if [ ! -x $testroot/wt/alpha ]; then
2467 c48f94a4 2023-01-29 stsp echo "file alpha lost its executable bit" >&2
2468 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2469 c48f94a4 2023-01-29 stsp return 1
2470 c48f94a4 2023-01-29 stsp fi
2471 c48f94a4 2023-01-29 stsp
2472 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got status > $testroot/stdout)
2473 c48f94a4 2023-01-29 stsp
2474 c48f94a4 2023-01-29 stsp echo -n > $testroot/stdout.expected
2475 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2476 c48f94a4 2023-01-29 stsp ret=$?
2477 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2478 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2479 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2480 c48f94a4 2023-01-29 stsp return 1
2481 c48f94a4 2023-01-29 stsp fi
2482 c48f94a4 2023-01-29 stsp
2483 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2484 c48f94a4 2023-01-29 stsp > $testroot/stdout)
2485 c48f94a4 2023-01-29 stsp
2486 c48f94a4 2023-01-29 stsp echo ' set executable bit on alpha' > $testroot/stdout.expected
2487 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2488 c48f94a4 2023-01-29 stsp ret=$?
2489 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2490 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2491 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2492 c48f94a4 2023-01-29 stsp return 1
2493 c48f94a4 2023-01-29 stsp fi
2494 c48f94a4 2023-01-29 stsp
2495 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2496 c48f94a4 2023-01-29 stsp }
2497 f1c9fe20 2023-01-30 mark
2498 f1c9fe20 2023-01-30 mark test_histedit_drop_only() {
2499 f1c9fe20 2023-01-30 mark local testroot=`test_init histedit_drop_only`
2500 f1c9fe20 2023-01-30 mark
2501 f1c9fe20 2023-01-30 mark local orig_commit=`git_show_head $testroot/repo`
2502 f1c9fe20 2023-01-30 mark local drop="-> drop commit:"
2503 f1c9fe20 2023-01-30 mark local dropmsg="commit changes to drop"
2504 f1c9fe20 2023-01-30 mark
2505 f1c9fe20 2023-01-30 mark echo "modified alpha on master" > $testroot/repo/alpha
2506 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
2507 f1c9fe20 2023-01-30 mark echo "new file on master" > $testroot/repo/epsilon/new
2508 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
2509 f1c9fe20 2023-01-30 mark
2510 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 1"
2511 f1c9fe20 2023-01-30 mark local drop_commit1=`git_show_head $testroot/repo`
2512 f1c9fe20 2023-01-30 mark
2513 f1c9fe20 2023-01-30 mark echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2514 f1c9fe20 2023-01-30 mark
2515 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 2"
2516 f1c9fe20 2023-01-30 mark local drop_commit2=`git_show_head $testroot/repo`
2517 f1c9fe20 2023-01-30 mark
2518 f1c9fe20 2023-01-30 mark echo "modified delta on master" > $testroot/repo/gamma/delta
2519 f1c9fe20 2023-01-30 mark
2520 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 3"
2521 f1c9fe20 2023-01-30 mark local drop_commit3=`git_show_head $testroot/repo`
2522 f1c9fe20 2023-01-30 mark
2523 f1c9fe20 2023-01-30 mark got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2524 f1c9fe20 2023-01-30 mark ret=$?
2525 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2526 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2527 f1c9fe20 2023-01-30 mark return 1
2528 f1c9fe20 2023-01-30 mark fi
2529 c48f94a4 2023-01-29 stsp
2530 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got histedit -d > $testroot/stdout)
2531 f1c9fe20 2023-01-30 mark local new_commit1=`git_show_head $testroot/repo`
2532 f1c9fe20 2023-01-30 mark
2533 f1c9fe20 2023-01-30 mark local short_commit1=`trim_obj_id 28 $drop_commit1`
2534 f1c9fe20 2023-01-30 mark local short_commit2=`trim_obj_id 28 $drop_commit2`
2535 f1c9fe20 2023-01-30 mark local short_commit3=`trim_obj_id 28 $drop_commit3`
2536 f1c9fe20 2023-01-30 mark
2537 f1c9fe20 2023-01-30 mark echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2538 f1c9fe20 2023-01-30 mark echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2539 f1c9fe20 2023-01-30 mark echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2540 f1c9fe20 2023-01-30 mark echo "Switching work tree to refs/heads/master" \
2541 f1c9fe20 2023-01-30 mark >> $testroot/stdout.expected
2542 f1c9fe20 2023-01-30 mark
2543 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2544 f1c9fe20 2023-01-30 mark ret=$?
2545 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2546 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2547 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2548 f1c9fe20 2023-01-30 mark return 1
2549 f1c9fe20 2023-01-30 mark fi
2550 f1c9fe20 2023-01-30 mark
2551 f1c9fe20 2023-01-30 mark echo "alpha" > $testroot/content.expected
2552 f1c9fe20 2023-01-30 mark cat $testroot/wt/alpha > $testroot/content
2553 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2554 f1c9fe20 2023-01-30 mark ret=$?
2555 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2556 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2557 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2558 f1c9fe20 2023-01-30 mark return 1
2559 f1c9fe20 2023-01-30 mark fi
2560 f1c9fe20 2023-01-30 mark
2561 f1c9fe20 2023-01-30 mark echo "zeta" > $testroot/content.expected
2562 f1c9fe20 2023-01-30 mark cat $testroot/wt/epsilon/zeta > $testroot/content
2563 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2564 f1c9fe20 2023-01-30 mark ret=$?
2565 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2566 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2567 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2568 f1c9fe20 2023-01-30 mark return 1
2569 f1c9fe20 2023-01-30 mark fi
2570 f1c9fe20 2023-01-30 mark
2571 f1c9fe20 2023-01-30 mark echo "delta" > $testroot/content.expected
2572 f1c9fe20 2023-01-30 mark cat $testroot/wt/gamma/delta > $testroot/content
2573 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2574 f1c9fe20 2023-01-30 mark ret=$?
2575 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2576 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2577 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2578 f1c9fe20 2023-01-30 mark return 1
2579 f1c9fe20 2023-01-30 mark fi
2580 f1c9fe20 2023-01-30 mark
2581 f1c9fe20 2023-01-30 mark if [ ! -e $testroot/wt/beta ]; then
2582 f1c9fe20 2023-01-30 mark echo "removed file beta should be restored" >&2
2583 f1c9fe20 2023-01-30 mark test_done "$testroot" "1"
2584 f1c9fe20 2023-01-30 mark return 1
2585 f1c9fe20 2023-01-30 mark fi
2586 f1c9fe20 2023-01-30 mark
2587 f1c9fe20 2023-01-30 mark if [ -e $testroot/wt/new ]; then
2588 f1c9fe20 2023-01-30 mark echo "new file should no longer exist" >&2
2589 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2590 f1c9fe20 2023-01-30 mark return 1
2591 f1c9fe20 2023-01-30 mark fi
2592 f1c9fe20 2023-01-30 mark
2593 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2594 f1c9fe20 2023-01-30 mark
2595 f1c9fe20 2023-01-30 mark echo -n > $testroot/stdout.expected
2596 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2597 f1c9fe20 2023-01-30 mark ret=$?
2598 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2599 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2600 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2601 f1c9fe20 2023-01-30 mark return 1
2602 f1c9fe20 2023-01-30 mark fi
2603 f1c9fe20 2023-01-30 mark
2604 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2605 f1c9fe20 2023-01-30 mark echo "commit $orig_commit (master)" > $testroot/stdout.expected
2606 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2607 f1c9fe20 2023-01-30 mark ret=$?
2608 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2609 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2610 f1c9fe20 2023-01-30 mark fi
2611 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2612 f1c9fe20 2023-01-30 mark }
2613 f1c9fe20 2023-01-30 mark
2614 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2615 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
2616 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
2617 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
2618 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
2619 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
2620 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
2621 14eb0fef 2023-10-26 stsp run_test test_histedit_missing_commit_pick
2622 14eb0fef 2023-10-26 stsp run_test test_histedit_missing_commit_mesg
2623 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
2624 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
2625 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
2626 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
2627 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
2628 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
2629 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
2630 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
2631 c2ba7aa6 2023-07-26 stsp run_test test_histedit_fold_edit_delete
2632 15aed053 2023-03-07 naddy run_test test_histedit_fold_delete_add
2633 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
2634 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg
2635 b93c7142 2021-10-01 stsp run_test test_histedit_edit_only
2636 09209b8a 2021-10-08 stsp run_test test_histedit_prepend_line
2637 598eac43 2022-07-22 stsp run_test test_histedit_resets_committer
2638 b2b3fce1 2022-10-29 op run_test test_histedit_umask
2639 c48f94a4 2023-01-29 stsp run_test test_histedit_mesg_filemode_change
2640 f1c9fe20 2023-01-30 mark run_test test_histedit_drop_only