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 49c543a6 2022-03-31 naddy ret=$?
43 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
44 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
45 0ebf8283 2019-07-24 stsp return 1
46 0ebf8283 2019-07-24 stsp fi
47 0ebf8283 2019-07-24 stsp
48 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
49 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
50 0ebf8283 2019-07-24 stsp
51 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
52 0ebf8283 2019-07-24 stsp > $testroot/stdout)
53 0ebf8283 2019-07-24 stsp
54 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
55 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
56 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
57 0ebf8283 2019-07-24 stsp
58 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
59 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
60 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
61 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 0ebf8283 2019-07-24 stsp
63 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
66 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
67 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
69 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
70 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
71 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
72 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
73 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
74 0ebf8283 2019-07-24 stsp
75 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 49c543a6 2022-03-31 naddy ret=$?
77 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
78 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
80 0ebf8283 2019-07-24 stsp return 1
81 0ebf8283 2019-07-24 stsp fi
82 0ebf8283 2019-07-24 stsp
83 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
84 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
85 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
86 49c543a6 2022-03-31 naddy ret=$?
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
89 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
90 0ebf8283 2019-07-24 stsp return 1
91 0ebf8283 2019-07-24 stsp fi
92 0ebf8283 2019-07-24 stsp
93 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
94 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
95 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
96 0ebf8283 2019-07-24 stsp return 1
97 0ebf8283 2019-07-24 stsp fi
98 0ebf8283 2019-07-24 stsp
99 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
100 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
101 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
102 49c543a6 2022-03-31 naddy ret=$?
103 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
104 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
105 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
106 0ebf8283 2019-07-24 stsp return 1
107 0ebf8283 2019-07-24 stsp fi
108 0ebf8283 2019-07-24 stsp
109 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
110 0ebf8283 2019-07-24 stsp
111 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
112 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
113 49c543a6 2022-03-31 naddy ret=$?
114 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
115 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
116 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
117 0ebf8283 2019-07-24 stsp return 1
118 0ebf8283 2019-07-24 stsp fi
119 0ebf8283 2019-07-24 stsp
120 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
121 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
122 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
123 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
124 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
125 49c543a6 2022-03-31 naddy ret=$?
126 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
127 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
128 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
129 86ac67ee 2019-07-25 stsp return 1
130 0ebf8283 2019-07-24 stsp fi
131 86ac67ee 2019-07-25 stsp
132 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
133 86ac67ee 2019-07-25 stsp > $testroot/diff
134 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
135 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
136 885e96df 2023-03-06 naddy w
137 885e96df 2023-03-06 naddy EOF
138 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
139 49c543a6 2022-03-31 naddy ret=$?
140 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
141 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
142 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
143 a615e0e7 2020-12-16 stsp return 1
144 86ac67ee 2019-07-25 stsp fi
145 a615e0e7 2020-12-16 stsp
146 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
147 a615e0e7 2020-12-16 stsp
148 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
149 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
150 49c543a6 2022-03-31 naddy ret=$?
151 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
152 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 a9662115 2021-08-29 naddy return 1
155 e600f124 2021-03-21 stsp fi
156 e600f124 2021-03-21 stsp
157 e600f124 2021-03-21 stsp # We should have a backup of old commits
158 e600f124 2021-03-21 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
159 ad324bf5 2021-09-21 stsp d_orig1=`date -u -r $old_author_time1 +"%G-%m-%d"`
160 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
161 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
162 3a6b8760 2021-08-31 naddy d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
163 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
164 e600f124 2021-03-21 stsp -----------------------------------------------
165 e600f124 2021-03-21 stsp commit $old_commit2 (formerly master)
166 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
167 e600f124 2021-03-21 stsp date: $d_orig2
168 e600f124 2021-03-21 stsp
169 e600f124 2021-03-21 stsp committing to zeta on master
170 e600f124 2021-03-21 stsp
171 e600f124 2021-03-21 stsp has become commit $new_commit2 (master)
172 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing to zeta on master
173 ad324bf5 2021-09-21 stsp EOF
174 ad324bf5 2021-09-21 stsp
175 ad324bf5 2021-09-21 stsp local is_forked=true d_fork fork_commit fork_commit_msg
176 ad324bf5 2021-09-21 stsp
177 ad324bf5 2021-09-21 stsp if [ "$old_commit1" = "$new_commit1" ]; then
178 ad324bf5 2021-09-21 stsp if [ "$old_commit2" = "$new_commit2" ]; then
179 ad324bf5 2021-09-21 stsp is_forked=false
180 ad324bf5 2021-09-21 stsp else
181 ad324bf5 2021-09-21 stsp d_fork=$d_orig1
182 ad324bf5 2021-09-21 stsp fork_commit=$new_commit1
183 ad324bf5 2021-09-21 stsp fork_commit_msg="committing changes"
184 ad324bf5 2021-09-21 stsp fi
185 ad324bf5 2021-09-21 stsp else
186 ad324bf5 2021-09-21 stsp d_fork=$d_orig
187 ad324bf5 2021-09-21 stsp fork_commit=$orig_commit
188 ad324bf5 2021-09-21 stsp fork_commit_msg="adding the test tree"
189 ad324bf5 2021-09-21 stsp fi
190 ad324bf5 2021-09-21 stsp
191 ad324bf5 2021-09-21 stsp $is_forked && cat >> $testroot/stdout.expected <<EOF
192 ad324bf5 2021-09-21 stsp history forked at $fork_commit
193 ad324bf5 2021-09-21 stsp $d_fork $GOT_AUTHOR_11 $fork_commit_msg
194 e600f124 2021-03-21 stsp EOF
195 ad324bf5 2021-09-21 stsp
196 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
197 49c543a6 2022-03-31 naddy ret=$?
198 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
199 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
200 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
201 643b85bc 2021-07-16 stsp return 1
202 a615e0e7 2020-12-16 stsp fi
203 643b85bc 2021-07-16 stsp
204 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -X master \
205 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
206 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/histedit/master/$new_commit2: " \
207 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
208 643b85bc 2021-07-16 stsp echo "$old_commit2" >> $testroot/stdout.expected
209 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
210 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
211 49c543a6 2022-03-31 naddy ret=$?
212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
213 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
215 643b85bc 2021-07-16 stsp return 1
216 643b85bc 2021-07-16 stsp fi
217 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
218 49c543a6 2022-03-31 naddy ret=$?
219 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
220 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
222 643b85bc 2021-07-16 stsp return 1
223 643b85bc 2021-07-16 stsp fi
224 643b85bc 2021-07-16 stsp
225 643b85bc 2021-07-16 stsp (cd $testroot/repo && got histedit -l > $testroot/stdout)
226 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
227 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
228 49c543a6 2022-03-31 naddy ret=$?
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
231 643b85bc 2021-07-16 stsp fi
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
233 0ebf8283 2019-07-24 stsp }
234 0ebf8283 2019-07-24 stsp
235 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
236 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
237 0ebf8283 2019-07-24 stsp
238 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
239 0ebf8283 2019-07-24 stsp
240 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
241 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 49c543a6 2022-03-31 naddy ret=$?
256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
257 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
258 0ebf8283 2019-07-24 stsp return 1
259 0ebf8283 2019-07-24 stsp fi
260 0ebf8283 2019-07-24 stsp
261 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
262 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
263 0ebf8283 2019-07-24 stsp
264 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
265 0ebf8283 2019-07-24 stsp > $testroot/stdout)
266 0ebf8283 2019-07-24 stsp
267 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
268 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
269 0ebf8283 2019-07-24 stsp
270 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
271 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
272 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
273 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
274 0ebf8283 2019-07-24 stsp
275 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
276 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
277 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
278 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
279 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
280 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
281 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
282 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
283 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
284 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
285 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
286 0ebf8283 2019-07-24 stsp
287 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
288 49c543a6 2022-03-31 naddy ret=$?
289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
290 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
292 0ebf8283 2019-07-24 stsp return 1
293 0ebf8283 2019-07-24 stsp fi
294 0ebf8283 2019-07-24 stsp
295 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
296 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
297 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
298 49c543a6 2022-03-31 naddy ret=$?
299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
300 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
301 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
302 0ebf8283 2019-07-24 stsp return 1
303 0ebf8283 2019-07-24 stsp fi
304 0ebf8283 2019-07-24 stsp
305 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
306 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
307 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
308 0ebf8283 2019-07-24 stsp return 1
309 0ebf8283 2019-07-24 stsp fi
310 0ebf8283 2019-07-24 stsp
311 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
312 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
313 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
314 49c543a6 2022-03-31 naddy ret=$?
315 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
316 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
317 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
318 0ebf8283 2019-07-24 stsp return 1
319 0ebf8283 2019-07-24 stsp fi
320 0ebf8283 2019-07-24 stsp
321 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
322 0ebf8283 2019-07-24 stsp
323 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
324 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 49c543a6 2022-03-31 naddy ret=$?
326 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
327 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
329 0ebf8283 2019-07-24 stsp return 1
330 0ebf8283 2019-07-24 stsp fi
331 0ebf8283 2019-07-24 stsp
332 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
333 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
334 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
335 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
336 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
337 49c543a6 2022-03-31 naddy ret=$?
338 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
339 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
341 86ac67ee 2019-07-25 stsp return 1
342 86ac67ee 2019-07-25 stsp fi
343 86ac67ee 2019-07-25 stsp
344 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
345 86ac67ee 2019-07-25 stsp > $testroot/diff
346 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
347 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit1/
348 885e96df 2023-03-06 naddy w
349 885e96df 2023-03-06 naddy EOF
350 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
351 49c543a6 2022-03-31 naddy ret=$?
352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
353 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
354 0ebf8283 2019-07-24 stsp fi
355 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
356 0ebf8283 2019-07-24 stsp }
357 0ebf8283 2019-07-24 stsp
358 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
359 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
360 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
361 0ebf8283 2019-07-24 stsp
362 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
363 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 49c543a6 2022-03-31 naddy ret=$?
378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
379 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
380 0ebf8283 2019-07-24 stsp return 1
381 0ebf8283 2019-07-24 stsp fi
382 0ebf8283 2019-07-24 stsp
383 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
384 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
385 0ebf8283 2019-07-24 stsp
386 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
387 0ebf8283 2019-07-24 stsp > $testroot/stdout)
388 0ebf8283 2019-07-24 stsp
389 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
390 0ebf8283 2019-07-24 stsp
391 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
392 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
393 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
394 0ebf8283 2019-07-24 stsp
395 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
396 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
397 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
398 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
399 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
400 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
401 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
402 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
403 0ebf8283 2019-07-24 stsp
404 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
405 49c543a6 2022-03-31 naddy ret=$?
406 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
407 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
408 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
409 0ebf8283 2019-07-24 stsp return 1
410 0ebf8283 2019-07-24 stsp fi
411 0ebf8283 2019-07-24 stsp
412 0ebf8283 2019-07-24 stsp for f in alpha beta; do
413 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
414 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
415 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
416 49c543a6 2022-03-31 naddy ret=$?
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
419 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
420 0ebf8283 2019-07-24 stsp return 1
421 0ebf8283 2019-07-24 stsp fi
422 0ebf8283 2019-07-24 stsp done
423 0ebf8283 2019-07-24 stsp
424 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
425 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
426 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
427 0ebf8283 2019-07-24 stsp return 1
428 0ebf8283 2019-07-24 stsp fi
429 0ebf8283 2019-07-24 stsp
430 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
431 0ebf8283 2019-07-24 stsp
432 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
433 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
434 49c543a6 2022-03-31 naddy ret=$?
435 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
436 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
438 0ebf8283 2019-07-24 stsp return 1
439 0ebf8283 2019-07-24 stsp fi
440 0ebf8283 2019-07-24 stsp
441 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
442 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
443 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
444 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 49c543a6 2022-03-31 naddy ret=$?
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
449 86ac67ee 2019-07-25 stsp return 1
450 86ac67ee 2019-07-25 stsp fi
451 86ac67ee 2019-07-25 stsp
452 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
453 86ac67ee 2019-07-25 stsp > $testroot/diff
454 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
455 885e96df 2023-03-06 naddy ,s/$old_commit1/$orig_commit/
456 885e96df 2023-03-06 naddy ,s/$old_commit2/$new_commit2/
457 885e96df 2023-03-06 naddy w
458 885e96df 2023-03-06 naddy EOF
459 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
460 49c543a6 2022-03-31 naddy ret=$?
461 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
462 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
463 0ebf8283 2019-07-24 stsp fi
464 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
465 0ebf8283 2019-07-24 stsp }
466 0ebf8283 2019-07-24 stsp
467 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
468 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
469 0ebf8283 2019-07-24 stsp
470 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
471 0ebf8283 2019-07-24 stsp
472 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
473 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 49c543a6 2022-03-31 naddy ret=$?
489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
490 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
491 0ebf8283 2019-07-24 stsp return 1
492 0ebf8283 2019-07-24 stsp fi
493 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 49c543a6 2022-03-31 naddy ret=$?
528 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
538 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
554 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
565 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
576 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
600 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
622 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
635 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
646 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
672 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
682 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
698 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
709 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
721 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
745 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
757 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
768 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
792 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
804 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
815 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
839 49c543a6 2022-03-31 naddy 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 41f061b2 2021-10-05 stsp
844 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
845 41f061b2 2021-10-05 stsp 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 49c543a6 2022-03-31 naddy ret=$?
864 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
887 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
898 49c543a6 2022-03-31 naddy 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 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
906 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
907 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
908 49c543a6 2022-03-31 naddy ret=$?
909 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
910 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
911 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
912 0ebf8283 2019-07-24 stsp return 1
913 0ebf8283 2019-07-24 stsp fi
914 0ebf8283 2019-07-24 stsp
915 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
916 0ebf8283 2019-07-24 stsp
917 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
918 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
919 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
920 49c543a6 2022-03-31 naddy ret=$?
921 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
922 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
923 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
924 0ebf8283 2019-07-24 stsp return 1
925 0ebf8283 2019-07-24 stsp fi
926 0ebf8283 2019-07-24 stsp
927 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
928 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
929 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
930 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
931 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
932 49c543a6 2022-03-31 naddy ret=$?
933 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
934 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
935 0160a755 2019-07-25 stsp fi
936 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
937 0160a755 2019-07-25 stsp }
938 0160a755 2019-07-25 stsp
939 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
940 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
941 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
942 0160a755 2019-07-25 stsp
943 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
944 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
945 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
946 0160a755 2019-07-25 stsp
947 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
948 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
949 49c543a6 2022-03-31 naddy ret=$?
950 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
951 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
952 0160a755 2019-07-25 stsp return 1
953 0160a755 2019-07-25 stsp fi
954 0160a755 2019-07-25 stsp
955 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
956 0160a755 2019-07-25 stsp
957 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
958 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
959 0160a755 2019-07-25 stsp
960 49c543a6 2022-03-31 naddy ret=$?
961 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
962 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
963 0160a755 2019-07-25 stsp test_done "$testroot" "1"
964 0160a755 2019-07-25 stsp return 1
965 0160a755 2019-07-25 stsp fi
966 0160a755 2019-07-25 stsp
967 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
968 0160a755 2019-07-25 stsp > $testroot/stderr.expected
969 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
970 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
971 0160a755 2019-07-25 stsp
972 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
973 49c543a6 2022-03-31 naddy ret=$?
974 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
975 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
976 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
977 0160a755 2019-07-25 stsp return 1
978 0160a755 2019-07-25 stsp fi
979 0160a755 2019-07-25 stsp
980 0160a755 2019-07-25 stsp rm -rf $testroot/wt
981 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
982 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
983 49c543a6 2022-03-31 naddy ret=$?
984 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
985 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
986 0160a755 2019-07-25 stsp return 1
987 0160a755 2019-07-25 stsp fi
988 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
989 0160a755 2019-07-25 stsp > $testroot/stdout)
990 0160a755 2019-07-25 stsp
991 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
992 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
993 0160a755 2019-07-25 stsp
994 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
995 0160a755 2019-07-25 stsp > $testroot/stdout.expected
996 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
997 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
998 0160a755 2019-07-25 stsp
999 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1000 49c543a6 2022-03-31 naddy ret=$?
1001 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1002 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1003 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1004 0160a755 2019-07-25 stsp return 1
1005 0ebf8283 2019-07-24 stsp fi
1006 0160a755 2019-07-25 stsp
1007 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
1008 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1009 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1010 49c543a6 2022-03-31 naddy ret=$?
1011 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1012 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1013 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1014 0160a755 2019-07-25 stsp return 1
1015 0160a755 2019-07-25 stsp fi
1016 0160a755 2019-07-25 stsp
1017 0160a755 2019-07-25 stsp
1018 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1019 0160a755 2019-07-25 stsp
1020 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
1021 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1022 49c543a6 2022-03-31 naddy ret=$?
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1025 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1026 0160a755 2019-07-25 stsp return 1
1027 0160a755 2019-07-25 stsp fi
1028 0160a755 2019-07-25 stsp
1029 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1030 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
1031 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1032 49c543a6 2022-03-31 naddy ret=$?
1033 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1034 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1035 b2c50a0a 2019-07-25 stsp fi
1036 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1037 b2c50a0a 2019-07-25 stsp }
1038 b2c50a0a 2019-07-25 stsp
1039 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1040 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1041 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1042 b2c50a0a 2019-07-25 stsp
1043 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1044 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1045 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1046 b2c50a0a 2019-07-25 stsp
1047 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1048 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1049 b2c50a0a 2019-07-25 stsp
1050 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1051 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1052 49c543a6 2022-03-31 naddy ret=$?
1053 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1054 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1055 b2c50a0a 2019-07-25 stsp return 1
1056 b2c50a0a 2019-07-25 stsp fi
1057 b2c50a0a 2019-07-25 stsp
1058 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1059 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
1060 b2c50a0a 2019-07-25 stsp
1061 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1062 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1063 b2c50a0a 2019-07-25 stsp
1064 49c543a6 2022-03-31 naddy ret=$?
1065 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1066 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1067 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1068 b2c50a0a 2019-07-25 stsp return 1
1069 b2c50a0a 2019-07-25 stsp fi
1070 b2c50a0a 2019-07-25 stsp
1071 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1072 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1073 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1074 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1075 b2c50a0a 2019-07-25 stsp
1076 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1077 49c543a6 2022-03-31 naddy ret=$?
1078 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1079 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1080 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1081 b2c50a0a 2019-07-25 stsp return 1
1082 b2c50a0a 2019-07-25 stsp fi
1083 b2c50a0a 2019-07-25 stsp
1084 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1085 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1086 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1087 49c543a6 2022-03-31 naddy ret=$?
1088 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1089 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1090 b2c50a0a 2019-07-25 stsp return 1
1091 b2c50a0a 2019-07-25 stsp fi
1092 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1093 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1094 b2c50a0a 2019-07-25 stsp
1095 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1096 b2c50a0a 2019-07-25 stsp
1097 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1098 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1099 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1100 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1101 49c543a6 2022-03-31 naddy ret=$?
1102 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1103 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1104 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1105 b2c50a0a 2019-07-25 stsp return 1
1106 0160a755 2019-07-25 stsp fi
1107 b2c50a0a 2019-07-25 stsp
1108 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1109 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1110 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1111 49c543a6 2022-03-31 naddy ret=$?
1112 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1113 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1114 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1115 b2c50a0a 2019-07-25 stsp return 1
1116 b2c50a0a 2019-07-25 stsp fi
1117 b2c50a0a 2019-07-25 stsp
1118 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1119 b2c50a0a 2019-07-25 stsp
1120 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1121 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1122 49c543a6 2022-03-31 naddy ret=$?
1123 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1124 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1125 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1126 b2c50a0a 2019-07-25 stsp return 1
1127 b2c50a0a 2019-07-25 stsp fi
1128 b2c50a0a 2019-07-25 stsp
1129 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1130 b2c50a0a 2019-07-25 stsp
1131 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1132 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1133 b2c50a0a 2019-07-25 stsp
1134 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1135 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1136 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1137 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1138 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1139 b2c50a0a 2019-07-25 stsp
1140 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1141 49c543a6 2022-03-31 naddy ret=$?
1142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1143 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1144 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1145 b2c50a0a 2019-07-25 stsp return 1
1146 b2c50a0a 2019-07-25 stsp fi
1147 b2c50a0a 2019-07-25 stsp
1148 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1149 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1150 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1151 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1152 49c543a6 2022-03-31 naddy ret=$?
1153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1154 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1155 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1156 b2c50a0a 2019-07-25 stsp return 1
1157 b2c50a0a 2019-07-25 stsp fi
1158 b2c50a0a 2019-07-25 stsp
1159 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1160 b2c50a0a 2019-07-25 stsp > $testroot/diff
1161 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
1162 885e96df 2023-03-06 naddy ,s/$old_commit1/$new_commit1/
1163 885e96df 2023-03-06 naddy w
1164 885e96df 2023-03-06 naddy EOF
1165 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1166 49c543a6 2022-03-31 naddy ret=$?
1167 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1168 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1169 b2c50a0a 2019-07-25 stsp fi
1170 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1171 0ebf8283 2019-07-24 stsp }
1172 c7d20a3f 2019-07-30 stsp
1173 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1174 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1175 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1176 c7d20a3f 2019-07-30 stsp
1177 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1178 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1181 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1182 c7d20a3f 2019-07-30 stsp return 1
1183 c7d20a3f 2019-07-30 stsp fi
1184 c7d20a3f 2019-07-30 stsp
1185 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1186 c7d20a3f 2019-07-30 stsp
1187 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1188 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1189 49c543a6 2022-03-31 naddy ret=$?
1190 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1191 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1192 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1193 c7d20a3f 2019-07-30 stsp return 1
1194 c7d20a3f 2019-07-30 stsp fi
1195 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1196 0ebf8283 2019-07-24 stsp
1197 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1198 49c543a6 2022-03-31 naddy ret=$?
1199 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1200 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1201 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1202 c7d20a3f 2019-07-30 stsp return 1
1203 c7d20a3f 2019-07-30 stsp fi
1204 c7d20a3f 2019-07-30 stsp
1205 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1206 49c543a6 2022-03-31 naddy ret=$?
1207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1208 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1209 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1210 c7d20a3f 2019-07-30 stsp return 1
1211 c7d20a3f 2019-07-30 stsp fi
1212 c7d20a3f 2019-07-30 stsp
1213 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1214 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1215 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1216 c7d20a3f 2019-07-30 stsp
1217 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1218 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1219 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1220 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1221 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1222 49c543a6 2022-03-31 naddy ret=$?
1223 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1224 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1225 0def28b1 2019-08-17 stsp fi
1226 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1227 0def28b1 2019-08-17 stsp }
1228 0def28b1 2019-08-17 stsp
1229 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1230 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1231 0def28b1 2019-08-17 stsp
1232 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1233 0def28b1 2019-08-17 stsp
1234 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1235 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1236 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1237 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1238 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1239 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1240 0def28b1 2019-08-17 stsp
1241 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1242 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1243 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1244 0def28b1 2019-08-17 stsp
1245 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1246 49c543a6 2022-03-31 naddy ret=$?
1247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1248 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1249 0def28b1 2019-08-17 stsp return 1
1250 0def28b1 2019-08-17 stsp fi
1251 0def28b1 2019-08-17 stsp
1252 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1253 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1254 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1255 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1256 0def28b1 2019-08-17 stsp
1257 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1258 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1259 0def28b1 2019-08-17 stsp
1260 49c543a6 2022-03-31 naddy ret=$?
1261 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1262 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1263 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1264 0def28b1 2019-08-17 stsp return 1
1265 c7d20a3f 2019-07-30 stsp fi
1266 0def28b1 2019-08-17 stsp
1267 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1268 0def28b1 2019-08-17 stsp
1269 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1270 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1271 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1272 0def28b1 2019-08-17 stsp
1273 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1274 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1275 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1276 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1277 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1278 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1279 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1280 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1281 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1282 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1283 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1284 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1285 0def28b1 2019-08-17 stsp
1286 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1287 49c543a6 2022-03-31 naddy ret=$?
1288 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1289 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1290 0def28b1 2019-08-17 stsp fi
1291 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1292 c7d20a3f 2019-07-30 stsp }
1293 de05890f 2020-03-05 stsp
1294 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1295 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1296 de05890f 2020-03-05 stsp
1297 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1298 de05890f 2020-03-05 stsp
1299 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1300 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1301 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1302 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1303 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1304 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1305 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1306 de05890f 2020-03-05 stsp
1307 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1308 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1309 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1310 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1311 c7d20a3f 2019-07-30 stsp
1312 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1313 49c543a6 2022-03-31 naddy ret=$?
1314 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1315 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1316 de05890f 2020-03-05 stsp return 1
1317 de05890f 2020-03-05 stsp fi
1318 de05890f 2020-03-05 stsp
1319 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1320 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1321 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1322 de05890f 2020-03-05 stsp
1323 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1324 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1325 49c543a6 2022-03-31 naddy ret=$?
1326 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1327 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1328 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1329 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1330 de05890f 2020-03-05 stsp return 1
1331 de05890f 2020-03-05 stsp fi
1332 de05890f 2020-03-05 stsp
1333 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1334 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1335 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1336 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1337 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1338 de05890f 2020-03-05 stsp
1339 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1340 49c543a6 2022-03-31 naddy ret=$?
1341 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1342 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1343 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1344 de05890f 2020-03-05 stsp return 1
1345 de05890f 2020-03-05 stsp fi
1346 de05890f 2020-03-05 stsp
1347 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1348 49c543a6 2022-03-31 naddy ret=$?
1349 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1350 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1351 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1352 de05890f 2020-03-05 stsp return 1
1353 de05890f 2020-03-05 stsp fi
1354 de05890f 2020-03-05 stsp
1355 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1356 49c543a6 2022-03-31 naddy ret=$?
1357 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1358 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1359 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1360 de05890f 2020-03-05 stsp return 1
1361 de05890f 2020-03-05 stsp fi
1362 de05890f 2020-03-05 stsp
1363 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1364 49c543a6 2022-03-31 naddy ret=$?
1365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1366 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1367 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1368 de05890f 2020-03-05 stsp return 1
1369 de05890f 2020-03-05 stsp fi
1370 de05890f 2020-03-05 stsp
1371 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1372 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1373 49c543a6 2022-03-31 naddy ret=$?
1374 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1375 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1376 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1377 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1378 de05890f 2020-03-05 stsp return 1
1379 de05890f 2020-03-05 stsp fi
1380 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1381 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1382 de05890f 2020-03-05 stsp
1383 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1384 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1385 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1386 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1387 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1388 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1389 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1390 de05890f 2020-03-05 stsp
1391 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1392 49c543a6 2022-03-31 naddy ret=$?
1393 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1394 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1395 5b87815e 2020-03-05 stsp fi
1396 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1397 5b87815e 2020-03-05 stsp
1398 5b87815e 2020-03-05 stsp }
1399 5b87815e 2020-03-05 stsp
1400 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1401 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1402 5b87815e 2020-03-05 stsp
1403 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1404 5b87815e 2020-03-05 stsp
1405 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1406 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1407 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1408 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1409 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1410 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1411 5b87815e 2020-03-05 stsp
1412 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1413 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1414 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1415 5b87815e 2020-03-05 stsp
1416 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1417 49c543a6 2022-03-31 naddy ret=$?
1418 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1419 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1420 5b87815e 2020-03-05 stsp return 1
1421 5b87815e 2020-03-05 stsp fi
1422 5b87815e 2020-03-05 stsp
1423 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1424 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1425 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1426 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1427 5b87815e 2020-03-05 stsp
1428 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1429 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1430 49c543a6 2022-03-31 naddy ret=$?
1431 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1432 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1433 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1434 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1435 5b87815e 2020-03-05 stsp return 1
1436 de05890f 2020-03-05 stsp fi
1437 5b87815e 2020-03-05 stsp
1438 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1439 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1440 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1441 5b87815e 2020-03-05 stsp
1442 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1443 49c543a6 2022-03-31 naddy ret=$?
1444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1445 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1446 5b87815e 2020-03-05 stsp fi
1447 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1448 de05890f 2020-03-05 stsp
1449 de05890f 2020-03-05 stsp }
1450 ecfff807 2020-09-23 stsp
1451 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1452 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1453 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1454 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1455 ecfff807 2020-09-23 stsp
1456 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1457 ecfff807 2020-09-23 stsp
1458 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1459 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1460 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1461 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1462 ecfff807 2020-09-23 stsp
1463 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1464 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1465 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1466 ecfff807 2020-09-23 stsp
1467 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1468 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1469 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1470 ecfff807 2020-09-23 stsp
1471 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1472 49c543a6 2022-03-31 naddy ret=$?
1473 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1474 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1475 ecfff807 2020-09-23 stsp return 1
1476 ecfff807 2020-09-23 stsp fi
1477 de05890f 2020-03-05 stsp
1478 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1479 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1480 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1481 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1482 ecfff807 2020-09-23 stsp
1483 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1484 ecfff807 2020-09-23 stsp > $testroot/stdout)
1485 ecfff807 2020-09-23 stsp
1486 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1487 ecfff807 2020-09-23 stsp
1488 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1489 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1490 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1491 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1492 ecfff807 2020-09-23 stsp
1493 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1494 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1495 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1496 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1497 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1498 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1499 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1500 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1501 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1502 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1503 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1504 ecfff807 2020-09-23 stsp
1505 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1506 49c543a6 2022-03-31 naddy ret=$?
1507 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1508 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1509 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1510 ecfff807 2020-09-23 stsp return 1
1511 ecfff807 2020-09-23 stsp fi
1512 ecfff807 2020-09-23 stsp
1513 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1514 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1515 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1516 ecfff807 2020-09-23 stsp return 1
1517 ecfff807 2020-09-23 stsp fi
1518 ecfff807 2020-09-23 stsp
1519 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1520 ecfff807 2020-09-23 stsp
1521 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1522 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1523 49c543a6 2022-03-31 naddy ret=$?
1524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1525 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1527 ecfff807 2020-09-23 stsp return 1
1528 ecfff807 2020-09-23 stsp fi
1529 ecfff807 2020-09-23 stsp
1530 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1531 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1532 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1533 49c543a6 2022-03-31 naddy ret=$?
1534 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1535 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1536 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1537 29c68398 2020-09-24 stsp return 1
1538 29c68398 2020-09-24 stsp fi
1539 29c68398 2020-09-24 stsp
1540 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1541 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1542 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1543 49c543a6 2022-03-31 naddy ret=$?
1544 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1545 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1546 15aed053 2023-03-07 naddy fi
1547 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1548 15aed053 2023-03-07 naddy }
1549 15aed053 2023-03-07 naddy
1550 15aed053 2023-03-07 naddy test_histedit_fold_delete_add() {
1551 15aed053 2023-03-07 naddy local testroot=`test_init histedit_fold_delete_add`
1552 15aed053 2023-03-07 naddy
1553 15aed053 2023-03-07 naddy local orig_commit=`git_show_head $testroot/repo`
1554 15aed053 2023-03-07 naddy
1555 15aed053 2023-03-07 naddy (cd $testroot/repo && git rm -q alpha)
1556 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "removing alpha"
1557 15aed053 2023-03-07 naddy local old_commit1=`git_show_head $testroot/repo`
1558 15aed053 2023-03-07 naddy
1559 15aed053 2023-03-07 naddy echo "modified alpha" >$testroot/repo/alpha
1560 15aed053 2023-03-07 naddy (cd $testroot/repo && git add alpha)
1561 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "add back modified alpha"
1562 15aed053 2023-03-07 naddy local old_commit2=`git_show_head $testroot/repo`
1563 15aed053 2023-03-07 naddy
1564 15aed053 2023-03-07 naddy got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1565 15aed053 2023-03-07 naddy ret=$?
1566 15aed053 2023-03-07 naddy if [ $ret -ne 0 ]; then
1567 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1568 15aed053 2023-03-07 naddy return 1
1569 15aed053 2023-03-07 naddy fi
1570 15aed053 2023-03-07 naddy
1571 15aed053 2023-03-07 naddy echo "fold $old_commit1" > $testroot/histedit-script
1572 15aed053 2023-03-07 naddy echo "pick $old_commit2" >> $testroot/histedit-script
1573 15aed053 2023-03-07 naddy echo "mesg folded changes" >> $testroot/histedit-script
1574 15aed053 2023-03-07 naddy
1575 15aed053 2023-03-07 naddy (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1576 15aed053 2023-03-07 naddy > $testroot/stdout)
1577 15aed053 2023-03-07 naddy
1578 15aed053 2023-03-07 naddy local new_commit1=`git_show_head $testroot/repo`
1579 15aed053 2023-03-07 naddy
1580 15aed053 2023-03-07 naddy local short_old_commit1=`trim_obj_id 28 $old_commit1`
1581 15aed053 2023-03-07 naddy local short_old_commit2=`trim_obj_id 28 $old_commit2`
1582 15aed053 2023-03-07 naddy local short_new_commit1=`trim_obj_id 28 $new_commit1`
1583 15aed053 2023-03-07 naddy
1584 15aed053 2023-03-07 naddy echo "D alpha" > $testroot/stdout.expected
1585 15aed053 2023-03-07 naddy echo "$short_old_commit1 -> fold commit: removing alpha" \
1586 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1587 15aed053 2023-03-07 naddy echo "A alpha" >> $testroot/stdout.expected
1588 15aed053 2023-03-07 naddy echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1589 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1590 15aed053 2023-03-07 naddy echo "Switching work tree to refs/heads/master" \
1591 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1592 15aed053 2023-03-07 naddy
1593 9a298e5c 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1594 9a298e5c 2023-03-10 stsp ret=$?
1595 9a298e5c 2023-03-10 stsp if [ $ret -ne 0 ]; then
1596 9a298e5c 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1597 9a298e5c 2023-03-10 stsp test_done "$testroot" "$ret"
1598 9a298e5c 2023-03-10 stsp return 1
1599 9a298e5c 2023-03-10 stsp fi
1600 15aed053 2023-03-07 naddy
1601 15aed053 2023-03-07 naddy if [ ! -e $testroot/wt/alpha ]; then
1602 9a298e5c 2023-03-10 stsp echo "file alpha is missing on disk" >&2
1603 9a298e5c 2023-03-10 stsp test_done "$testroot" "1"
1604 5fdcbbb6 2023-03-14 naddy return 1
1605 5fdcbbb6 2023-03-14 naddy fi
1606 5fdcbbb6 2023-03-14 naddy
1607 5fdcbbb6 2023-03-14 naddy echo "modified alpha" > $testroot/content.expected
1608 5fdcbbb6 2023-03-14 naddy cat $testroot/wt/alpha > $testroot/content
1609 5fdcbbb6 2023-03-14 naddy cmp -s $testroot/content.expected $testroot/content
1610 5fdcbbb6 2023-03-14 naddy ret=$?
1611 5fdcbbb6 2023-03-14 naddy if [ $ret -ne 0 ]; then
1612 5fdcbbb6 2023-03-14 naddy diff -u $testroot/content.expected $testroot/content
1613 5fdcbbb6 2023-03-14 naddy test_done "$testroot" "$ret"
1614 9a298e5c 2023-03-10 stsp return 1
1615 ecfff807 2020-09-23 stsp fi
1616 9a298e5c 2023-03-10 stsp test_done "$testroot" "0"
1617 ecfff807 2020-09-23 stsp }
1618 239f5c5a 2020-12-13 stsp
1619 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1620 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1621 239f5c5a 2020-12-13 stsp
1622 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1623 239f5c5a 2020-12-13 stsp
1624 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1625 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1626 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1627 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1628 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1629 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1630 239f5c5a 2020-12-13 stsp
1631 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1632 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1633 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1634 239f5c5a 2020-12-13 stsp
1635 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1636 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1637 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1638 239f5c5a 2020-12-13 stsp
1639 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1640 49c543a6 2022-03-31 naddy ret=$?
1641 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1642 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1643 239f5c5a 2020-12-13 stsp return 1
1644 239f5c5a 2020-12-13 stsp fi
1645 239f5c5a 2020-12-13 stsp
1646 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1647 239f5c5a 2020-12-13 stsp #!/bin/sh
1648 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1649 885e96df 2023-03-06 naddy ,s/.*/committing folded changes/
1650 885e96df 2023-03-06 naddy w
1651 885e96df 2023-03-06 naddy EOF
1652 239f5c5a 2020-12-13 stsp EOF
1653 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1654 239f5c5a 2020-12-13 stsp
1655 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1656 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1657 239f5c5a 2020-12-13 stsp
1658 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1659 239f5c5a 2020-12-13 stsp
1660 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1661 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1662 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1663 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1664 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1665 239f5c5a 2020-12-13 stsp
1666 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1667 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1668 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1669 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1670 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1671 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1672 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1673 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1674 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1675 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1676 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1677 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1678 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1679 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1680 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1681 ecfff807 2020-09-23 stsp
1682 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1683 49c543a6 2022-03-31 naddy ret=$?
1684 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1685 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1686 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1687 239f5c5a 2020-12-13 stsp return 1
1688 239f5c5a 2020-12-13 stsp fi
1689 ecfff807 2020-09-23 stsp
1690 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1691 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1692 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1693 49c543a6 2022-03-31 naddy ret=$?
1694 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1695 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1696 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1697 239f5c5a 2020-12-13 stsp return 1
1698 239f5c5a 2020-12-13 stsp fi
1699 239f5c5a 2020-12-13 stsp
1700 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1701 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1702 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1703 239f5c5a 2020-12-13 stsp return 1
1704 239f5c5a 2020-12-13 stsp fi
1705 239f5c5a 2020-12-13 stsp
1706 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1707 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1708 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1709 49c543a6 2022-03-31 naddy ret=$?
1710 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1711 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1712 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1713 239f5c5a 2020-12-13 stsp return 1
1714 239f5c5a 2020-12-13 stsp fi
1715 239f5c5a 2020-12-13 stsp
1716 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1717 239f5c5a 2020-12-13 stsp
1718 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1719 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1720 49c543a6 2022-03-31 naddy ret=$?
1721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1722 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1723 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1724 239f5c5a 2020-12-13 stsp return 1
1725 239f5c5a 2020-12-13 stsp fi
1726 239f5c5a 2020-12-13 stsp
1727 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1728 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1729 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1730 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1731 49c543a6 2022-03-31 naddy ret=$?
1732 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1733 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1734 239f5c5a 2020-12-13 stsp fi
1735 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1736 239f5c5a 2020-12-13 stsp }
1737 a347e6bb 2020-12-13 stsp
1738 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1739 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1740 a347e6bb 2020-12-13 stsp
1741 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1742 a347e6bb 2020-12-13 stsp
1743 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1744 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1745 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1746 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1747 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1748 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1749 239f5c5a 2020-12-13 stsp
1750 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1751 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1752 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1753 a347e6bb 2020-12-13 stsp
1754 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1755 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1756 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1757 a347e6bb 2020-12-13 stsp
1758 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1759 49c543a6 2022-03-31 naddy ret=$?
1760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1761 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1762 a347e6bb 2020-12-13 stsp return 1
1763 a347e6bb 2020-12-13 stsp fi
1764 a347e6bb 2020-12-13 stsp
1765 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1766 a347e6bb 2020-12-13 stsp #!/bin/sh
1767 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1768 885e96df 2023-03-06 naddy ,d
1769 885e96df 2023-03-06 naddy w
1770 885e96df 2023-03-06 naddy EOF
1771 a347e6bb 2020-12-13 stsp EOF
1772 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1773 a347e6bb 2020-12-13 stsp
1774 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1775 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1776 a347e6bb 2020-12-13 stsp
1777 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1778 a347e6bb 2020-12-13 stsp
1779 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1780 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1781 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1782 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1783 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1784 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1785 a347e6bb 2020-12-13 stsp
1786 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1787 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1788 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1789 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1790 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1791 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1792 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1793 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1794 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1795 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1796 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1797 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1798 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1799 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1800 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1801 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1802 a347e6bb 2020-12-13 stsp
1803 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1804 49c543a6 2022-03-31 naddy ret=$?
1805 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1806 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1807 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1808 a347e6bb 2020-12-13 stsp return 1
1809 a347e6bb 2020-12-13 stsp fi
1810 a347e6bb 2020-12-13 stsp
1811 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1812 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1813 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1814 49c543a6 2022-03-31 naddy ret=$?
1815 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1816 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1817 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1818 a347e6bb 2020-12-13 stsp return 1
1819 a347e6bb 2020-12-13 stsp fi
1820 a347e6bb 2020-12-13 stsp
1821 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1822 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1823 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1824 a347e6bb 2020-12-13 stsp return 1
1825 a347e6bb 2020-12-13 stsp fi
1826 a347e6bb 2020-12-13 stsp
1827 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1828 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1829 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1830 49c543a6 2022-03-31 naddy ret=$?
1831 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1832 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1833 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1834 a347e6bb 2020-12-13 stsp return 1
1835 a347e6bb 2020-12-13 stsp fi
1836 a347e6bb 2020-12-13 stsp
1837 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1838 a347e6bb 2020-12-13 stsp
1839 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1840 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1841 49c543a6 2022-03-31 naddy ret=$?
1842 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1843 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1844 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1845 a347e6bb 2020-12-13 stsp return 1
1846 a347e6bb 2020-12-13 stsp fi
1847 a347e6bb 2020-12-13 stsp
1848 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1849 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1850 b93c7142 2021-10-01 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1851 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1852 49c543a6 2022-03-31 naddy ret=$?
1853 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1854 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1855 b93c7142 2021-10-01 stsp fi
1856 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1857 b93c7142 2021-10-01 stsp }
1858 b93c7142 2021-10-01 stsp
1859 b93c7142 2021-10-01 stsp test_histedit_edit_only() {
1860 b93c7142 2021-10-01 stsp local testroot=`test_init histedit_edit_only`
1861 b93c7142 2021-10-01 stsp
1862 b93c7142 2021-10-01 stsp local orig_commit=`git_show_head $testroot/repo`
1863 b93c7142 2021-10-01 stsp
1864 b93c7142 2021-10-01 stsp echo "modified alpha on master" > $testroot/repo/alpha
1865 b93c7142 2021-10-01 stsp (cd $testroot/repo && git rm -q beta)
1866 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/repo/epsilon/new
1867 b93c7142 2021-10-01 stsp (cd $testroot/repo && git add epsilon/new)
1868 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing changes"
1869 b93c7142 2021-10-01 stsp local old_commit1=`git_show_head $testroot/repo`
1870 b93c7142 2021-10-01 stsp
1871 b93c7142 2021-10-01 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1872 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing to zeta on master"
1873 b93c7142 2021-10-01 stsp local old_commit2=`git_show_head $testroot/repo`
1874 b93c7142 2021-10-01 stsp
1875 b93c7142 2021-10-01 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1876 49c543a6 2022-03-31 naddy ret=$?
1877 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1878 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1879 b93c7142 2021-10-01 stsp return 1
1880 b93c7142 2021-10-01 stsp fi
1881 b93c7142 2021-10-01 stsp
1882 b93c7142 2021-10-01 stsp (cd $testroot/wt && got histedit -e > $testroot/stdout)
1883 b93c7142 2021-10-01 stsp
1884 b93c7142 2021-10-01 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1885 b93c7142 2021-10-01 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1886 b93c7142 2021-10-01 stsp
1887 b93c7142 2021-10-01 stsp echo "G alpha" > $testroot/stdout.expected
1888 b93c7142 2021-10-01 stsp echo "D beta" >> $testroot/stdout.expected
1889 b93c7142 2021-10-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1890 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit1" \
1891 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1892 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1893 49c543a6 2022-03-31 naddy ret=$?
1894 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1895 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1896 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1897 b93c7142 2021-10-01 stsp return 1
1898 b93c7142 2021-10-01 stsp fi
1899 b93c7142 2021-10-01 stsp
1900 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
1901 b93c7142 2021-10-01 stsp
1902 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
1903 b93c7142 2021-10-01 stsp #!/bin/sh
1904 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1905 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 1/
1906 885e96df 2023-03-06 naddy w
1907 885e96df 2023-03-06 naddy EOF
1908 b93c7142 2021-10-01 stsp EOF
1909 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
1910 b93c7142 2021-10-01 stsp
1911 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1912 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1913 b93c7142 2021-10-01 stsp
1914 b93c7142 2021-10-01 stsp local new_commit1=$(cd $testroot/wt && got info | \
1915 b93c7142 2021-10-01 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1916 b93c7142 2021-10-01 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1917 b93c7142 2021-10-01 stsp
1918 b93c7142 2021-10-01 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1919 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
1920 b93c7142 2021-10-01 stsp echo "committing edited changes 1" >> $testroot/stdout.expected
1921 b93c7142 2021-10-01 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1922 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit2" \
1923 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1924 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1925 49c543a6 2022-03-31 naddy ret=$?
1926 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1927 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1928 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1929 b93c7142 2021-10-01 stsp return 1
1930 b93c7142 2021-10-01 stsp fi
1931 b93c7142 2021-10-01 stsp
1932 b93c7142 2021-10-01 stsp echo "edited zeta on master" > $testroot/wt/epsilon/zeta
1933 b93c7142 2021-10-01 stsp
1934 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
1935 b93c7142 2021-10-01 stsp #!/bin/sh
1936 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1937 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 2/
1938 885e96df 2023-03-06 naddy w
1939 885e96df 2023-03-06 naddy EOF
1940 b93c7142 2021-10-01 stsp EOF
1941 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
1942 b93c7142 2021-10-01 stsp
1943 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1944 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1945 b93c7142 2021-10-01 stsp
1946 b93c7142 2021-10-01 stsp local new_commit2=`git_show_head $testroot/repo`
1947 b93c7142 2021-10-01 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1948 b93c7142 2021-10-01 stsp
1949 b93c7142 2021-10-01 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
1950 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
1951 b93c7142 2021-10-01 stsp echo "committing edited changes 2" >> $testroot/stdout.expected
1952 b93c7142 2021-10-01 stsp echo "Switching work tree to refs/heads/master" \
1953 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1954 b93c7142 2021-10-01 stsp
1955 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1956 49c543a6 2022-03-31 naddy ret=$?
1957 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1958 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1959 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1960 b93c7142 2021-10-01 stsp return 1
1961 b93c7142 2021-10-01 stsp fi
1962 b93c7142 2021-10-01 stsp
1963 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/content.expected
1964 b93c7142 2021-10-01 stsp cat $testroot/wt/alpha > $testroot/content
1965 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
1966 49c543a6 2022-03-31 naddy ret=$?
1967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1968 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
1969 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1970 b93c7142 2021-10-01 stsp return 1
1971 b93c7142 2021-10-01 stsp fi
1972 b93c7142 2021-10-01 stsp
1973 b93c7142 2021-10-01 stsp if [ -e $testroot/wt/beta ]; then
1974 b93c7142 2021-10-01 stsp echo "removed file beta still exists on disk" >&2
1975 b93c7142 2021-10-01 stsp test_done "$testroot" "1"
1976 b93c7142 2021-10-01 stsp return 1
1977 b93c7142 2021-10-01 stsp fi
1978 b93c7142 2021-10-01 stsp
1979 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/content.expected
1980 b93c7142 2021-10-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
1981 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
1982 49c543a6 2022-03-31 naddy ret=$?
1983 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1984 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
1985 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1986 b93c7142 2021-10-01 stsp return 1
1987 b93c7142 2021-10-01 stsp fi
1988 b93c7142 2021-10-01 stsp
1989 b93c7142 2021-10-01 stsp (cd $testroot/wt && got status > $testroot/stdout)
1990 b93c7142 2021-10-01 stsp
1991 b93c7142 2021-10-01 stsp echo -n > $testroot/stdout.expected
1992 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1993 49c543a6 2022-03-31 naddy ret=$?
1994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1995 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1996 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1997 b93c7142 2021-10-01 stsp return 1
1998 b93c7142 2021-10-01 stsp fi
1999 b93c7142 2021-10-01 stsp
2000 b93c7142 2021-10-01 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2001 b93c7142 2021-10-01 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2002 b93c7142 2021-10-01 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
2003 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2004 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2005 49c543a6 2022-03-31 naddy ret=$?
2006 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2007 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2008 a347e6bb 2020-12-13 stsp fi
2009 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2010 a347e6bb 2020-12-13 stsp }
2011 09209b8a 2021-10-08 stsp
2012 09209b8a 2021-10-08 stsp test_histedit_prepend_line() {
2013 09209b8a 2021-10-08 stsp local testroot=`test_init histedit_prepend_line`
2014 09209b8a 2021-10-08 stsp local orig_commit=`git_show_head $testroot/repo`
2015 09209b8a 2021-10-08 stsp
2016 09209b8a 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2017 09209b8a 2021-10-08 stsp
2018 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/alpha" <<EOF
2019 b4e0802f 2021-10-14 naddy 1i
2020 09209b8a 2021-10-08 stsp first line
2021 09209b8a 2021-10-08 stsp .
2022 09209b8a 2021-10-08 stsp wq
2023 09209b8a 2021-10-08 stsp EOF
2024 09209b8a 2021-10-08 stsp
2025 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content.expected
2026 a347e6bb 2020-12-13 stsp
2027 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2028 09209b8a 2021-10-08 stsp alpha > /dev/null)
2029 49c543a6 2022-03-31 naddy ret=$?
2030 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2031 09209b8a 2021-10-08 stsp echo "got commit failed unexpectedly" >&2
2032 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2033 09209b8a 2021-10-08 stsp return 1
2034 09209b8a 2021-10-08 stsp fi
2035 09209b8a 2021-10-08 stsp
2036 09209b8a 2021-10-08 stsp local top_commit=`git_show_head $testroot/repo`
2037 09209b8a 2021-10-08 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2038 09209b8a 2021-10-08 stsp
2039 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2040 49c543a6 2022-03-31 naddy ret=$?
2041 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2042 09209b8a 2021-10-08 stsp echo "got update failed unexpectedly" >&2
2043 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2044 09209b8a 2021-10-08 stsp return 1
2045 09209b8a 2021-10-08 stsp fi
2046 09209b8a 2021-10-08 stsp
2047 09209b8a 2021-10-08 stsp (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2048 09209b8a 2021-10-08 stsp > /dev/null)
2049 49c543a6 2022-03-31 naddy ret=$?
2050 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2051 09209b8a 2021-10-08 stsp echo "got histedit failed unexpectedly" >&2
2052 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2053 09209b8a 2021-10-08 stsp return 1
2054 09209b8a 2021-10-08 stsp fi
2055 09209b8a 2021-10-08 stsp
2056 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content
2057 09209b8a 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
2058 49c543a6 2022-03-31 naddy ret=$?
2059 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2060 09209b8a 2021-10-08 stsp diff -u $testroot/content.expected $testroot/content
2061 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2062 09209b8a 2021-10-08 stsp return 1
2063 09209b8a 2021-10-08 stsp fi
2064 09209b8a 2021-10-08 stsp
2065 09209b8a 2021-10-08 stsp test_done "$testroot" $ret
2066 09209b8a 2021-10-08 stsp }
2067 f1e5aff4 2022-07-12 op
2068 f1e5aff4 2022-07-12 op test_histedit_mesg_invalid() {
2069 f1e5aff4 2022-07-12 op local testroot=`test_init mesg_invalid`
2070 f1e5aff4 2022-07-12 op
2071 f1e5aff4 2022-07-12 op local orig_commit=`git_show_head $testroot/repo`
2072 f1e5aff4 2022-07-12 op
2073 f1e5aff4 2022-07-12 op echo "modified alpha on master" > $testroot/repo/alpha
2074 f1e5aff4 2022-07-12 op (cd $testroot/repo && git rm -q beta)
2075 f1e5aff4 2022-07-12 op echo "new file on master" > $testroot/repo/epsilon/new
2076 f1e5aff4 2022-07-12 op (cd $testroot/repo && git add epsilon/new)
2077 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing changes'
2078 f1e5aff4 2022-07-12 op local old_commit1=`git_show_head $testroot/repo`
2079 f1e5aff4 2022-07-12 op
2080 f1e5aff4 2022-07-12 op echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2081 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing to zeto on master'
2082 f1e5aff4 2022-07-12 op local old_commit2=`git_show_head $testroot/repo`
2083 f1e5aff4 2022-07-12 op
2084 f1e5aff4 2022-07-12 op got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2085 f1e5aff4 2022-07-12 op ret=$?
2086 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2087 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2088 97f28afb 2022-07-20 op return 1
2089 f1e5aff4 2022-07-12 op fi
2090 f1e5aff4 2022-07-12 op
2091 f1e5aff4 2022-07-12 op # try with a leading mesg
2092 f1e5aff4 2022-07-12 op
2093 f1e5aff4 2022-07-12 op echo "mesg something something" > $testroot/histedit-script
2094 f1e5aff4 2022-07-12 op echo "pick $old_commit1" >> $testroot/histedit-script
2095 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2096 f1e5aff4 2022-07-12 op
2097 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2098 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2099 f1e5aff4 2022-07-12 op ret=$?
2100 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2101 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2102 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2103 f1e5aff4 2022-07-12 op return 1
2104 f1e5aff4 2022-07-12 op fi
2105 09209b8a 2021-10-08 stsp
2106 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2107 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2108 f1e5aff4 2022-07-12 op ret=$?
2109 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2110 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2111 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2112 f1e5aff4 2022-07-12 op return 1
2113 f1e5aff4 2022-07-12 op fi
2114 f1e5aff4 2022-07-12 op
2115 f1e5aff4 2022-07-12 op # try again with mesg -> mesg
2116 f1e5aff4 2022-07-12 op
2117 f1e5aff4 2022-07-12 op echo "pick $old_commit1" > $testroot/histedit-script
2118 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2119 f1e5aff4 2022-07-12 op echo "mesg something something else" >> $testroot/histedit-script
2120 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2121 f1e5aff4 2022-07-12 op
2122 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2123 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2124 f1e5aff4 2022-07-12 op ret=$?
2125 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2126 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2127 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2128 f1e5aff4 2022-07-12 op return 1
2129 f1e5aff4 2022-07-12 op fi
2130 f1e5aff4 2022-07-12 op
2131 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2132 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2133 f1e5aff4 2022-07-12 op ret=$?
2134 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2135 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2136 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2137 f1e5aff4 2022-07-12 op return 1
2138 f1e5aff4 2022-07-12 op fi
2139 f1e5aff4 2022-07-12 op
2140 f1e5aff4 2022-07-12 op # try again with drop -> mesg
2141 f1e5aff4 2022-07-12 op
2142 f1e5aff4 2022-07-12 op echo "drop $old_commit1" > $testroot/histedit-script
2143 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2144 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2145 f1e5aff4 2022-07-12 op
2146 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2147 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2148 f1e5aff4 2022-07-12 op ret=$?
2149 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2150 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2151 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2152 f1e5aff4 2022-07-12 op return 1
2153 f1e5aff4 2022-07-12 op fi
2154 f1e5aff4 2022-07-12 op
2155 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2156 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2157 f1e5aff4 2022-07-12 op ret=$?
2158 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2159 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2160 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2161 f1e5aff4 2022-07-12 op return 1
2162 f1e5aff4 2022-07-12 op fi
2163 f1e5aff4 2022-07-12 op
2164 f1e5aff4 2022-07-12 op # try again with fold -> mesg
2165 f1e5aff4 2022-07-12 op
2166 f1e5aff4 2022-07-12 op echo "fold $old_commit1" > $testroot/histedit-script
2167 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2168 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2169 f1e5aff4 2022-07-12 op
2170 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2171 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2172 f1e5aff4 2022-07-12 op ret=$?
2173 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2174 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2175 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2176 f1e5aff4 2022-07-12 op return 1
2177 f1e5aff4 2022-07-12 op fi
2178 f1e5aff4 2022-07-12 op
2179 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2180 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2181 f1e5aff4 2022-07-12 op ret=$?
2182 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2183 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2184 f1e5aff4 2022-07-12 op fi
2185 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2186 598eac43 2022-07-22 stsp }
2187 598eac43 2022-07-22 stsp
2188 598eac43 2022-07-22 stsp test_histedit_resets_committer() {
2189 598eac43 2022-07-22 stsp local testroot=`test_init histedit_resets_committer`
2190 598eac43 2022-07-22 stsp local orig_commit=`git_show_head $testroot/repo`
2191 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
2192 598eac43 2022-07-22 stsp
2193 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2194 598eac43 2022-07-22 stsp
2195 598eac43 2022-07-22 stsp echo "modified alpha" > $testroot/wt/alpha
2196 598eac43 2022-07-22 stsp
2197 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2198 598eac43 2022-07-22 stsp alpha > /dev/null)
2199 598eac43 2022-07-22 stsp ret=$?
2200 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2201 598eac43 2022-07-22 stsp echo "got commit failed unexpectedly" >&2
2202 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2203 598eac43 2022-07-22 stsp return 1
2204 598eac43 2022-07-22 stsp fi
2205 598eac43 2022-07-22 stsp
2206 598eac43 2022-07-22 stsp local top_commit=`git_show_head $testroot/repo`
2207 598eac43 2022-07-22 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2208 598eac43 2022-07-22 stsp
2209 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2210 598eac43 2022-07-22 stsp ret=$?
2211 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2212 598eac43 2022-07-22 stsp echo "got update failed unexpectedly" >&2
2213 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2214 598eac43 2022-07-22 stsp return 1
2215 598eac43 2022-07-22 stsp fi
2216 598eac43 2022-07-22 stsp
2217 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2218 598eac43 2022-07-22 stsp got histedit -F "$testroot/histedit-script" > /dev/null)
2219 598eac43 2022-07-22 stsp ret=$?
2220 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2221 598eac43 2022-07-22 stsp echo "got histedit failed unexpectedly" >&2
2222 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2223 598eac43 2022-07-22 stsp return 1
2224 598eac43 2022-07-22 stsp fi
2225 598eac43 2022-07-22 stsp local edited_commit=`git_show_head $testroot/repo`
2226 598eac43 2022-07-22 stsp
2227 598eac43 2022-07-22 stsp # Original commit only had one author
2228 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $top_commit | \
2229 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2230 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2231 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2232 598eac43 2022-07-22 stsp ret=$?
2233 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2234 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2235 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2236 598eac43 2022-07-22 stsp return 1
2237 598eac43 2022-07-22 stsp fi
2238 598eac43 2022-07-22 stsp
2239 598eac43 2022-07-22 stsp # Edited commit should have new committer name added
2240 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $edited_commit | \
2241 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2242 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2243 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
2244 598eac43 2022-07-22 stsp
2245 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2246 598eac43 2022-07-22 stsp ret=$?
2247 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2248 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2249 598eac43 2022-07-22 stsp fi
2250 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2251 f1e5aff4 2022-07-12 op }
2252 b2b3fce1 2022-10-29 op
2253 b2b3fce1 2022-10-29 op test_histedit_umask() {
2254 b2b3fce1 2022-10-29 op local testroot=`test_init histedit_umask`
2255 b2b3fce1 2022-10-29 op local orig_commit=`git_show_head "$testroot/repo"`
2256 b2b3fce1 2022-10-29 op
2257 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2258 b2b3fce1 2022-10-29 op
2259 b2b3fce1 2022-10-29 op echo "modified alpha" > $testroot/wt/alpha
2260 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2261 b2b3fce1 2022-10-29 op local commit1=`git_show_head "$testroot/repo"`
2262 b2b3fce1 2022-10-29 op
2263 b2b3fce1 2022-10-29 op echo "modified again" > $testroot/wt/alpha
2264 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2265 b2b3fce1 2022-10-29 op local commit2=`git_show_head "$testroot/repo"`
2266 b2b3fce1 2022-10-29 op
2267 b2b3fce1 2022-10-29 op echo "modified again!" > $testroot/wt/alpha
2268 b2b3fce1 2022-10-29 op echo "modify beta too!" > $testroot/wt/beta
2269 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2270 b2b3fce1 2022-10-29 op local commit3=`git_show_head "$testroot/repo"`
2271 f1e5aff4 2022-07-12 op
2272 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2273 b2b3fce1 2022-10-29 op ret=$?
2274 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2275 b2b3fce1 2022-10-29 op echo "update to $orig_commit failed!" >&2
2276 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2277 b2b3fce1 2022-10-29 op return 1
2278 b2b3fce1 2022-10-29 op fi
2279 b2b3fce1 2022-10-29 op
2280 b2b3fce1 2022-10-29 op echo fold $commit1 >$testroot/histedit-script
2281 b2b3fce1 2022-10-29 op echo fold $commit2 >>$testroot/histedit-script
2282 b2b3fce1 2022-10-29 op echo pick $commit3 >>$testroot/histedit-script
2283 b2b3fce1 2022-10-29 op echo mesg folding changes >>$testroot/histedit-script
2284 b2b3fce1 2022-10-29 op
2285 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
2286 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && \
2287 b2b3fce1 2022-10-29 op got histedit -F "$testroot/histedit-script") >/dev/null
2288 b2b3fce1 2022-10-29 op ret=$?
2289 b2b3fce1 2022-10-29 op
2290 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2291 b2b3fce1 2022-10-29 op echo "histedit operation failed" >&2
2292 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
2293 b2b3fce1 2022-10-29 op return 1
2294 b2b3fce1 2022-10-29 op fi
2295 b2b3fce1 2022-10-29 op
2296 b2b3fce1 2022-10-29 op for f in alpha beta; do
2297 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2298 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
2299 b2b3fce1 2022-10-29 op echo "$f is not 0600 after histedi" >&2
2300 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
2301 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2302 b2b3fce1 2022-10-29 op return 1
2303 b2b3fce1 2022-10-29 op fi
2304 b2b3fce1 2022-10-29 op done
2305 b2b3fce1 2022-10-29 op
2306 b2b3fce1 2022-10-29 op test_done "$testroot" 0
2307 b2b3fce1 2022-10-29 op }
2308 c48f94a4 2023-01-29 stsp
2309 c48f94a4 2023-01-29 stsp test_histedit_mesg_filemode_change() {
2310 c48f94a4 2023-01-29 stsp local testroot=`test_init histedit_mode_change`
2311 c48f94a4 2023-01-29 stsp
2312 c48f94a4 2023-01-29 stsp local orig_commit=`git_show_head $testroot/repo`
2313 c48f94a4 2023-01-29 stsp local orig_author_time=`git_show_author_time $testroot/repo`
2314 c48f94a4 2023-01-29 stsp
2315 c48f94a4 2023-01-29 stsp chmod +x $testroot/repo/alpha
2316 c48f94a4 2023-01-29 stsp git_commit $testroot/repo -m "set x bit on alpha"
2317 c48f94a4 2023-01-29 stsp local old_commit1=`git_show_head $testroot/repo`
2318 c48f94a4 2023-01-29 stsp local old_author_time1=`git_show_author_time $testroot/repo`
2319 c48f94a4 2023-01-29 stsp
2320 c48f94a4 2023-01-29 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2321 c48f94a4 2023-01-29 stsp ret=$?
2322 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2323 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2324 c48f94a4 2023-01-29 stsp return 1
2325 c48f94a4 2023-01-29 stsp fi
2326 c48f94a4 2023-01-29 stsp
2327 c48f94a4 2023-01-29 stsp if [ -x $testroot/wt/alpha ]; then
2328 c48f94a4 2023-01-29 stsp echo "file alpha has unexpected executable bit" >&2
2329 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2330 c48f94a4 2023-01-29 stsp return 1
2331 c48f94a4 2023-01-29 stsp fi
2332 c48f94a4 2023-01-29 stsp
2333 c48f94a4 2023-01-29 stsp cat > $testroot/editor.sh <<EOF
2334 c48f94a4 2023-01-29 stsp #!/bin/sh
2335 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2336 885e96df 2023-03-06 naddy ,s/ x bit / executable bit /
2337 885e96df 2023-03-06 naddy w
2338 885e96df 2023-03-06 naddy EOF
2339 c48f94a4 2023-01-29 stsp EOF
2340 b2b3fce1 2022-10-29 op
2341 c48f94a4 2023-01-29 stsp chmod +x $testroot/editor.sh
2342 c48f94a4 2023-01-29 stsp
2343 71a61c8c 2023-01-29 stsp (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2344 c48f94a4 2023-01-29 stsp got histedit -m > $testroot/stdout)
2345 c48f94a4 2023-01-29 stsp
2346 c48f94a4 2023-01-29 stsp local new_commit1=`git_show_head $testroot/repo`
2347 c48f94a4 2023-01-29 stsp local new_author_time1=`git_show_author_time $testroot/repo`
2348 c48f94a4 2023-01-29 stsp
2349 c48f94a4 2023-01-29 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2350 c48f94a4 2023-01-29 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2351 c48f94a4 2023-01-29 stsp
2352 c48f94a4 2023-01-29 stsp echo "G alpha" > $testroot/stdout.expected
2353 c48f94a4 2023-01-29 stsp echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2354 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2355 c48f94a4 2023-01-29 stsp echo "Switching work tree to refs/heads/master" \
2356 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2357 c48f94a4 2023-01-29 stsp
2358 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2359 c48f94a4 2023-01-29 stsp ret=$?
2360 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2361 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2362 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2363 c48f94a4 2023-01-29 stsp return 1
2364 c48f94a4 2023-01-29 stsp fi
2365 c48f94a4 2023-01-29 stsp
2366 c48f94a4 2023-01-29 stsp echo "alpha" > $testroot/content.expected
2367 9f31ca1f 2023-01-29 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
2368 c48f94a4 2023-01-29 stsp ret=$?
2369 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2370 9f31ca1f 2023-01-29 stsp diff -u $testroot/content.expected $testroot/wt/alpha
2371 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2372 c48f94a4 2023-01-29 stsp return 1
2373 c48f94a4 2023-01-29 stsp fi
2374 c48f94a4 2023-01-29 stsp
2375 c48f94a4 2023-01-29 stsp if [ ! -x $testroot/wt/alpha ]; then
2376 c48f94a4 2023-01-29 stsp echo "file alpha lost its executable bit" >&2
2377 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2378 c48f94a4 2023-01-29 stsp return 1
2379 c48f94a4 2023-01-29 stsp fi
2380 c48f94a4 2023-01-29 stsp
2381 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got status > $testroot/stdout)
2382 c48f94a4 2023-01-29 stsp
2383 c48f94a4 2023-01-29 stsp echo -n > $testroot/stdout.expected
2384 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2385 c48f94a4 2023-01-29 stsp ret=$?
2386 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2387 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2388 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2389 c48f94a4 2023-01-29 stsp return 1
2390 c48f94a4 2023-01-29 stsp fi
2391 c48f94a4 2023-01-29 stsp
2392 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2393 c48f94a4 2023-01-29 stsp > $testroot/stdout)
2394 c48f94a4 2023-01-29 stsp
2395 c48f94a4 2023-01-29 stsp echo ' set executable bit on alpha' > $testroot/stdout.expected
2396 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2397 c48f94a4 2023-01-29 stsp ret=$?
2398 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2399 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2400 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2401 c48f94a4 2023-01-29 stsp return 1
2402 c48f94a4 2023-01-29 stsp fi
2403 c48f94a4 2023-01-29 stsp
2404 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2405 c48f94a4 2023-01-29 stsp }
2406 f1c9fe20 2023-01-30 mark
2407 f1c9fe20 2023-01-30 mark test_histedit_drop_only() {
2408 f1c9fe20 2023-01-30 mark local testroot=`test_init histedit_drop_only`
2409 f1c9fe20 2023-01-30 mark
2410 f1c9fe20 2023-01-30 mark local orig_commit=`git_show_head $testroot/repo`
2411 f1c9fe20 2023-01-30 mark local drop="-> drop commit:"
2412 f1c9fe20 2023-01-30 mark local dropmsg="commit changes to drop"
2413 f1c9fe20 2023-01-30 mark
2414 f1c9fe20 2023-01-30 mark echo "modified alpha on master" > $testroot/repo/alpha
2415 f1c9fe20 2023-01-30 mark (cd $testroot/repo && git rm -q beta)
2416 f1c9fe20 2023-01-30 mark echo "new file on master" > $testroot/repo/epsilon/new
2417 f1c9fe20 2023-01-30 mark (cd $testroot/repo && git add epsilon/new)
2418 f1c9fe20 2023-01-30 mark
2419 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 1"
2420 f1c9fe20 2023-01-30 mark local drop_commit1=`git_show_head $testroot/repo`
2421 f1c9fe20 2023-01-30 mark
2422 f1c9fe20 2023-01-30 mark echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2423 f1c9fe20 2023-01-30 mark
2424 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 2"
2425 f1c9fe20 2023-01-30 mark local drop_commit2=`git_show_head $testroot/repo`
2426 f1c9fe20 2023-01-30 mark
2427 f1c9fe20 2023-01-30 mark echo "modified delta on master" > $testroot/repo/gamma/delta
2428 f1c9fe20 2023-01-30 mark
2429 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 3"
2430 f1c9fe20 2023-01-30 mark local drop_commit3=`git_show_head $testroot/repo`
2431 f1c9fe20 2023-01-30 mark
2432 f1c9fe20 2023-01-30 mark got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2433 f1c9fe20 2023-01-30 mark ret=$?
2434 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2435 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2436 f1c9fe20 2023-01-30 mark return 1
2437 f1c9fe20 2023-01-30 mark fi
2438 c48f94a4 2023-01-29 stsp
2439 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got histedit -d > $testroot/stdout)
2440 f1c9fe20 2023-01-30 mark local new_commit1=`git_show_head $testroot/repo`
2441 f1c9fe20 2023-01-30 mark
2442 f1c9fe20 2023-01-30 mark local short_commit1=`trim_obj_id 28 $drop_commit1`
2443 f1c9fe20 2023-01-30 mark local short_commit2=`trim_obj_id 28 $drop_commit2`
2444 f1c9fe20 2023-01-30 mark local short_commit3=`trim_obj_id 28 $drop_commit3`
2445 f1c9fe20 2023-01-30 mark
2446 f1c9fe20 2023-01-30 mark echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2447 f1c9fe20 2023-01-30 mark echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2448 f1c9fe20 2023-01-30 mark echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2449 f1c9fe20 2023-01-30 mark echo "Switching work tree to refs/heads/master" \
2450 f1c9fe20 2023-01-30 mark >> $testroot/stdout.expected
2451 f1c9fe20 2023-01-30 mark
2452 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2453 f1c9fe20 2023-01-30 mark ret=$?
2454 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2455 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2456 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2457 f1c9fe20 2023-01-30 mark return 1
2458 f1c9fe20 2023-01-30 mark fi
2459 f1c9fe20 2023-01-30 mark
2460 f1c9fe20 2023-01-30 mark echo "alpha" > $testroot/content.expected
2461 f1c9fe20 2023-01-30 mark cat $testroot/wt/alpha > $testroot/content
2462 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2463 f1c9fe20 2023-01-30 mark ret=$?
2464 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2465 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2466 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2467 f1c9fe20 2023-01-30 mark return 1
2468 f1c9fe20 2023-01-30 mark fi
2469 f1c9fe20 2023-01-30 mark
2470 f1c9fe20 2023-01-30 mark echo "zeta" > $testroot/content.expected
2471 f1c9fe20 2023-01-30 mark cat $testroot/wt/epsilon/zeta > $testroot/content
2472 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2473 f1c9fe20 2023-01-30 mark ret=$?
2474 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2475 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2476 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2477 f1c9fe20 2023-01-30 mark return 1
2478 f1c9fe20 2023-01-30 mark fi
2479 f1c9fe20 2023-01-30 mark
2480 f1c9fe20 2023-01-30 mark echo "delta" > $testroot/content.expected
2481 f1c9fe20 2023-01-30 mark cat $testroot/wt/gamma/delta > $testroot/content
2482 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2483 f1c9fe20 2023-01-30 mark ret=$?
2484 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2485 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2486 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2487 f1c9fe20 2023-01-30 mark return 1
2488 f1c9fe20 2023-01-30 mark fi
2489 f1c9fe20 2023-01-30 mark
2490 f1c9fe20 2023-01-30 mark if [ ! -e $testroot/wt/beta ]; then
2491 f1c9fe20 2023-01-30 mark echo "removed file beta should be restored" >&2
2492 f1c9fe20 2023-01-30 mark test_done "$testroot" "1"
2493 f1c9fe20 2023-01-30 mark return 1
2494 f1c9fe20 2023-01-30 mark fi
2495 f1c9fe20 2023-01-30 mark
2496 f1c9fe20 2023-01-30 mark if [ -e $testroot/wt/new ]; then
2497 f1c9fe20 2023-01-30 mark echo "new file should no longer exist" >&2
2498 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2499 f1c9fe20 2023-01-30 mark return 1
2500 f1c9fe20 2023-01-30 mark fi
2501 f1c9fe20 2023-01-30 mark
2502 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2503 f1c9fe20 2023-01-30 mark
2504 f1c9fe20 2023-01-30 mark echo -n > $testroot/stdout.expected
2505 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2506 f1c9fe20 2023-01-30 mark ret=$?
2507 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2508 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2509 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2510 f1c9fe20 2023-01-30 mark return 1
2511 f1c9fe20 2023-01-30 mark fi
2512 f1c9fe20 2023-01-30 mark
2513 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2514 f1c9fe20 2023-01-30 mark echo "commit $orig_commit (master)" > $testroot/stdout.expected
2515 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2516 f1c9fe20 2023-01-30 mark ret=$?
2517 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2518 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2519 f1c9fe20 2023-01-30 mark fi
2520 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2521 f1c9fe20 2023-01-30 mark }
2522 f1c9fe20 2023-01-30 mark
2523 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2524 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
2525 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
2526 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
2527 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
2528 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
2529 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
2530 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
2531 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
2532 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
2533 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
2534 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
2535 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
2536 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
2537 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
2538 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
2539 15aed053 2023-03-07 naddy run_test test_histedit_fold_delete_add
2540 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
2541 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg
2542 b93c7142 2021-10-01 stsp run_test test_histedit_edit_only
2543 09209b8a 2021-10-08 stsp run_test test_histedit_prepend_line
2544 f1e5aff4 2022-07-12 op run_test test_histedit_mesg_invalid
2545 598eac43 2022-07-22 stsp run_test test_histedit_resets_committer
2546 b2b3fce1 2022-10-29 op run_test test_histedit_umask
2547 c48f94a4 2023-01-29 stsp run_test test_histedit_mesg_filemode_change
2548 f1c9fe20 2023-01-30 mark run_test test_histedit_drop_only