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