Blame


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