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 af179be7 2023-04-14 stsp if [ -e $testroot/wt/epsilon/new ]; then
906 af179be7 2023-04-14 stsp echo "removed file new still exists on disk" >&2
907 af179be7 2023-04-14 stsp test_done "$testroot" "1"
908 0ebf8283 2019-07-24 stsp return 1
909 0ebf8283 2019-07-24 stsp fi
910 0ebf8283 2019-07-24 stsp
911 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
912 0ebf8283 2019-07-24 stsp
913 af179be7 2023-04-14 stsp echo "? unversioned-file" > $testroot/stdout.expected
914 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
915 49c543a6 2022-03-31 naddy ret=$?
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
918 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
919 0ebf8283 2019-07-24 stsp return 1
920 0ebf8283 2019-07-24 stsp fi
921 0ebf8283 2019-07-24 stsp
922 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
923 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
924 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
925 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
926 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
927 49c543a6 2022-03-31 naddy ret=$?
928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
929 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
930 0160a755 2019-07-25 stsp fi
931 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
932 0160a755 2019-07-25 stsp }
933 0160a755 2019-07-25 stsp
934 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
935 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
936 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
937 0160a755 2019-07-25 stsp
938 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
939 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
940 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
941 0160a755 2019-07-25 stsp
942 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
943 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
944 49c543a6 2022-03-31 naddy ret=$?
945 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
946 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
947 0160a755 2019-07-25 stsp return 1
948 0160a755 2019-07-25 stsp fi
949 0160a755 2019-07-25 stsp
950 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
951 0160a755 2019-07-25 stsp
952 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
953 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
954 0160a755 2019-07-25 stsp
955 49c543a6 2022-03-31 naddy ret=$?
956 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
957 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
958 0160a755 2019-07-25 stsp test_done "$testroot" "1"
959 0160a755 2019-07-25 stsp return 1
960 0160a755 2019-07-25 stsp fi
961 0160a755 2019-07-25 stsp
962 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
963 0160a755 2019-07-25 stsp > $testroot/stderr.expected
964 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
965 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
966 0160a755 2019-07-25 stsp
967 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
968 49c543a6 2022-03-31 naddy ret=$?
969 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
970 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
971 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
972 0160a755 2019-07-25 stsp return 1
973 0160a755 2019-07-25 stsp fi
974 0160a755 2019-07-25 stsp
975 0160a755 2019-07-25 stsp rm -rf $testroot/wt
976 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
977 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
978 49c543a6 2022-03-31 naddy ret=$?
979 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
980 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
981 0160a755 2019-07-25 stsp return 1
982 0160a755 2019-07-25 stsp fi
983 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
984 0160a755 2019-07-25 stsp > $testroot/stdout)
985 0160a755 2019-07-25 stsp
986 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
987 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
988 0160a755 2019-07-25 stsp
989 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
990 0160a755 2019-07-25 stsp > $testroot/stdout.expected
991 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
992 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
993 0160a755 2019-07-25 stsp
994 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
995 49c543a6 2022-03-31 naddy ret=$?
996 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
997 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
998 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
999 0160a755 2019-07-25 stsp return 1
1000 0ebf8283 2019-07-24 stsp fi
1001 0160a755 2019-07-25 stsp
1002 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
1003 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1004 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1005 49c543a6 2022-03-31 naddy ret=$?
1006 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1007 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1008 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1009 0160a755 2019-07-25 stsp return 1
1010 0160a755 2019-07-25 stsp fi
1011 0160a755 2019-07-25 stsp
1012 0160a755 2019-07-25 stsp
1013 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1014 0160a755 2019-07-25 stsp
1015 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
1016 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1017 49c543a6 2022-03-31 naddy ret=$?
1018 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1019 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1020 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
1021 0160a755 2019-07-25 stsp return 1
1022 0160a755 2019-07-25 stsp fi
1023 0160a755 2019-07-25 stsp
1024 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1025 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
1026 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1027 49c543a6 2022-03-31 naddy ret=$?
1028 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1029 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1030 b2c50a0a 2019-07-25 stsp fi
1031 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1032 b2c50a0a 2019-07-25 stsp }
1033 b2c50a0a 2019-07-25 stsp
1034 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
1035 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
1036 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
1037 b2c50a0a 2019-07-25 stsp
1038 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
1039 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
1040 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
1041 b2c50a0a 2019-07-25 stsp
1042 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
1043 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
1044 b2c50a0a 2019-07-25 stsp
1045 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
1046 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1047 49c543a6 2022-03-31 naddy ret=$?
1048 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1049 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1050 b2c50a0a 2019-07-25 stsp return 1
1051 b2c50a0a 2019-07-25 stsp fi
1052 b2c50a0a 2019-07-25 stsp
1053 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
1054 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
1055 b2c50a0a 2019-07-25 stsp
1056 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1057 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
1058 b2c50a0a 2019-07-25 stsp
1059 49c543a6 2022-03-31 naddy ret=$?
1060 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1061 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
1062 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
1063 b2c50a0a 2019-07-25 stsp return 1
1064 b2c50a0a 2019-07-25 stsp fi
1065 b2c50a0a 2019-07-25 stsp
1066 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
1067 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
1068 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
1069 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
1070 b2c50a0a 2019-07-25 stsp
1071 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1072 49c543a6 2022-03-31 naddy ret=$?
1073 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1074 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
1075 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1076 b2c50a0a 2019-07-25 stsp return 1
1077 b2c50a0a 2019-07-25 stsp fi
1078 b2c50a0a 2019-07-25 stsp
1079 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
1080 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
1081 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
1082 49c543a6 2022-03-31 naddy ret=$?
1083 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1084 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1085 b2c50a0a 2019-07-25 stsp return 1
1086 b2c50a0a 2019-07-25 stsp fi
1087 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1088 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1089 b2c50a0a 2019-07-25 stsp
1090 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1091 b2c50a0a 2019-07-25 stsp
1092 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1093 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1094 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1095 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1096 49c543a6 2022-03-31 naddy ret=$?
1097 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1098 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1099 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1100 b2c50a0a 2019-07-25 stsp return 1
1101 0160a755 2019-07-25 stsp fi
1102 b2c50a0a 2019-07-25 stsp
1103 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1104 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1105 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1106 49c543a6 2022-03-31 naddy ret=$?
1107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1108 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1109 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1110 b2c50a0a 2019-07-25 stsp return 1
1111 b2c50a0a 2019-07-25 stsp fi
1112 b2c50a0a 2019-07-25 stsp
1113 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1114 b2c50a0a 2019-07-25 stsp
1115 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1116 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1117 49c543a6 2022-03-31 naddy ret=$?
1118 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1119 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1120 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1121 b2c50a0a 2019-07-25 stsp return 1
1122 b2c50a0a 2019-07-25 stsp fi
1123 b2c50a0a 2019-07-25 stsp
1124 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1125 b2c50a0a 2019-07-25 stsp
1126 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1127 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1128 b2c50a0a 2019-07-25 stsp
1129 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1130 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1131 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1132 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1133 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1134 b2c50a0a 2019-07-25 stsp
1135 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1136 49c543a6 2022-03-31 naddy ret=$?
1137 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1138 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1139 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1140 b2c50a0a 2019-07-25 stsp return 1
1141 b2c50a0a 2019-07-25 stsp fi
1142 b2c50a0a 2019-07-25 stsp
1143 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1144 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1145 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1146 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1147 49c543a6 2022-03-31 naddy ret=$?
1148 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1149 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1150 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1151 b2c50a0a 2019-07-25 stsp return 1
1152 b2c50a0a 2019-07-25 stsp fi
1153 b2c50a0a 2019-07-25 stsp
1154 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1155 b2c50a0a 2019-07-25 stsp > $testroot/diff
1156 885e96df 2023-03-06 naddy ed -s $testroot/diff.expected <<-EOF
1157 885e96df 2023-03-06 naddy ,s/$old_commit1/$new_commit1/
1158 885e96df 2023-03-06 naddy w
1159 885e96df 2023-03-06 naddy EOF
1160 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1161 49c543a6 2022-03-31 naddy ret=$?
1162 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1163 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1164 b2c50a0a 2019-07-25 stsp fi
1165 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1166 0ebf8283 2019-07-24 stsp }
1167 c7d20a3f 2019-07-30 stsp
1168 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1169 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1170 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1171 c7d20a3f 2019-07-30 stsp
1172 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1176 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1177 c7d20a3f 2019-07-30 stsp return 1
1178 c7d20a3f 2019-07-30 stsp fi
1179 c7d20a3f 2019-07-30 stsp
1180 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1181 c7d20a3f 2019-07-30 stsp
1182 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1183 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1184 49c543a6 2022-03-31 naddy ret=$?
1185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1186 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1187 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1188 c7d20a3f 2019-07-30 stsp return 1
1189 c7d20a3f 2019-07-30 stsp fi
1190 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1191 0ebf8283 2019-07-24 stsp
1192 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1193 49c543a6 2022-03-31 naddy ret=$?
1194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1195 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1196 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1197 c7d20a3f 2019-07-30 stsp return 1
1198 c7d20a3f 2019-07-30 stsp fi
1199 c7d20a3f 2019-07-30 stsp
1200 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1201 49c543a6 2022-03-31 naddy ret=$?
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1204 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1205 c7d20a3f 2019-07-30 stsp return 1
1206 c7d20a3f 2019-07-30 stsp fi
1207 c7d20a3f 2019-07-30 stsp
1208 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1209 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1210 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1211 c7d20a3f 2019-07-30 stsp
1212 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1213 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1214 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1215 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1216 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1217 49c543a6 2022-03-31 naddy ret=$?
1218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1219 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1220 0def28b1 2019-08-17 stsp fi
1221 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1222 0def28b1 2019-08-17 stsp }
1223 0def28b1 2019-08-17 stsp
1224 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1225 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1226 0def28b1 2019-08-17 stsp
1227 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1228 0def28b1 2019-08-17 stsp
1229 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1230 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1231 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1232 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1233 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1234 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1235 0def28b1 2019-08-17 stsp
1236 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1237 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1238 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1239 0def28b1 2019-08-17 stsp
1240 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1241 49c543a6 2022-03-31 naddy ret=$?
1242 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1243 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1244 0def28b1 2019-08-17 stsp return 1
1245 0def28b1 2019-08-17 stsp fi
1246 0def28b1 2019-08-17 stsp
1247 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1248 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1249 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1250 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1251 0def28b1 2019-08-17 stsp
1252 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1253 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1254 0def28b1 2019-08-17 stsp
1255 49c543a6 2022-03-31 naddy ret=$?
1256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1257 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1258 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1259 0def28b1 2019-08-17 stsp return 1
1260 c7d20a3f 2019-07-30 stsp fi
1261 0def28b1 2019-08-17 stsp
1262 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1263 0def28b1 2019-08-17 stsp
1264 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1265 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1266 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1267 0def28b1 2019-08-17 stsp
1268 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1269 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1270 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1271 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1272 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1273 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1274 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1275 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1276 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1277 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1278 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1279 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1280 0def28b1 2019-08-17 stsp
1281 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1282 49c543a6 2022-03-31 naddy ret=$?
1283 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1284 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1285 0def28b1 2019-08-17 stsp fi
1286 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1287 c7d20a3f 2019-07-30 stsp }
1288 de05890f 2020-03-05 stsp
1289 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1290 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1291 de05890f 2020-03-05 stsp
1292 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1293 de05890f 2020-03-05 stsp
1294 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1295 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1296 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1297 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1298 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1299 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1300 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1301 de05890f 2020-03-05 stsp
1302 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1303 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1304 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1305 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1306 c7d20a3f 2019-07-30 stsp
1307 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1308 49c543a6 2022-03-31 naddy ret=$?
1309 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1310 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1311 de05890f 2020-03-05 stsp return 1
1312 de05890f 2020-03-05 stsp fi
1313 de05890f 2020-03-05 stsp
1314 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1315 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1316 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1317 de05890f 2020-03-05 stsp
1318 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1319 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1320 49c543a6 2022-03-31 naddy ret=$?
1321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1322 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1323 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1324 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1325 de05890f 2020-03-05 stsp return 1
1326 de05890f 2020-03-05 stsp fi
1327 de05890f 2020-03-05 stsp
1328 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1329 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1330 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1331 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1332 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1333 de05890f 2020-03-05 stsp
1334 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1335 49c543a6 2022-03-31 naddy ret=$?
1336 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1337 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1338 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1339 de05890f 2020-03-05 stsp return 1
1340 de05890f 2020-03-05 stsp fi
1341 de05890f 2020-03-05 stsp
1342 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1343 49c543a6 2022-03-31 naddy ret=$?
1344 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1345 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1346 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1347 de05890f 2020-03-05 stsp return 1
1348 de05890f 2020-03-05 stsp fi
1349 de05890f 2020-03-05 stsp
1350 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1351 49c543a6 2022-03-31 naddy ret=$?
1352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1353 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1354 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1355 de05890f 2020-03-05 stsp return 1
1356 de05890f 2020-03-05 stsp fi
1357 de05890f 2020-03-05 stsp
1358 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1359 49c543a6 2022-03-31 naddy ret=$?
1360 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1361 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1362 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1363 de05890f 2020-03-05 stsp return 1
1364 de05890f 2020-03-05 stsp fi
1365 de05890f 2020-03-05 stsp
1366 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1367 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1368 49c543a6 2022-03-31 naddy ret=$?
1369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1370 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1371 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1372 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1373 de05890f 2020-03-05 stsp return 1
1374 de05890f 2020-03-05 stsp fi
1375 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1376 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1377 de05890f 2020-03-05 stsp
1378 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1379 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1380 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1381 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1382 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1383 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1384 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1385 de05890f 2020-03-05 stsp
1386 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1387 49c543a6 2022-03-31 naddy ret=$?
1388 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1389 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1390 5b87815e 2020-03-05 stsp fi
1391 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1392 5b87815e 2020-03-05 stsp
1393 5b87815e 2020-03-05 stsp }
1394 5b87815e 2020-03-05 stsp
1395 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1396 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1397 5b87815e 2020-03-05 stsp
1398 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1399 5b87815e 2020-03-05 stsp
1400 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1401 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1402 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1403 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1404 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1405 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1406 5b87815e 2020-03-05 stsp
1407 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1408 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1409 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1410 5b87815e 2020-03-05 stsp
1411 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1412 49c543a6 2022-03-31 naddy ret=$?
1413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1414 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1415 5b87815e 2020-03-05 stsp return 1
1416 5b87815e 2020-03-05 stsp fi
1417 5b87815e 2020-03-05 stsp
1418 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1419 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1420 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1421 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1422 5b87815e 2020-03-05 stsp
1423 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1424 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1425 49c543a6 2022-03-31 naddy ret=$?
1426 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1427 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1428 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1429 ea4ee74a 2023-06-17 op test_done "$testroot" 1
1430 5b87815e 2020-03-05 stsp return 1
1431 de05890f 2020-03-05 stsp fi
1432 5b87815e 2020-03-05 stsp
1433 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1434 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1435 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1436 5b87815e 2020-03-05 stsp
1437 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1438 49c543a6 2022-03-31 naddy ret=$?
1439 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1440 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1441 5b87815e 2020-03-05 stsp fi
1442 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1443 de05890f 2020-03-05 stsp
1444 de05890f 2020-03-05 stsp }
1445 ecfff807 2020-09-23 stsp
1446 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1447 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1448 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1449 4c662b1d 2021-09-01 stsp local testroot=`test_init histedit_fold_add_delete`
1450 ecfff807 2020-09-23 stsp
1451 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1452 ecfff807 2020-09-23 stsp
1453 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1454 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1455 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1456 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1457 ecfff807 2020-09-23 stsp
1458 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1459 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1460 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1461 ecfff807 2020-09-23 stsp
1462 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1463 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1464 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1465 ecfff807 2020-09-23 stsp
1466 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1467 49c543a6 2022-03-31 naddy ret=$?
1468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1469 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1470 ecfff807 2020-09-23 stsp return 1
1471 ecfff807 2020-09-23 stsp fi
1472 de05890f 2020-03-05 stsp
1473 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1474 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1475 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1476 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1477 ecfff807 2020-09-23 stsp
1478 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1479 ecfff807 2020-09-23 stsp > $testroot/stdout)
1480 ecfff807 2020-09-23 stsp
1481 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1482 ecfff807 2020-09-23 stsp
1483 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1484 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1485 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1486 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1487 ecfff807 2020-09-23 stsp
1488 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1489 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1490 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1491 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1492 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1493 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1494 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1495 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1496 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1497 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1498 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1499 ecfff807 2020-09-23 stsp
1500 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1501 49c543a6 2022-03-31 naddy ret=$?
1502 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1503 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1504 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1505 ecfff807 2020-09-23 stsp return 1
1506 ecfff807 2020-09-23 stsp fi
1507 ecfff807 2020-09-23 stsp
1508 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1509 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1510 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1511 ecfff807 2020-09-23 stsp return 1
1512 ecfff807 2020-09-23 stsp fi
1513 ecfff807 2020-09-23 stsp
1514 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1515 ecfff807 2020-09-23 stsp
1516 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1517 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1518 49c543a6 2022-03-31 naddy ret=$?
1519 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1520 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1521 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1522 ecfff807 2020-09-23 stsp return 1
1523 ecfff807 2020-09-23 stsp fi
1524 ecfff807 2020-09-23 stsp
1525 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1526 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1527 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1528 49c543a6 2022-03-31 naddy ret=$?
1529 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1530 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1531 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1532 29c68398 2020-09-24 stsp return 1
1533 29c68398 2020-09-24 stsp fi
1534 29c68398 2020-09-24 stsp
1535 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1536 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1537 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1538 49c543a6 2022-03-31 naddy ret=$?
1539 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1540 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1541 15aed053 2023-03-07 naddy fi
1542 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1543 15aed053 2023-03-07 naddy }
1544 c2ba7aa6 2023-07-26 stsp
1545 c2ba7aa6 2023-07-26 stsp # if a previous commit edits a file, and it is folded into a commit
1546 c2ba7aa6 2023-07-26 stsp # that deletes the same file, the file will be deleted by histedit
1547 c2ba7aa6 2023-07-26 stsp test_histedit_fold_edit_delete() {
1548 c2ba7aa6 2023-07-26 stsp local testroot=`test_init histedit_fold_edit_delete`
1549 c2ba7aa6 2023-07-26 stsp
1550 c2ba7aa6 2023-07-26 stsp local orig_commit=`git_show_head $testroot/repo`
1551 c2ba7aa6 2023-07-26 stsp
1552 c2ba7aa6 2023-07-26 stsp echo "modify alpha" > $testroot/repo/alpha
1553 c2ba7aa6 2023-07-26 stsp (cd $testroot/repo && git add alpha)
1554 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "modified alpha"
1555 c2ba7aa6 2023-07-26 stsp local old_commit1=`git_show_head $testroot/repo`
1556 15aed053 2023-03-07 naddy
1557 c2ba7aa6 2023-07-26 stsp git_rm $testroot/repo alpha
1558 c2ba7aa6 2023-07-26 stsp git_commit $testroot/repo -m "deleted alpha"
1559 c2ba7aa6 2023-07-26 stsp local old_commit2=`git_show_head $testroot/repo`
1560 c2ba7aa6 2023-07-26 stsp
1561 c2ba7aa6 2023-07-26 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1562 c2ba7aa6 2023-07-26 stsp ret=$?
1563 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1564 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1565 c2ba7aa6 2023-07-26 stsp return 1
1566 c2ba7aa6 2023-07-26 stsp fi
1567 c2ba7aa6 2023-07-26 stsp
1568 c2ba7aa6 2023-07-26 stsp echo "fold $old_commit1" > $testroot/histedit-script
1569 c2ba7aa6 2023-07-26 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1570 c2ba7aa6 2023-07-26 stsp echo "mesg folded changes" >> $testroot/histedit-script
1571 c2ba7aa6 2023-07-26 stsp
1572 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1573 c2ba7aa6 2023-07-26 stsp > $testroot/stdout)
1574 c2ba7aa6 2023-07-26 stsp
1575 c2ba7aa6 2023-07-26 stsp local new_commit1=`git_show_head $testroot/repo`
1576 c2ba7aa6 2023-07-26 stsp
1577 c2ba7aa6 2023-07-26 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1578 c2ba7aa6 2023-07-26 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1579 c2ba7aa6 2023-07-26 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1580 c2ba7aa6 2023-07-26 stsp
1581 c2ba7aa6 2023-07-26 stsp echo "G alpha" >> $testroot/stdout.expected
1582 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit1 -> fold commit: modified alpha" \
1583 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1584 c2ba7aa6 2023-07-26 stsp echo "D alpha" >> $testroot/stdout.expected
1585 c2ba7aa6 2023-07-26 stsp echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1586 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1587 c2ba7aa6 2023-07-26 stsp echo "Switching work tree to refs/heads/master" \
1588 c2ba7aa6 2023-07-26 stsp >> $testroot/stdout.expected
1589 c2ba7aa6 2023-07-26 stsp
1590 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1591 c2ba7aa6 2023-07-26 stsp ret=$?
1592 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1593 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1594 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1595 c2ba7aa6 2023-07-26 stsp return 1
1596 c2ba7aa6 2023-07-26 stsp fi
1597 c2ba7aa6 2023-07-26 stsp
1598 c2ba7aa6 2023-07-26 stsp if [ -e $testroot/wt/alpha ]; then
1599 c2ba7aa6 2023-07-26 stsp echo "removed file alpha still exists on disk" >&2
1600 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "1"
1601 c2ba7aa6 2023-07-26 stsp return 1
1602 c2ba7aa6 2023-07-26 stsp fi
1603 c2ba7aa6 2023-07-26 stsp
1604 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got status > $testroot/stdout)
1605 c2ba7aa6 2023-07-26 stsp
1606 c2ba7aa6 2023-07-26 stsp echo -n > $testroot/stdout.expected
1607 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1608 c2ba7aa6 2023-07-26 stsp ret=$?
1609 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1610 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1611 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1612 c2ba7aa6 2023-07-26 stsp return 1
1613 c2ba7aa6 2023-07-26 stsp fi
1614 c2ba7aa6 2023-07-26 stsp
1615 c2ba7aa6 2023-07-26 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
1616 c2ba7aa6 2023-07-26 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1617 c2ba7aa6 2023-07-26 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1618 c2ba7aa6 2023-07-26 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1619 c2ba7aa6 2023-07-26 stsp ret=$?
1620 c2ba7aa6 2023-07-26 stsp if [ $ret -ne 0 ]; then
1621 c2ba7aa6 2023-07-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
1622 c2ba7aa6 2023-07-26 stsp fi
1623 c2ba7aa6 2023-07-26 stsp
1624 c2ba7aa6 2023-07-26 stsp test_done "$testroot" "$ret"
1625 c2ba7aa6 2023-07-26 stsp }
1626 c2ba7aa6 2023-07-26 stsp
1627 15aed053 2023-03-07 naddy test_histedit_fold_delete_add() {
1628 15aed053 2023-03-07 naddy local testroot=`test_init histedit_fold_delete_add`
1629 15aed053 2023-03-07 naddy
1630 15aed053 2023-03-07 naddy local orig_commit=`git_show_head $testroot/repo`
1631 15aed053 2023-03-07 naddy
1632 15aed053 2023-03-07 naddy (cd $testroot/repo && git rm -q alpha)
1633 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "removing alpha"
1634 15aed053 2023-03-07 naddy local old_commit1=`git_show_head $testroot/repo`
1635 15aed053 2023-03-07 naddy
1636 15aed053 2023-03-07 naddy echo "modified alpha" >$testroot/repo/alpha
1637 15aed053 2023-03-07 naddy (cd $testroot/repo && git add alpha)
1638 15aed053 2023-03-07 naddy git_commit $testroot/repo -m "add back modified alpha"
1639 15aed053 2023-03-07 naddy local old_commit2=`git_show_head $testroot/repo`
1640 15aed053 2023-03-07 naddy
1641 15aed053 2023-03-07 naddy got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1642 15aed053 2023-03-07 naddy ret=$?
1643 15aed053 2023-03-07 naddy if [ $ret -ne 0 ]; then
1644 15aed053 2023-03-07 naddy test_done "$testroot" "$ret"
1645 15aed053 2023-03-07 naddy return 1
1646 15aed053 2023-03-07 naddy fi
1647 15aed053 2023-03-07 naddy
1648 15aed053 2023-03-07 naddy echo "fold $old_commit1" > $testroot/histedit-script
1649 15aed053 2023-03-07 naddy echo "pick $old_commit2" >> $testroot/histedit-script
1650 15aed053 2023-03-07 naddy echo "mesg folded changes" >> $testroot/histedit-script
1651 15aed053 2023-03-07 naddy
1652 15aed053 2023-03-07 naddy (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1653 15aed053 2023-03-07 naddy > $testroot/stdout)
1654 15aed053 2023-03-07 naddy
1655 15aed053 2023-03-07 naddy local new_commit1=`git_show_head $testroot/repo`
1656 15aed053 2023-03-07 naddy
1657 15aed053 2023-03-07 naddy local short_old_commit1=`trim_obj_id 28 $old_commit1`
1658 15aed053 2023-03-07 naddy local short_old_commit2=`trim_obj_id 28 $old_commit2`
1659 15aed053 2023-03-07 naddy local short_new_commit1=`trim_obj_id 28 $new_commit1`
1660 15aed053 2023-03-07 naddy
1661 15aed053 2023-03-07 naddy echo "D alpha" > $testroot/stdout.expected
1662 15aed053 2023-03-07 naddy echo "$short_old_commit1 -> fold commit: removing alpha" \
1663 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1664 15aed053 2023-03-07 naddy echo "A alpha" >> $testroot/stdout.expected
1665 15aed053 2023-03-07 naddy echo "$short_old_commit2 -> $short_new_commit1: folded changes" \
1666 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1667 15aed053 2023-03-07 naddy echo "Switching work tree to refs/heads/master" \
1668 15aed053 2023-03-07 naddy >> $testroot/stdout.expected
1669 15aed053 2023-03-07 naddy
1670 9a298e5c 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1671 9a298e5c 2023-03-10 stsp ret=$?
1672 9a298e5c 2023-03-10 stsp if [ $ret -ne 0 ]; then
1673 9a298e5c 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1674 9a298e5c 2023-03-10 stsp test_done "$testroot" "$ret"
1675 9a298e5c 2023-03-10 stsp return 1
1676 9a298e5c 2023-03-10 stsp fi
1677 15aed053 2023-03-07 naddy
1678 15aed053 2023-03-07 naddy if [ ! -e $testroot/wt/alpha ]; then
1679 9a298e5c 2023-03-10 stsp echo "file alpha is missing on disk" >&2
1680 9a298e5c 2023-03-10 stsp test_done "$testroot" "1"
1681 5fdcbbb6 2023-03-14 naddy return 1
1682 5fdcbbb6 2023-03-14 naddy fi
1683 5fdcbbb6 2023-03-14 naddy
1684 5fdcbbb6 2023-03-14 naddy echo "modified alpha" > $testroot/content.expected
1685 5fdcbbb6 2023-03-14 naddy cat $testroot/wt/alpha > $testroot/content
1686 5fdcbbb6 2023-03-14 naddy cmp -s $testroot/content.expected $testroot/content
1687 5fdcbbb6 2023-03-14 naddy ret=$?
1688 5fdcbbb6 2023-03-14 naddy if [ $ret -ne 0 ]; then
1689 5fdcbbb6 2023-03-14 naddy diff -u $testroot/content.expected $testroot/content
1690 5fdcbbb6 2023-03-14 naddy test_done "$testroot" "$ret"
1691 9a298e5c 2023-03-10 stsp return 1
1692 ecfff807 2020-09-23 stsp fi
1693 9a298e5c 2023-03-10 stsp test_done "$testroot" "0"
1694 ecfff807 2020-09-23 stsp }
1695 239f5c5a 2020-12-13 stsp
1696 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1697 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1698 239f5c5a 2020-12-13 stsp
1699 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1700 239f5c5a 2020-12-13 stsp
1701 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1702 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1703 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1704 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1705 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1706 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1707 239f5c5a 2020-12-13 stsp
1708 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1709 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1710 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1711 239f5c5a 2020-12-13 stsp
1712 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1713 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1714 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1715 239f5c5a 2020-12-13 stsp
1716 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1717 49c543a6 2022-03-31 naddy ret=$?
1718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1719 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1720 239f5c5a 2020-12-13 stsp return 1
1721 239f5c5a 2020-12-13 stsp fi
1722 239f5c5a 2020-12-13 stsp
1723 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1724 239f5c5a 2020-12-13 stsp #!/bin/sh
1725 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1726 885e96df 2023-03-06 naddy ,s/.*/committing folded changes/
1727 885e96df 2023-03-06 naddy w
1728 885e96df 2023-03-06 naddy EOF
1729 239f5c5a 2020-12-13 stsp EOF
1730 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1731 239f5c5a 2020-12-13 stsp
1732 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1733 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1734 239f5c5a 2020-12-13 stsp
1735 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1736 239f5c5a 2020-12-13 stsp
1737 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1738 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1739 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1740 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1741 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1742 239f5c5a 2020-12-13 stsp
1743 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1744 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1745 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1746 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1747 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1748 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1749 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1750 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1751 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1752 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1753 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1754 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1755 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1756 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1757 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1758 ecfff807 2020-09-23 stsp
1759 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1760 49c543a6 2022-03-31 naddy ret=$?
1761 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1762 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1763 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1764 239f5c5a 2020-12-13 stsp return 1
1765 239f5c5a 2020-12-13 stsp fi
1766 ecfff807 2020-09-23 stsp
1767 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1768 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1769 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1770 49c543a6 2022-03-31 naddy ret=$?
1771 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1772 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1773 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1774 239f5c5a 2020-12-13 stsp return 1
1775 239f5c5a 2020-12-13 stsp fi
1776 239f5c5a 2020-12-13 stsp
1777 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1778 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1779 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1780 239f5c5a 2020-12-13 stsp return 1
1781 239f5c5a 2020-12-13 stsp fi
1782 239f5c5a 2020-12-13 stsp
1783 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1784 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1785 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1786 49c543a6 2022-03-31 naddy ret=$?
1787 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1788 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1789 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1790 239f5c5a 2020-12-13 stsp return 1
1791 239f5c5a 2020-12-13 stsp fi
1792 239f5c5a 2020-12-13 stsp
1793 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1794 239f5c5a 2020-12-13 stsp
1795 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1796 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1797 49c543a6 2022-03-31 naddy ret=$?
1798 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1799 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1800 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1801 239f5c5a 2020-12-13 stsp return 1
1802 239f5c5a 2020-12-13 stsp fi
1803 239f5c5a 2020-12-13 stsp
1804 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1805 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1806 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1807 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1808 49c543a6 2022-03-31 naddy ret=$?
1809 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1810 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1811 239f5c5a 2020-12-13 stsp fi
1812 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1813 239f5c5a 2020-12-13 stsp }
1814 a347e6bb 2020-12-13 stsp
1815 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1816 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1817 a347e6bb 2020-12-13 stsp
1818 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1819 a347e6bb 2020-12-13 stsp
1820 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1821 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1822 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1823 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1824 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1825 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1826 239f5c5a 2020-12-13 stsp
1827 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1828 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1829 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1830 a347e6bb 2020-12-13 stsp
1831 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1832 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1833 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1834 a347e6bb 2020-12-13 stsp
1835 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1836 49c543a6 2022-03-31 naddy ret=$?
1837 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1838 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1839 a347e6bb 2020-12-13 stsp return 1
1840 a347e6bb 2020-12-13 stsp fi
1841 a347e6bb 2020-12-13 stsp
1842 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1843 a347e6bb 2020-12-13 stsp #!/bin/sh
1844 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1845 885e96df 2023-03-06 naddy ,d
1846 885e96df 2023-03-06 naddy w
1847 885e96df 2023-03-06 naddy EOF
1848 a347e6bb 2020-12-13 stsp EOF
1849 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1850 a347e6bb 2020-12-13 stsp
1851 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1852 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1853 a347e6bb 2020-12-13 stsp
1854 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1855 a347e6bb 2020-12-13 stsp
1856 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1857 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1858 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1859 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1860 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1861 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1862 a347e6bb 2020-12-13 stsp
1863 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1864 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1865 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1866 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1867 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1868 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1869 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1870 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1871 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1872 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1873 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1874 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1875 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1876 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1877 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1878 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1879 a347e6bb 2020-12-13 stsp
1880 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1881 49c543a6 2022-03-31 naddy ret=$?
1882 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1883 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1884 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1885 a347e6bb 2020-12-13 stsp return 1
1886 a347e6bb 2020-12-13 stsp fi
1887 a347e6bb 2020-12-13 stsp
1888 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1889 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1890 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1891 49c543a6 2022-03-31 naddy ret=$?
1892 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1893 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1894 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1895 a347e6bb 2020-12-13 stsp return 1
1896 a347e6bb 2020-12-13 stsp fi
1897 a347e6bb 2020-12-13 stsp
1898 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1899 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1900 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1901 a347e6bb 2020-12-13 stsp return 1
1902 a347e6bb 2020-12-13 stsp fi
1903 a347e6bb 2020-12-13 stsp
1904 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1905 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1906 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1907 49c543a6 2022-03-31 naddy ret=$?
1908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1909 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1910 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1911 a347e6bb 2020-12-13 stsp return 1
1912 a347e6bb 2020-12-13 stsp fi
1913 a347e6bb 2020-12-13 stsp
1914 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1915 a347e6bb 2020-12-13 stsp
1916 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1917 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1918 49c543a6 2022-03-31 naddy ret=$?
1919 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1920 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1921 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1922 a347e6bb 2020-12-13 stsp return 1
1923 a347e6bb 2020-12-13 stsp fi
1924 a347e6bb 2020-12-13 stsp
1925 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1926 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1927 b93c7142 2021-10-01 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1928 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1929 49c543a6 2022-03-31 naddy ret=$?
1930 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1931 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1932 b93c7142 2021-10-01 stsp fi
1933 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1934 b93c7142 2021-10-01 stsp }
1935 b93c7142 2021-10-01 stsp
1936 b93c7142 2021-10-01 stsp test_histedit_edit_only() {
1937 b93c7142 2021-10-01 stsp local testroot=`test_init histedit_edit_only`
1938 b93c7142 2021-10-01 stsp
1939 b93c7142 2021-10-01 stsp local orig_commit=`git_show_head $testroot/repo`
1940 b93c7142 2021-10-01 stsp
1941 b93c7142 2021-10-01 stsp echo "modified alpha on master" > $testroot/repo/alpha
1942 b93c7142 2021-10-01 stsp (cd $testroot/repo && git rm -q beta)
1943 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/repo/epsilon/new
1944 b93c7142 2021-10-01 stsp (cd $testroot/repo && git add epsilon/new)
1945 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing changes"
1946 b93c7142 2021-10-01 stsp local old_commit1=`git_show_head $testroot/repo`
1947 b93c7142 2021-10-01 stsp
1948 b93c7142 2021-10-01 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1949 b93c7142 2021-10-01 stsp git_commit $testroot/repo -m "committing to zeta on master"
1950 b93c7142 2021-10-01 stsp local old_commit2=`git_show_head $testroot/repo`
1951 b93c7142 2021-10-01 stsp
1952 b93c7142 2021-10-01 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1953 49c543a6 2022-03-31 naddy ret=$?
1954 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1955 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1956 b93c7142 2021-10-01 stsp return 1
1957 b93c7142 2021-10-01 stsp fi
1958 b93c7142 2021-10-01 stsp
1959 b93c7142 2021-10-01 stsp (cd $testroot/wt && got histedit -e > $testroot/stdout)
1960 b93c7142 2021-10-01 stsp
1961 b93c7142 2021-10-01 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1962 b93c7142 2021-10-01 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1963 b93c7142 2021-10-01 stsp
1964 b93c7142 2021-10-01 stsp echo "G alpha" > $testroot/stdout.expected
1965 b93c7142 2021-10-01 stsp echo "D beta" >> $testroot/stdout.expected
1966 b93c7142 2021-10-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1967 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit1" \
1968 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
1969 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1970 49c543a6 2022-03-31 naddy ret=$?
1971 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1972 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
1973 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
1974 b93c7142 2021-10-01 stsp return 1
1975 b93c7142 2021-10-01 stsp fi
1976 b93c7142 2021-10-01 stsp
1977 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
1978 b93c7142 2021-10-01 stsp
1979 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
1980 b93c7142 2021-10-01 stsp #!/bin/sh
1981 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1982 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 1/
1983 885e96df 2023-03-06 naddy w
1984 885e96df 2023-03-06 naddy EOF
1985 b93c7142 2021-10-01 stsp EOF
1986 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
1987 b93c7142 2021-10-01 stsp
1988 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1989 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
1990 b93c7142 2021-10-01 stsp
1991 b93c7142 2021-10-01 stsp local new_commit1=$(cd $testroot/wt && got info | \
1992 b93c7142 2021-10-01 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1993 b93c7142 2021-10-01 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1994 b93c7142 2021-10-01 stsp
1995 b93c7142 2021-10-01 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1996 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
1997 b93c7142 2021-10-01 stsp echo "committing edited changes 1" >> $testroot/stdout.expected
1998 b93c7142 2021-10-01 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1999 b93c7142 2021-10-01 stsp echo "Stopping histedit for amending commit $old_commit2" \
2000 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2001 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2002 49c543a6 2022-03-31 naddy ret=$?
2003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2004 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2005 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2006 b93c7142 2021-10-01 stsp return 1
2007 b93c7142 2021-10-01 stsp fi
2008 b93c7142 2021-10-01 stsp
2009 b93c7142 2021-10-01 stsp echo "edited zeta on master" > $testroot/wt/epsilon/zeta
2010 b93c7142 2021-10-01 stsp
2011 b93c7142 2021-10-01 stsp cat > $testroot/editor.sh <<EOF
2012 b93c7142 2021-10-01 stsp #!/bin/sh
2013 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2014 885e96df 2023-03-06 naddy ,s/.*/committing edited changes 2/
2015 885e96df 2023-03-06 naddy w
2016 885e96df 2023-03-06 naddy EOF
2017 b93c7142 2021-10-01 stsp EOF
2018 b93c7142 2021-10-01 stsp chmod +x $testroot/editor.sh
2019 b93c7142 2021-10-01 stsp
2020 b93c7142 2021-10-01 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
2021 b93c7142 2021-10-01 stsp VISUAL="$testroot/editor.sh" got histedit -c > $testroot/stdout)
2022 b93c7142 2021-10-01 stsp
2023 b93c7142 2021-10-01 stsp local new_commit2=`git_show_head $testroot/repo`
2024 b93c7142 2021-10-01 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
2025 b93c7142 2021-10-01 stsp
2026 b93c7142 2021-10-01 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
2027 b93c7142 2021-10-01 stsp > $testroot/stdout.expected
2028 b93c7142 2021-10-01 stsp echo "committing edited changes 2" >> $testroot/stdout.expected
2029 b93c7142 2021-10-01 stsp echo "Switching work tree to refs/heads/master" \
2030 b93c7142 2021-10-01 stsp >> $testroot/stdout.expected
2031 b93c7142 2021-10-01 stsp
2032 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2033 49c543a6 2022-03-31 naddy ret=$?
2034 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2035 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2036 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2037 b93c7142 2021-10-01 stsp return 1
2038 b93c7142 2021-10-01 stsp fi
2039 b93c7142 2021-10-01 stsp
2040 b93c7142 2021-10-01 stsp echo "edited modified alpha on master" > $testroot/content.expected
2041 b93c7142 2021-10-01 stsp cat $testroot/wt/alpha > $testroot/content
2042 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2043 49c543a6 2022-03-31 naddy ret=$?
2044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2045 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2046 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2047 b93c7142 2021-10-01 stsp return 1
2048 b93c7142 2021-10-01 stsp fi
2049 b93c7142 2021-10-01 stsp
2050 b93c7142 2021-10-01 stsp if [ -e $testroot/wt/beta ]; then
2051 b93c7142 2021-10-01 stsp echo "removed file beta still exists on disk" >&2
2052 b93c7142 2021-10-01 stsp test_done "$testroot" "1"
2053 b93c7142 2021-10-01 stsp return 1
2054 b93c7142 2021-10-01 stsp fi
2055 b93c7142 2021-10-01 stsp
2056 b93c7142 2021-10-01 stsp echo "new file on master" > $testroot/content.expected
2057 b93c7142 2021-10-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
2058 b93c7142 2021-10-01 stsp cmp -s $testroot/content.expected $testroot/content
2059 49c543a6 2022-03-31 naddy ret=$?
2060 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2061 b93c7142 2021-10-01 stsp diff -u $testroot/content.expected $testroot/content
2062 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2063 b93c7142 2021-10-01 stsp return 1
2064 b93c7142 2021-10-01 stsp fi
2065 b93c7142 2021-10-01 stsp
2066 b93c7142 2021-10-01 stsp (cd $testroot/wt && got status > $testroot/stdout)
2067 b93c7142 2021-10-01 stsp
2068 b93c7142 2021-10-01 stsp echo -n > $testroot/stdout.expected
2069 b93c7142 2021-10-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2070 49c543a6 2022-03-31 naddy ret=$?
2071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2072 b93c7142 2021-10-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
2073 b93c7142 2021-10-01 stsp test_done "$testroot" "$ret"
2074 b93c7142 2021-10-01 stsp return 1
2075 b93c7142 2021-10-01 stsp fi
2076 b93c7142 2021-10-01 stsp
2077 b93c7142 2021-10-01 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
2078 b93c7142 2021-10-01 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
2079 b93c7142 2021-10-01 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
2080 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
2081 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2082 49c543a6 2022-03-31 naddy ret=$?
2083 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2084 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
2085 a347e6bb 2020-12-13 stsp fi
2086 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
2087 a347e6bb 2020-12-13 stsp }
2088 09209b8a 2021-10-08 stsp
2089 09209b8a 2021-10-08 stsp test_histedit_prepend_line() {
2090 09209b8a 2021-10-08 stsp local testroot=`test_init histedit_prepend_line`
2091 09209b8a 2021-10-08 stsp local orig_commit=`git_show_head $testroot/repo`
2092 09209b8a 2021-10-08 stsp
2093 09209b8a 2021-10-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2094 09209b8a 2021-10-08 stsp
2095 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/alpha" <<EOF
2096 b4e0802f 2021-10-14 naddy 1i
2097 09209b8a 2021-10-08 stsp first line
2098 09209b8a 2021-10-08 stsp .
2099 09209b8a 2021-10-08 stsp wq
2100 09209b8a 2021-10-08 stsp EOF
2101 09209b8a 2021-10-08 stsp
2102 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content.expected
2103 a347e6bb 2020-12-13 stsp
2104 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2105 09209b8a 2021-10-08 stsp alpha > /dev/null)
2106 49c543a6 2022-03-31 naddy ret=$?
2107 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2108 09209b8a 2021-10-08 stsp echo "got commit failed unexpectedly" >&2
2109 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2110 09209b8a 2021-10-08 stsp return 1
2111 09209b8a 2021-10-08 stsp fi
2112 09209b8a 2021-10-08 stsp
2113 09209b8a 2021-10-08 stsp local top_commit=`git_show_head $testroot/repo`
2114 09209b8a 2021-10-08 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2115 09209b8a 2021-10-08 stsp
2116 09209b8a 2021-10-08 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2117 49c543a6 2022-03-31 naddy ret=$?
2118 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2119 09209b8a 2021-10-08 stsp echo "got update failed unexpectedly" >&2
2120 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2121 09209b8a 2021-10-08 stsp return 1
2122 09209b8a 2021-10-08 stsp fi
2123 09209b8a 2021-10-08 stsp
2124 09209b8a 2021-10-08 stsp (cd $testroot/wt && got histedit -F "$testroot/histedit-script" \
2125 09209b8a 2021-10-08 stsp > /dev/null)
2126 49c543a6 2022-03-31 naddy ret=$?
2127 09209b8a 2021-10-08 stsp if [ "$?" != 0 ]; then
2128 09209b8a 2021-10-08 stsp echo "got histedit failed unexpectedly" >&2
2129 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2130 09209b8a 2021-10-08 stsp return 1
2131 09209b8a 2021-10-08 stsp fi
2132 09209b8a 2021-10-08 stsp
2133 09209b8a 2021-10-08 stsp cp $testroot/wt/alpha $testroot/content
2134 09209b8a 2021-10-08 stsp cmp -s $testroot/content.expected $testroot/content
2135 49c543a6 2022-03-31 naddy ret=$?
2136 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2137 09209b8a 2021-10-08 stsp diff -u $testroot/content.expected $testroot/content
2138 09209b8a 2021-10-08 stsp test_done "$testroot" "$ret"
2139 09209b8a 2021-10-08 stsp return 1
2140 09209b8a 2021-10-08 stsp fi
2141 09209b8a 2021-10-08 stsp
2142 09209b8a 2021-10-08 stsp test_done "$testroot" $ret
2143 09209b8a 2021-10-08 stsp }
2144 f1e5aff4 2022-07-12 op
2145 f1e5aff4 2022-07-12 op test_histedit_mesg_invalid() {
2146 f1e5aff4 2022-07-12 op local testroot=`test_init mesg_invalid`
2147 f1e5aff4 2022-07-12 op
2148 f1e5aff4 2022-07-12 op local orig_commit=`git_show_head $testroot/repo`
2149 f1e5aff4 2022-07-12 op
2150 f1e5aff4 2022-07-12 op echo "modified alpha on master" > $testroot/repo/alpha
2151 f1e5aff4 2022-07-12 op (cd $testroot/repo && git rm -q beta)
2152 f1e5aff4 2022-07-12 op echo "new file on master" > $testroot/repo/epsilon/new
2153 f1e5aff4 2022-07-12 op (cd $testroot/repo && git add epsilon/new)
2154 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing changes'
2155 f1e5aff4 2022-07-12 op local old_commit1=`git_show_head $testroot/repo`
2156 f1e5aff4 2022-07-12 op
2157 f1e5aff4 2022-07-12 op echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2158 f1e5aff4 2022-07-12 op git_commit $testroot/repo -m 'committing to zeto on master'
2159 f1e5aff4 2022-07-12 op local old_commit2=`git_show_head $testroot/repo`
2160 f1e5aff4 2022-07-12 op
2161 f1e5aff4 2022-07-12 op got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2162 f1e5aff4 2022-07-12 op ret=$?
2163 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2164 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2165 97f28afb 2022-07-20 op return 1
2166 f1e5aff4 2022-07-12 op fi
2167 f1e5aff4 2022-07-12 op
2168 f1e5aff4 2022-07-12 op # try with a leading mesg
2169 f1e5aff4 2022-07-12 op
2170 f1e5aff4 2022-07-12 op echo "mesg something something" > $testroot/histedit-script
2171 f1e5aff4 2022-07-12 op echo "pick $old_commit1" >> $testroot/histedit-script
2172 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2173 f1e5aff4 2022-07-12 op
2174 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2175 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2176 f1e5aff4 2022-07-12 op ret=$?
2177 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2178 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2179 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2180 f1e5aff4 2022-07-12 op return 1
2181 f1e5aff4 2022-07-12 op fi
2182 09209b8a 2021-10-08 stsp
2183 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2184 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2185 f1e5aff4 2022-07-12 op ret=$?
2186 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2187 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2188 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2189 f1e5aff4 2022-07-12 op return 1
2190 f1e5aff4 2022-07-12 op fi
2191 f1e5aff4 2022-07-12 op
2192 f1e5aff4 2022-07-12 op # try again with mesg -> mesg
2193 f1e5aff4 2022-07-12 op
2194 f1e5aff4 2022-07-12 op echo "pick $old_commit1" > $testroot/histedit-script
2195 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2196 f1e5aff4 2022-07-12 op echo "mesg something something else" >> $testroot/histedit-script
2197 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2198 f1e5aff4 2022-07-12 op
2199 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2200 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2201 f1e5aff4 2022-07-12 op ret=$?
2202 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2203 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2204 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2205 f1e5aff4 2022-07-12 op return 1
2206 f1e5aff4 2022-07-12 op fi
2207 f1e5aff4 2022-07-12 op
2208 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2209 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2210 f1e5aff4 2022-07-12 op ret=$?
2211 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2212 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2213 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2214 f1e5aff4 2022-07-12 op return 1
2215 f1e5aff4 2022-07-12 op fi
2216 f1e5aff4 2022-07-12 op
2217 f1e5aff4 2022-07-12 op # try again with drop -> mesg
2218 f1e5aff4 2022-07-12 op
2219 f1e5aff4 2022-07-12 op echo "drop $old_commit1" > $testroot/histedit-script
2220 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2221 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2222 f1e5aff4 2022-07-12 op
2223 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2224 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2225 f1e5aff4 2022-07-12 op ret=$?
2226 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2227 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2228 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2229 f1e5aff4 2022-07-12 op return 1
2230 f1e5aff4 2022-07-12 op fi
2231 f1e5aff4 2022-07-12 op
2232 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2233 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2234 f1e5aff4 2022-07-12 op ret=$?
2235 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2236 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2237 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2238 f1e5aff4 2022-07-12 op return 1
2239 f1e5aff4 2022-07-12 op fi
2240 f1e5aff4 2022-07-12 op
2241 f1e5aff4 2022-07-12 op # try again with fold -> mesg
2242 f1e5aff4 2022-07-12 op
2243 f1e5aff4 2022-07-12 op echo "fold $old_commit1" > $testroot/histedit-script
2244 f1e5aff4 2022-07-12 op echo "mesg something something" >> $testroot/histedit-script
2245 f1e5aff4 2022-07-12 op echo "pick $old_commit2" >> $testroot/histedit-script
2246 f1e5aff4 2022-07-12 op
2247 f1e5aff4 2022-07-12 op (cd $testroot/wt && got histedit -F $testroot/histedit-script \
2248 f1e5aff4 2022-07-12 op > $testroot/stdout 2> $testroot/stderr)
2249 f1e5aff4 2022-07-12 op ret=$?
2250 f1e5aff4 2022-07-12 op if [ $ret -eq 0 ]; then
2251 f1e5aff4 2022-07-12 op echo "histedit succeeded unexpectedly" >&2
2252 f1e5aff4 2022-07-12 op test_done "$testroot" 1
2253 f1e5aff4 2022-07-12 op return 1
2254 f1e5aff4 2022-07-12 op fi
2255 f1e5aff4 2022-07-12 op
2256 f1e5aff4 2022-07-12 op echo "got: bad histedit command" > $testroot/stderr.expected
2257 f1e5aff4 2022-07-12 op cmp -s $testroot/stderr.expected $testroot/stderr
2258 f1e5aff4 2022-07-12 op ret=$?
2259 f1e5aff4 2022-07-12 op if [ $ret -ne 0 ]; then
2260 f1e5aff4 2022-07-12 op diff -u $testroot/stderr.expected $testroot/stderr
2261 f1e5aff4 2022-07-12 op fi
2262 f1e5aff4 2022-07-12 op test_done "$testroot" $ret
2263 598eac43 2022-07-22 stsp }
2264 598eac43 2022-07-22 stsp
2265 598eac43 2022-07-22 stsp test_histedit_resets_committer() {
2266 598eac43 2022-07-22 stsp local testroot=`test_init histedit_resets_committer`
2267 598eac43 2022-07-22 stsp local orig_commit=`git_show_head $testroot/repo`
2268 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
2269 598eac43 2022-07-22 stsp
2270 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2271 598eac43 2022-07-22 stsp
2272 598eac43 2022-07-22 stsp echo "modified alpha" > $testroot/wt/alpha
2273 598eac43 2022-07-22 stsp
2274 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got commit -m 'modified alpha on master' \
2275 598eac43 2022-07-22 stsp alpha > /dev/null)
2276 598eac43 2022-07-22 stsp ret=$?
2277 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2278 598eac43 2022-07-22 stsp echo "got commit failed unexpectedly" >&2
2279 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2280 598eac43 2022-07-22 stsp return 1
2281 598eac43 2022-07-22 stsp fi
2282 598eac43 2022-07-22 stsp
2283 598eac43 2022-07-22 stsp local top_commit=`git_show_head $testroot/repo`
2284 598eac43 2022-07-22 stsp echo "pick $top_commit" > "$testroot/histedit-script"
2285 598eac43 2022-07-22 stsp
2286 598eac43 2022-07-22 stsp (cd $testroot/wt/ && got update -c $orig_commit > /dev/null)
2287 598eac43 2022-07-22 stsp ret=$?
2288 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2289 598eac43 2022-07-22 stsp echo "got update failed unexpectedly" >&2
2290 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2291 598eac43 2022-07-22 stsp return 1
2292 598eac43 2022-07-22 stsp fi
2293 598eac43 2022-07-22 stsp
2294 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
2295 598eac43 2022-07-22 stsp got histedit -F "$testroot/histedit-script" > /dev/null)
2296 598eac43 2022-07-22 stsp ret=$?
2297 598eac43 2022-07-22 stsp if [ "$?" != 0 ]; then
2298 598eac43 2022-07-22 stsp echo "got histedit failed unexpectedly" >&2
2299 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2300 598eac43 2022-07-22 stsp return 1
2301 598eac43 2022-07-22 stsp fi
2302 598eac43 2022-07-22 stsp local edited_commit=`git_show_head $testroot/repo`
2303 598eac43 2022-07-22 stsp
2304 598eac43 2022-07-22 stsp # Original commit only had one author
2305 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $top_commit | \
2306 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2307 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2308 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2309 598eac43 2022-07-22 stsp ret=$?
2310 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2311 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2312 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2313 598eac43 2022-07-22 stsp return 1
2314 598eac43 2022-07-22 stsp fi
2315 598eac43 2022-07-22 stsp
2316 598eac43 2022-07-22 stsp # Edited commit should have new committer name added
2317 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $edited_commit | \
2318 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
2319 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
2320 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
2321 598eac43 2022-07-22 stsp
2322 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2323 598eac43 2022-07-22 stsp ret=$?
2324 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
2325 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
2326 598eac43 2022-07-22 stsp fi
2327 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
2328 f1e5aff4 2022-07-12 op }
2329 b2b3fce1 2022-10-29 op
2330 b2b3fce1 2022-10-29 op test_histedit_umask() {
2331 b2b3fce1 2022-10-29 op local testroot=`test_init histedit_umask`
2332 b2b3fce1 2022-10-29 op local orig_commit=`git_show_head "$testroot/repo"`
2333 b2b3fce1 2022-10-29 op
2334 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
2335 b2b3fce1 2022-10-29 op
2336 b2b3fce1 2022-10-29 op echo "modified alpha" > $testroot/wt/alpha
2337 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #1') >/dev/null
2338 b2b3fce1 2022-10-29 op local commit1=`git_show_head "$testroot/repo"`
2339 b2b3fce1 2022-10-29 op
2340 b2b3fce1 2022-10-29 op echo "modified again" > $testroot/wt/alpha
2341 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #2') >/dev/null
2342 b2b3fce1 2022-10-29 op local commit2=`git_show_head "$testroot/repo"`
2343 b2b3fce1 2022-10-29 op
2344 b2b3fce1 2022-10-29 op echo "modified again!" > $testroot/wt/alpha
2345 b2b3fce1 2022-10-29 op echo "modify beta too!" > $testroot/wt/beta
2346 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'edit #3') >/dev/null
2347 b2b3fce1 2022-10-29 op local commit3=`git_show_head "$testroot/repo"`
2348 f1e5aff4 2022-07-12 op
2349 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -c "$orig_commit") >/dev/null
2350 b2b3fce1 2022-10-29 op ret=$?
2351 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2352 b2b3fce1 2022-10-29 op echo "update to $orig_commit failed!" >&2
2353 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2354 b2b3fce1 2022-10-29 op return 1
2355 b2b3fce1 2022-10-29 op fi
2356 b2b3fce1 2022-10-29 op
2357 b2b3fce1 2022-10-29 op echo fold $commit1 >$testroot/histedit-script
2358 b2b3fce1 2022-10-29 op echo fold $commit2 >>$testroot/histedit-script
2359 b2b3fce1 2022-10-29 op echo pick $commit3 >>$testroot/histedit-script
2360 b2b3fce1 2022-10-29 op echo mesg folding changes >>$testroot/histedit-script
2361 b2b3fce1 2022-10-29 op
2362 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
2363 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && \
2364 b2b3fce1 2022-10-29 op got histedit -F "$testroot/histedit-script") >/dev/null
2365 b2b3fce1 2022-10-29 op ret=$?
2366 b2b3fce1 2022-10-29 op
2367 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
2368 b2b3fce1 2022-10-29 op echo "histedit operation failed" >&2
2369 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
2370 b2b3fce1 2022-10-29 op return 1
2371 b2b3fce1 2022-10-29 op fi
2372 b2b3fce1 2022-10-29 op
2373 b2b3fce1 2022-10-29 op for f in alpha beta; do
2374 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
2375 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
2376 b2b3fce1 2022-10-29 op echo "$f is not 0600 after histedi" >&2
2377 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
2378 b2b3fce1 2022-10-29 op test_done "$testroot" 1
2379 b2b3fce1 2022-10-29 op return 1
2380 b2b3fce1 2022-10-29 op fi
2381 b2b3fce1 2022-10-29 op done
2382 b2b3fce1 2022-10-29 op
2383 b2b3fce1 2022-10-29 op test_done "$testroot" 0
2384 b2b3fce1 2022-10-29 op }
2385 c48f94a4 2023-01-29 stsp
2386 c48f94a4 2023-01-29 stsp test_histedit_mesg_filemode_change() {
2387 c48f94a4 2023-01-29 stsp local testroot=`test_init histedit_mode_change`
2388 c48f94a4 2023-01-29 stsp
2389 c48f94a4 2023-01-29 stsp local orig_commit=`git_show_head $testroot/repo`
2390 c48f94a4 2023-01-29 stsp local orig_author_time=`git_show_author_time $testroot/repo`
2391 c48f94a4 2023-01-29 stsp
2392 c48f94a4 2023-01-29 stsp chmod +x $testroot/repo/alpha
2393 c48f94a4 2023-01-29 stsp git_commit $testroot/repo -m "set x bit on alpha"
2394 c48f94a4 2023-01-29 stsp local old_commit1=`git_show_head $testroot/repo`
2395 c48f94a4 2023-01-29 stsp local old_author_time1=`git_show_author_time $testroot/repo`
2396 c48f94a4 2023-01-29 stsp
2397 c48f94a4 2023-01-29 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2398 c48f94a4 2023-01-29 stsp ret=$?
2399 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
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 if [ -x $testroot/wt/alpha ]; then
2405 c48f94a4 2023-01-29 stsp echo "file alpha has unexpected executable bit" >&2
2406 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2407 c48f94a4 2023-01-29 stsp return 1
2408 c48f94a4 2023-01-29 stsp fi
2409 c48f94a4 2023-01-29 stsp
2410 c48f94a4 2023-01-29 stsp cat > $testroot/editor.sh <<EOF
2411 c48f94a4 2023-01-29 stsp #!/bin/sh
2412 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
2413 885e96df 2023-03-06 naddy ,s/ x bit / executable bit /
2414 885e96df 2023-03-06 naddy w
2415 885e96df 2023-03-06 naddy EOF
2416 c48f94a4 2023-01-29 stsp EOF
2417 b2b3fce1 2022-10-29 op
2418 c48f94a4 2023-01-29 stsp chmod +x $testroot/editor.sh
2419 c48f94a4 2023-01-29 stsp
2420 71a61c8c 2023-01-29 stsp (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2421 c48f94a4 2023-01-29 stsp got histedit -m > $testroot/stdout)
2422 c48f94a4 2023-01-29 stsp
2423 c48f94a4 2023-01-29 stsp local new_commit1=`git_show_head $testroot/repo`
2424 c48f94a4 2023-01-29 stsp local new_author_time1=`git_show_author_time $testroot/repo`
2425 c48f94a4 2023-01-29 stsp
2426 c48f94a4 2023-01-29 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
2427 c48f94a4 2023-01-29 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
2428 c48f94a4 2023-01-29 stsp
2429 c48f94a4 2023-01-29 stsp echo "G alpha" > $testroot/stdout.expected
2430 c48f94a4 2023-01-29 stsp echo "$short_old_commit1 -> $short_new_commit1: set executable bit on alpha" \
2431 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2432 c48f94a4 2023-01-29 stsp echo "Switching work tree to refs/heads/master" \
2433 c48f94a4 2023-01-29 stsp >> $testroot/stdout.expected
2434 c48f94a4 2023-01-29 stsp
2435 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2436 c48f94a4 2023-01-29 stsp ret=$?
2437 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2438 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2439 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2440 c48f94a4 2023-01-29 stsp return 1
2441 c48f94a4 2023-01-29 stsp fi
2442 c48f94a4 2023-01-29 stsp
2443 c48f94a4 2023-01-29 stsp echo "alpha" > $testroot/content.expected
2444 9f31ca1f 2023-01-29 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
2445 c48f94a4 2023-01-29 stsp ret=$?
2446 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2447 9f31ca1f 2023-01-29 stsp diff -u $testroot/content.expected $testroot/wt/alpha
2448 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2449 c48f94a4 2023-01-29 stsp return 1
2450 c48f94a4 2023-01-29 stsp fi
2451 c48f94a4 2023-01-29 stsp
2452 c48f94a4 2023-01-29 stsp if [ ! -x $testroot/wt/alpha ]; then
2453 c48f94a4 2023-01-29 stsp echo "file alpha lost its executable bit" >&2
2454 c48f94a4 2023-01-29 stsp test_done "$testroot" "1"
2455 c48f94a4 2023-01-29 stsp return 1
2456 c48f94a4 2023-01-29 stsp fi
2457 c48f94a4 2023-01-29 stsp
2458 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got status > $testroot/stdout)
2459 c48f94a4 2023-01-29 stsp
2460 c48f94a4 2023-01-29 stsp echo -n > $testroot/stdout.expected
2461 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2462 c48f94a4 2023-01-29 stsp ret=$?
2463 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2464 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2465 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2466 c48f94a4 2023-01-29 stsp return 1
2467 c48f94a4 2023-01-29 stsp fi
2468 c48f94a4 2023-01-29 stsp
2469 c48f94a4 2023-01-29 stsp (cd $testroot/wt && got log -l1 | grep ' set executable bit on alpha' \
2470 c48f94a4 2023-01-29 stsp > $testroot/stdout)
2471 c48f94a4 2023-01-29 stsp
2472 c48f94a4 2023-01-29 stsp echo ' set executable bit on alpha' > $testroot/stdout.expected
2473 c48f94a4 2023-01-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2474 c48f94a4 2023-01-29 stsp ret=$?
2475 c48f94a4 2023-01-29 stsp if [ $ret -ne 0 ]; then
2476 c48f94a4 2023-01-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
2477 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2478 c48f94a4 2023-01-29 stsp return 1
2479 c48f94a4 2023-01-29 stsp fi
2480 c48f94a4 2023-01-29 stsp
2481 c48f94a4 2023-01-29 stsp test_done "$testroot" "$ret"
2482 c48f94a4 2023-01-29 stsp }
2483 f1c9fe20 2023-01-30 mark
2484 f1c9fe20 2023-01-30 mark test_histedit_drop_only() {
2485 f1c9fe20 2023-01-30 mark local testroot=`test_init histedit_drop_only`
2486 f1c9fe20 2023-01-30 mark
2487 f1c9fe20 2023-01-30 mark local orig_commit=`git_show_head $testroot/repo`
2488 f1c9fe20 2023-01-30 mark local drop="-> drop commit:"
2489 f1c9fe20 2023-01-30 mark local dropmsg="commit changes to drop"
2490 f1c9fe20 2023-01-30 mark
2491 f1c9fe20 2023-01-30 mark echo "modified alpha on master" > $testroot/repo/alpha
2492 f1c9fe20 2023-01-30 mark (cd $testroot/repo && git rm -q beta)
2493 f1c9fe20 2023-01-30 mark echo "new file on master" > $testroot/repo/epsilon/new
2494 f1c9fe20 2023-01-30 mark (cd $testroot/repo && git add epsilon/new)
2495 f1c9fe20 2023-01-30 mark
2496 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 1"
2497 f1c9fe20 2023-01-30 mark local drop_commit1=`git_show_head $testroot/repo`
2498 f1c9fe20 2023-01-30 mark
2499 f1c9fe20 2023-01-30 mark echo "modified zeta on master" > $testroot/repo/epsilon/zeta
2500 f1c9fe20 2023-01-30 mark
2501 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 2"
2502 f1c9fe20 2023-01-30 mark local drop_commit2=`git_show_head $testroot/repo`
2503 f1c9fe20 2023-01-30 mark
2504 f1c9fe20 2023-01-30 mark echo "modified delta on master" > $testroot/repo/gamma/delta
2505 f1c9fe20 2023-01-30 mark
2506 f1c9fe20 2023-01-30 mark git_commit $testroot/repo -m "$dropmsg 3"
2507 f1c9fe20 2023-01-30 mark local drop_commit3=`git_show_head $testroot/repo`
2508 f1c9fe20 2023-01-30 mark
2509 f1c9fe20 2023-01-30 mark got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
2510 f1c9fe20 2023-01-30 mark ret=$?
2511 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2512 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2513 f1c9fe20 2023-01-30 mark return 1
2514 f1c9fe20 2023-01-30 mark fi
2515 c48f94a4 2023-01-29 stsp
2516 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got histedit -d > $testroot/stdout)
2517 f1c9fe20 2023-01-30 mark local new_commit1=`git_show_head $testroot/repo`
2518 f1c9fe20 2023-01-30 mark
2519 f1c9fe20 2023-01-30 mark local short_commit1=`trim_obj_id 28 $drop_commit1`
2520 f1c9fe20 2023-01-30 mark local short_commit2=`trim_obj_id 28 $drop_commit2`
2521 f1c9fe20 2023-01-30 mark local short_commit3=`trim_obj_id 28 $drop_commit3`
2522 f1c9fe20 2023-01-30 mark
2523 f1c9fe20 2023-01-30 mark echo "$short_commit1 $drop $dropmsg 1" > $testroot/stdout.expected
2524 f1c9fe20 2023-01-30 mark echo "$short_commit2 $drop $dropmsg 2" >> $testroot/stdout.expected
2525 f1c9fe20 2023-01-30 mark echo "$short_commit3 $drop $dropmsg 3" >> $testroot/stdout.expected
2526 f1c9fe20 2023-01-30 mark echo "Switching work tree to refs/heads/master" \
2527 f1c9fe20 2023-01-30 mark >> $testroot/stdout.expected
2528 f1c9fe20 2023-01-30 mark
2529 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2530 f1c9fe20 2023-01-30 mark ret=$?
2531 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2532 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2533 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2534 f1c9fe20 2023-01-30 mark return 1
2535 f1c9fe20 2023-01-30 mark fi
2536 f1c9fe20 2023-01-30 mark
2537 f1c9fe20 2023-01-30 mark echo "alpha" > $testroot/content.expected
2538 f1c9fe20 2023-01-30 mark cat $testroot/wt/alpha > $testroot/content
2539 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2540 f1c9fe20 2023-01-30 mark ret=$?
2541 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2542 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2543 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2544 f1c9fe20 2023-01-30 mark return 1
2545 f1c9fe20 2023-01-30 mark fi
2546 f1c9fe20 2023-01-30 mark
2547 f1c9fe20 2023-01-30 mark echo "zeta" > $testroot/content.expected
2548 f1c9fe20 2023-01-30 mark cat $testroot/wt/epsilon/zeta > $testroot/content
2549 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2550 f1c9fe20 2023-01-30 mark ret=$?
2551 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2552 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2553 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2554 f1c9fe20 2023-01-30 mark return 1
2555 f1c9fe20 2023-01-30 mark fi
2556 f1c9fe20 2023-01-30 mark
2557 f1c9fe20 2023-01-30 mark echo "delta" > $testroot/content.expected
2558 f1c9fe20 2023-01-30 mark cat $testroot/wt/gamma/delta > $testroot/content
2559 f1c9fe20 2023-01-30 mark cmp -s $testroot/content.expected $testroot/content
2560 f1c9fe20 2023-01-30 mark ret=$?
2561 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2562 f1c9fe20 2023-01-30 mark diff -u $testroot/content.expected $testroot/content
2563 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2564 f1c9fe20 2023-01-30 mark return 1
2565 f1c9fe20 2023-01-30 mark fi
2566 f1c9fe20 2023-01-30 mark
2567 f1c9fe20 2023-01-30 mark if [ ! -e $testroot/wt/beta ]; then
2568 f1c9fe20 2023-01-30 mark echo "removed file beta should be restored" >&2
2569 f1c9fe20 2023-01-30 mark test_done "$testroot" "1"
2570 f1c9fe20 2023-01-30 mark return 1
2571 f1c9fe20 2023-01-30 mark fi
2572 f1c9fe20 2023-01-30 mark
2573 f1c9fe20 2023-01-30 mark if [ -e $testroot/wt/new ]; then
2574 f1c9fe20 2023-01-30 mark echo "new file should no longer exist" >&2
2575 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2576 f1c9fe20 2023-01-30 mark return 1
2577 f1c9fe20 2023-01-30 mark fi
2578 f1c9fe20 2023-01-30 mark
2579 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2580 f1c9fe20 2023-01-30 mark
2581 f1c9fe20 2023-01-30 mark echo -n > $testroot/stdout.expected
2582 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2583 f1c9fe20 2023-01-30 mark ret=$?
2584 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2585 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2586 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2587 f1c9fe20 2023-01-30 mark return 1
2588 f1c9fe20 2023-01-30 mark fi
2589 f1c9fe20 2023-01-30 mark
2590 f1c9fe20 2023-01-30 mark (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
2591 f1c9fe20 2023-01-30 mark echo "commit $orig_commit (master)" > $testroot/stdout.expected
2592 f1c9fe20 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2593 f1c9fe20 2023-01-30 mark ret=$?
2594 f1c9fe20 2023-01-30 mark if [ $ret -ne 0 ]; then
2595 f1c9fe20 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2596 f1c9fe20 2023-01-30 mark fi
2597 f1c9fe20 2023-01-30 mark test_done "$testroot" "$ret"
2598 f1c9fe20 2023-01-30 mark }
2599 f1c9fe20 2023-01-30 mark
2600 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2601 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
2602 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
2603 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
2604 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
2605 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
2606 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
2607 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
2608 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
2609 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
2610 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
2611 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
2612 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
2613 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
2614 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
2615 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
2616 c2ba7aa6 2023-07-26 stsp run_test test_histedit_fold_edit_delete
2617 15aed053 2023-03-07 naddy run_test test_histedit_fold_delete_add
2618 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
2619 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg
2620 b93c7142 2021-10-01 stsp run_test test_histedit_edit_only
2621 09209b8a 2021-10-08 stsp run_test test_histedit_prepend_line
2622 f1e5aff4 2022-07-12 op run_test test_histedit_mesg_invalid
2623 598eac43 2022-07-22 stsp run_test test_histedit_resets_committer
2624 b2b3fce1 2022-10-29 op run_test test_histedit_umask
2625 c48f94a4 2023-01-29 stsp run_test test_histedit_mesg_filemode_change
2626 f1c9fe20 2023-01-30 mark run_test test_histedit_drop_only