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 0ebf8283 2019-07-24 stsp
24 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
25 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
26 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
27 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
28 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
29 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
30 0ebf8283 2019-07-24 stsp
31 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
32 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
33 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
34 0ebf8283 2019-07-24 stsp
35 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
36 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
37 86ac67ee 2019-07-25 stsp
38 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
39 0ebf8283 2019-07-24 stsp ret="$?"
40 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
41 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
42 0ebf8283 2019-07-24 stsp return 1
43 0ebf8283 2019-07-24 stsp fi
44 0ebf8283 2019-07-24 stsp
45 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
46 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
47 0ebf8283 2019-07-24 stsp
48 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
49 0ebf8283 2019-07-24 stsp > $testroot/stdout)
50 0ebf8283 2019-07-24 stsp
51 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
52 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
53 0ebf8283 2019-07-24 stsp
54 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
55 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
56 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
57 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
58 0ebf8283 2019-07-24 stsp
59 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
60 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
61 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
62 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
63 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
64 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
65 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
66 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
67 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
68 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
69 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
70 0ebf8283 2019-07-24 stsp
71 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
72 0ebf8283 2019-07-24 stsp ret="$?"
73 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
74 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
75 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
76 0ebf8283 2019-07-24 stsp return 1
77 0ebf8283 2019-07-24 stsp fi
78 0ebf8283 2019-07-24 stsp
79 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
80 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
81 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
82 0ebf8283 2019-07-24 stsp ret="$?"
83 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
84 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
85 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
86 0ebf8283 2019-07-24 stsp return 1
87 0ebf8283 2019-07-24 stsp fi
88 0ebf8283 2019-07-24 stsp
89 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
90 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
91 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
92 0ebf8283 2019-07-24 stsp return 1
93 0ebf8283 2019-07-24 stsp fi
94 0ebf8283 2019-07-24 stsp
95 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
96 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
97 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
98 0ebf8283 2019-07-24 stsp ret="$?"
99 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
100 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
101 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
102 0ebf8283 2019-07-24 stsp return 1
103 0ebf8283 2019-07-24 stsp fi
104 0ebf8283 2019-07-24 stsp
105 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
106 0ebf8283 2019-07-24 stsp
107 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
108 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
109 0ebf8283 2019-07-24 stsp ret="$?"
110 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
111 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
112 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
113 0ebf8283 2019-07-24 stsp return 1
114 0ebf8283 2019-07-24 stsp fi
115 0ebf8283 2019-07-24 stsp
116 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
117 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
118 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
119 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
120 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
121 0ebf8283 2019-07-24 stsp ret="$?"
122 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
123 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
125 86ac67ee 2019-07-25 stsp return 1
126 0ebf8283 2019-07-24 stsp fi
127 86ac67ee 2019-07-25 stsp
128 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
129 86ac67ee 2019-07-25 stsp > $testroot/diff
130 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
131 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
132 86ac67ee 2019-07-25 stsp ret="$?"
133 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
134 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
135 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
136 a615e0e7 2020-12-16 stsp return 1
137 86ac67ee 2019-07-25 stsp fi
138 a615e0e7 2020-12-16 stsp
139 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
140 a615e0e7 2020-12-16 stsp
141 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
142 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
143 a615e0e7 2020-12-16 stsp ret="$?"
144 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
145 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
146 a615e0e7 2020-12-16 stsp fi
147 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
148 0ebf8283 2019-07-24 stsp }
149 0ebf8283 2019-07-24 stsp
150 f6cae3ed 2020-09-13 naddy test_histedit_swap() {
151 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
152 0ebf8283 2019-07-24 stsp
153 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
154 0ebf8283 2019-07-24 stsp
155 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
156 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
157 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
158 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
159 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
160 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
161 0ebf8283 2019-07-24 stsp
162 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
163 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
164 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
165 0ebf8283 2019-07-24 stsp
166 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
167 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
168 86ac67ee 2019-07-25 stsp
169 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
170 0ebf8283 2019-07-24 stsp ret="$?"
171 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
172 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
173 0ebf8283 2019-07-24 stsp return 1
174 0ebf8283 2019-07-24 stsp fi
175 0ebf8283 2019-07-24 stsp
176 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
177 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
178 0ebf8283 2019-07-24 stsp
179 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
180 0ebf8283 2019-07-24 stsp > $testroot/stdout)
181 0ebf8283 2019-07-24 stsp
182 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
183 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
184 0ebf8283 2019-07-24 stsp
185 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
186 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
187 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
188 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
189 0ebf8283 2019-07-24 stsp
190 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
191 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
192 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
193 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
194 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
195 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
196 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
197 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
198 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
199 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
200 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
201 0ebf8283 2019-07-24 stsp
202 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
203 0ebf8283 2019-07-24 stsp ret="$?"
204 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
205 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
207 0ebf8283 2019-07-24 stsp return 1
208 0ebf8283 2019-07-24 stsp fi
209 0ebf8283 2019-07-24 stsp
210 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
211 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
212 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
213 0ebf8283 2019-07-24 stsp ret="$?"
214 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
215 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
216 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
217 0ebf8283 2019-07-24 stsp return 1
218 0ebf8283 2019-07-24 stsp fi
219 0ebf8283 2019-07-24 stsp
220 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
221 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
222 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
223 0ebf8283 2019-07-24 stsp return 1
224 0ebf8283 2019-07-24 stsp fi
225 0ebf8283 2019-07-24 stsp
226 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
227 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
228 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
229 0ebf8283 2019-07-24 stsp ret="$?"
230 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
231 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
232 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
233 0ebf8283 2019-07-24 stsp return 1
234 0ebf8283 2019-07-24 stsp fi
235 0ebf8283 2019-07-24 stsp
236 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
237 0ebf8283 2019-07-24 stsp
238 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
239 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
240 0ebf8283 2019-07-24 stsp ret="$?"
241 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
242 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
243 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
244 0ebf8283 2019-07-24 stsp return 1
245 0ebf8283 2019-07-24 stsp fi
246 0ebf8283 2019-07-24 stsp
247 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
248 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
249 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
250 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
251 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
252 0ebf8283 2019-07-24 stsp ret="$?"
253 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
254 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
256 86ac67ee 2019-07-25 stsp return 1
257 86ac67ee 2019-07-25 stsp fi
258 86ac67ee 2019-07-25 stsp
259 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
260 86ac67ee 2019-07-25 stsp > $testroot/diff
261 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
262 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
263 86ac67ee 2019-07-25 stsp ret="$?"
264 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
265 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
266 0ebf8283 2019-07-24 stsp fi
267 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
268 0ebf8283 2019-07-24 stsp }
269 0ebf8283 2019-07-24 stsp
270 f6cae3ed 2020-09-13 naddy test_histedit_drop() {
271 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
272 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
273 0ebf8283 2019-07-24 stsp
274 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
275 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
276 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
277 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
278 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
279 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
280 0ebf8283 2019-07-24 stsp
281 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
282 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
283 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
284 0ebf8283 2019-07-24 stsp
285 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
286 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
287 86ac67ee 2019-07-25 stsp
288 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
289 0ebf8283 2019-07-24 stsp ret="$?"
290 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
291 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
292 0ebf8283 2019-07-24 stsp return 1
293 0ebf8283 2019-07-24 stsp fi
294 0ebf8283 2019-07-24 stsp
295 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
296 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
297 0ebf8283 2019-07-24 stsp
298 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
299 0ebf8283 2019-07-24 stsp > $testroot/stdout)
300 0ebf8283 2019-07-24 stsp
301 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
302 0ebf8283 2019-07-24 stsp
303 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
304 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
305 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
306 0ebf8283 2019-07-24 stsp
307 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
308 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
309 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
310 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
311 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
312 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
313 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
314 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
315 0ebf8283 2019-07-24 stsp
316 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
317 0ebf8283 2019-07-24 stsp ret="$?"
318 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
319 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
320 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
321 0ebf8283 2019-07-24 stsp return 1
322 0ebf8283 2019-07-24 stsp fi
323 0ebf8283 2019-07-24 stsp
324 0ebf8283 2019-07-24 stsp for f in alpha beta; do
325 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
326 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
327 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
328 0ebf8283 2019-07-24 stsp ret="$?"
329 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
330 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
331 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
332 0ebf8283 2019-07-24 stsp return 1
333 0ebf8283 2019-07-24 stsp fi
334 0ebf8283 2019-07-24 stsp done
335 0ebf8283 2019-07-24 stsp
336 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
337 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
338 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
339 0ebf8283 2019-07-24 stsp return 1
340 0ebf8283 2019-07-24 stsp fi
341 0ebf8283 2019-07-24 stsp
342 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
343 0ebf8283 2019-07-24 stsp
344 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
345 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
346 0ebf8283 2019-07-24 stsp ret="$?"
347 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
348 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
349 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
350 0ebf8283 2019-07-24 stsp return 1
351 0ebf8283 2019-07-24 stsp fi
352 0ebf8283 2019-07-24 stsp
353 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
354 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
355 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
356 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
357 0ebf8283 2019-07-24 stsp ret="$?"
358 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
359 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
360 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
361 86ac67ee 2019-07-25 stsp return 1
362 86ac67ee 2019-07-25 stsp fi
363 86ac67ee 2019-07-25 stsp
364 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
365 86ac67ee 2019-07-25 stsp > $testroot/diff
366 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
367 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
368 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
369 86ac67ee 2019-07-25 stsp ret="$?"
370 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
371 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
372 0ebf8283 2019-07-24 stsp fi
373 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
374 0ebf8283 2019-07-24 stsp }
375 0ebf8283 2019-07-24 stsp
376 f6cae3ed 2020-09-13 naddy test_histedit_fold() {
377 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
378 0ebf8283 2019-07-24 stsp
379 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
380 0ebf8283 2019-07-24 stsp
381 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
382 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
383 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
384 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
385 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
386 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
387 0ebf8283 2019-07-24 stsp
388 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
389 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
390 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
391 3f9de99f 2019-07-24 stsp
392 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
393 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
394 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
395 0ebf8283 2019-07-24 stsp
396 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
397 0ebf8283 2019-07-24 stsp ret="$?"
398 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
399 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
400 0ebf8283 2019-07-24 stsp return 1
401 0ebf8283 2019-07-24 stsp fi
402 0ebf8283 2019-07-24 stsp
403 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
404 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
405 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
406 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
407 0ebf8283 2019-07-24 stsp
408 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
409 0ebf8283 2019-07-24 stsp > $testroot/stdout)
410 0ebf8283 2019-07-24 stsp
411 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
412 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
413 0ebf8283 2019-07-24 stsp
414 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
415 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
416 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
417 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
418 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
419 0ebf8283 2019-07-24 stsp
420 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
421 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
422 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
423 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
424 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
425 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
426 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
427 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
428 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
429 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
430 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
431 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
432 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
433 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
434 0ebf8283 2019-07-24 stsp
435 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
436 0ebf8283 2019-07-24 stsp ret="$?"
437 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
438 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
440 0ebf8283 2019-07-24 stsp return 1
441 0ebf8283 2019-07-24 stsp fi
442 0ebf8283 2019-07-24 stsp
443 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
444 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
445 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
446 0ebf8283 2019-07-24 stsp ret="$?"
447 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
448 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
449 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
450 0ebf8283 2019-07-24 stsp return 1
451 0ebf8283 2019-07-24 stsp fi
452 0ebf8283 2019-07-24 stsp
453 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
454 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
455 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
456 0ebf8283 2019-07-24 stsp return 1
457 0ebf8283 2019-07-24 stsp fi
458 0ebf8283 2019-07-24 stsp
459 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
460 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
461 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
462 0ebf8283 2019-07-24 stsp ret="$?"
463 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
464 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
465 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
466 0ebf8283 2019-07-24 stsp return 1
467 0ebf8283 2019-07-24 stsp fi
468 0ebf8283 2019-07-24 stsp
469 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
470 0ebf8283 2019-07-24 stsp
471 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
472 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
473 0ebf8283 2019-07-24 stsp ret="$?"
474 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
475 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
476 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
477 0ebf8283 2019-07-24 stsp return 1
478 0ebf8283 2019-07-24 stsp fi
479 0ebf8283 2019-07-24 stsp
480 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
481 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
482 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
483 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
484 0ebf8283 2019-07-24 stsp ret="$?"
485 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
486 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
487 0ebf8283 2019-07-24 stsp fi
488 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
489 0ebf8283 2019-07-24 stsp }
490 0ebf8283 2019-07-24 stsp
491 f6cae3ed 2020-09-13 naddy test_histedit_edit() {
492 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
493 0ebf8283 2019-07-24 stsp
494 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
495 0ebf8283 2019-07-24 stsp
496 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
497 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
498 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
499 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
500 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
501 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
502 0ebf8283 2019-07-24 stsp
503 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
504 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
505 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
506 0ebf8283 2019-07-24 stsp
507 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
508 0ebf8283 2019-07-24 stsp ret="$?"
509 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
510 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
511 0ebf8283 2019-07-24 stsp return 1
512 0ebf8283 2019-07-24 stsp fi
513 0ebf8283 2019-07-24 stsp
514 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
515 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
516 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
517 0ebf8283 2019-07-24 stsp
518 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
519 0ebf8283 2019-07-24 stsp > $testroot/stdout)
520 0ebf8283 2019-07-24 stsp
521 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
522 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
523 0ebf8283 2019-07-24 stsp
524 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
525 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
526 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
527 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
528 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
529 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
530 0ebf8283 2019-07-24 stsp ret="$?"
531 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
532 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
533 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
534 0ebf8283 2019-07-24 stsp return 1
535 0ebf8283 2019-07-24 stsp fi
536 0ebf8283 2019-07-24 stsp
537 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
538 0ebf8283 2019-07-24 stsp
539 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and histedit -c
540 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
541 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout \
542 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
543 f032f1f7 2019-08-04 stsp ret="$?"
544 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
545 f032f1f7 2019-08-04 stsp echo "histedit succeeded unexpectedly" >&2
546 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
547 f032f1f7 2019-08-04 stsp return 1
548 f032f1f7 2019-08-04 stsp fi
549 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
550 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
551 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
552 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
553 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
554 f032f1f7 2019-08-04 stsp ret="$?"
555 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
556 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
557 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
558 f032f1f7 2019-08-04 stsp return 1
559 f032f1f7 2019-08-04 stsp fi
560 f032f1f7 2019-08-04 stsp
561 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
562 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
563 0ebf8283 2019-07-24 stsp
564 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
565 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
566 0ebf8283 2019-07-24 stsp
567 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
568 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
569 0ebf8283 2019-07-24 stsp
570 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
571 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
572 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
573 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
574 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
575 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
576 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
577 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
578 0ebf8283 2019-07-24 stsp
579 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
580 0ebf8283 2019-07-24 stsp ret="$?"
581 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
582 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
583 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
584 0ebf8283 2019-07-24 stsp return 1
585 0ebf8283 2019-07-24 stsp fi
586 0ebf8283 2019-07-24 stsp
587 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
588 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
589 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
590 0ebf8283 2019-07-24 stsp ret="$?"
591 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
592 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
593 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
594 0ebf8283 2019-07-24 stsp return 1
595 0ebf8283 2019-07-24 stsp fi
596 0ebf8283 2019-07-24 stsp
597 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
598 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
599 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
600 0ebf8283 2019-07-24 stsp return 1
601 0ebf8283 2019-07-24 stsp fi
602 0ebf8283 2019-07-24 stsp
603 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
604 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
605 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
606 0ebf8283 2019-07-24 stsp ret="$?"
607 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
608 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
609 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
610 0ebf8283 2019-07-24 stsp return 1
611 0ebf8283 2019-07-24 stsp fi
612 0ebf8283 2019-07-24 stsp
613 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
614 0ebf8283 2019-07-24 stsp
615 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
616 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
617 0ebf8283 2019-07-24 stsp ret="$?"
618 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
619 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
621 0ebf8283 2019-07-24 stsp return 1
622 0ebf8283 2019-07-24 stsp fi
623 0ebf8283 2019-07-24 stsp
624 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
625 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
626 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
627 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
628 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
629 0ebf8283 2019-07-24 stsp ret="$?"
630 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
631 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
632 0ebf8283 2019-07-24 stsp fi
633 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
634 0ebf8283 2019-07-24 stsp }
635 0ebf8283 2019-07-24 stsp
636 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit() {
637 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
638 0ebf8283 2019-07-24 stsp
639 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
640 0ebf8283 2019-07-24 stsp
641 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
642 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
643 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
644 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
645 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
646 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
647 0ebf8283 2019-07-24 stsp
648 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
649 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
650 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
651 0ebf8283 2019-07-24 stsp
652 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
653 0ebf8283 2019-07-24 stsp ret="$?"
654 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
655 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
656 0ebf8283 2019-07-24 stsp return 1
657 0ebf8283 2019-07-24 stsp fi
658 0ebf8283 2019-07-24 stsp
659 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
660 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
661 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
662 0ebf8283 2019-07-24 stsp
663 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
664 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
665 0ebf8283 2019-07-24 stsp
666 0ebf8283 2019-07-24 stsp ret="$?"
667 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
668 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
669 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
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 "got: last commit in histedit script cannot be folded" \
674 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
675 0ebf8283 2019-07-24 stsp
676 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
677 0ebf8283 2019-07-24 stsp ret="$?"
678 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
679 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
680 0ebf8283 2019-07-24 stsp fi
681 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
682 0ebf8283 2019-07-24 stsp }
683 0ebf8283 2019-07-24 stsp
684 f6cae3ed 2020-09-13 naddy test_histedit_missing_commit() {
685 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
686 0ebf8283 2019-07-24 stsp
687 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
688 0ebf8283 2019-07-24 stsp
689 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
690 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
691 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
692 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
693 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
694 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
695 0ebf8283 2019-07-24 stsp
696 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
697 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
698 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
699 0ebf8283 2019-07-24 stsp
700 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
701 0ebf8283 2019-07-24 stsp ret="$?"
702 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
703 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
704 0ebf8283 2019-07-24 stsp return 1
705 0ebf8283 2019-07-24 stsp fi
706 0ebf8283 2019-07-24 stsp
707 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
708 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
709 0ebf8283 2019-07-24 stsp
710 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
711 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
712 0ebf8283 2019-07-24 stsp
713 0ebf8283 2019-07-24 stsp ret="$?"
714 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
715 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
716 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
717 0ebf8283 2019-07-24 stsp return 1
718 0ebf8283 2019-07-24 stsp fi
719 0ebf8283 2019-07-24 stsp
720 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
721 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
722 0ebf8283 2019-07-24 stsp
723 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
724 0ebf8283 2019-07-24 stsp ret="$?"
725 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
726 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
727 0ebf8283 2019-07-24 stsp fi
728 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
729 0ebf8283 2019-07-24 stsp }
730 0ebf8283 2019-07-24 stsp
731 f6cae3ed 2020-09-13 naddy test_histedit_abort() {
732 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
733 0ebf8283 2019-07-24 stsp
734 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
735 0ebf8283 2019-07-24 stsp
736 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
737 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
738 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
739 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
740 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
741 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
742 0ebf8283 2019-07-24 stsp
743 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
744 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
745 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
746 0ebf8283 2019-07-24 stsp
747 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
748 0ebf8283 2019-07-24 stsp ret="$?"
749 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
750 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
751 0ebf8283 2019-07-24 stsp return 1
752 0ebf8283 2019-07-24 stsp fi
753 0ebf8283 2019-07-24 stsp
754 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
755 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
756 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
757 0ebf8283 2019-07-24 stsp
758 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
759 0ebf8283 2019-07-24 stsp > $testroot/stdout)
760 0ebf8283 2019-07-24 stsp
761 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
762 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
763 0ebf8283 2019-07-24 stsp
764 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
765 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
766 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
767 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
768 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
769 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
770 0ebf8283 2019-07-24 stsp ret="$?"
771 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
772 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
773 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
774 0ebf8283 2019-07-24 stsp return 1
775 0ebf8283 2019-07-24 stsp fi
776 0ebf8283 2019-07-24 stsp
777 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
778 0ebf8283 2019-07-24 stsp
779 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
780 0ebf8283 2019-07-24 stsp
781 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
782 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
783 0ebf8283 2019-07-24 stsp
784 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
785 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
786 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
787 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
788 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
789 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
790 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
791 0ebf8283 2019-07-24 stsp
792 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
793 0ebf8283 2019-07-24 stsp ret="$?"
794 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
795 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
796 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
797 0ebf8283 2019-07-24 stsp return 1
798 0ebf8283 2019-07-24 stsp fi
799 0ebf8283 2019-07-24 stsp
800 0ebf8283 2019-07-24 stsp for f in alpha beta; do
801 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
802 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
803 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
804 0ebf8283 2019-07-24 stsp ret="$?"
805 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
806 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
807 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
808 0ebf8283 2019-07-24 stsp return 1
809 0ebf8283 2019-07-24 stsp fi
810 0ebf8283 2019-07-24 stsp done
811 0ebf8283 2019-07-24 stsp
812 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
813 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
814 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
815 0ebf8283 2019-07-24 stsp ret="$?"
816 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
817 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
818 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
819 0ebf8283 2019-07-24 stsp return 1
820 0ebf8283 2019-07-24 stsp fi
821 0ebf8283 2019-07-24 stsp
822 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
823 0ebf8283 2019-07-24 stsp
824 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
825 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
826 0ebf8283 2019-07-24 stsp ret="$?"
827 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
828 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
829 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
830 0ebf8283 2019-07-24 stsp return 1
831 0ebf8283 2019-07-24 stsp fi
832 0ebf8283 2019-07-24 stsp
833 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
834 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
835 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
836 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
837 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
838 0160a755 2019-07-25 stsp ret="$?"
839 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
840 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 0160a755 2019-07-25 stsp fi
842 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
843 0160a755 2019-07-25 stsp }
844 0160a755 2019-07-25 stsp
845 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_drop() {
846 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
847 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
848 0160a755 2019-07-25 stsp
849 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
850 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
851 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
852 0160a755 2019-07-25 stsp
853 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
854 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
855 0160a755 2019-07-25 stsp ret="$?"
856 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
857 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
858 0160a755 2019-07-25 stsp return 1
859 0160a755 2019-07-25 stsp fi
860 0160a755 2019-07-25 stsp
861 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
862 0160a755 2019-07-25 stsp
863 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
864 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
865 0160a755 2019-07-25 stsp
866 0160a755 2019-07-25 stsp ret="$?"
867 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
868 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
869 0160a755 2019-07-25 stsp test_done "$testroot" "1"
870 0160a755 2019-07-25 stsp return 1
871 0160a755 2019-07-25 stsp fi
872 0160a755 2019-07-25 stsp
873 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
874 0160a755 2019-07-25 stsp > $testroot/stderr.expected
875 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
876 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
877 0160a755 2019-07-25 stsp
878 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
879 0160a755 2019-07-25 stsp ret="$?"
880 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
881 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
882 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
883 0160a755 2019-07-25 stsp return 1
884 0160a755 2019-07-25 stsp fi
885 0160a755 2019-07-25 stsp
886 0160a755 2019-07-25 stsp rm -rf $testroot/wt
887 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
888 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
889 0160a755 2019-07-25 stsp ret="$?"
890 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
891 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
892 0160a755 2019-07-25 stsp return 1
893 0160a755 2019-07-25 stsp fi
894 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
895 0160a755 2019-07-25 stsp > $testroot/stdout)
896 0160a755 2019-07-25 stsp
897 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
898 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
899 0160a755 2019-07-25 stsp
900 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
901 0160a755 2019-07-25 stsp > $testroot/stdout.expected
902 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
903 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
904 0160a755 2019-07-25 stsp
905 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
906 0ebf8283 2019-07-24 stsp ret="$?"
907 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
908 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
909 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
910 0160a755 2019-07-25 stsp return 1
911 0ebf8283 2019-07-24 stsp fi
912 0160a755 2019-07-25 stsp
913 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
914 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
915 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
916 0160a755 2019-07-25 stsp ret="$?"
917 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
918 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
919 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
920 0160a755 2019-07-25 stsp return 1
921 0160a755 2019-07-25 stsp fi
922 0160a755 2019-07-25 stsp
923 0160a755 2019-07-25 stsp
924 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
925 0160a755 2019-07-25 stsp
926 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
927 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
928 0160a755 2019-07-25 stsp ret="$?"
929 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
930 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
931 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
932 0160a755 2019-07-25 stsp return 1
933 0160a755 2019-07-25 stsp fi
934 0160a755 2019-07-25 stsp
935 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
936 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
937 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
938 b2c50a0a 2019-07-25 stsp ret="$?"
939 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
940 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 b2c50a0a 2019-07-25 stsp fi
942 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
943 b2c50a0a 2019-07-25 stsp }
944 b2c50a0a 2019-07-25 stsp
945 f6cae3ed 2020-09-13 naddy test_histedit_path_prefix_edit() {
946 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
947 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
948 b2c50a0a 2019-07-25 stsp
949 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
950 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
951 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
952 b2c50a0a 2019-07-25 stsp
953 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
954 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
955 b2c50a0a 2019-07-25 stsp
956 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
957 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
958 b2c50a0a 2019-07-25 stsp ret="$?"
959 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
960 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
961 b2c50a0a 2019-07-25 stsp return 1
962 b2c50a0a 2019-07-25 stsp fi
963 b2c50a0a 2019-07-25 stsp
964 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
965 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
966 b2c50a0a 2019-07-25 stsp
967 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
968 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
969 b2c50a0a 2019-07-25 stsp
970 b2c50a0a 2019-07-25 stsp ret="$?"
971 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
972 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
973 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
974 b2c50a0a 2019-07-25 stsp return 1
975 b2c50a0a 2019-07-25 stsp fi
976 b2c50a0a 2019-07-25 stsp
977 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
978 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
979 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
980 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
981 b2c50a0a 2019-07-25 stsp
982 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
983 b2c50a0a 2019-07-25 stsp ret="$?"
984 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
985 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
986 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
987 b2c50a0a 2019-07-25 stsp return 1
988 b2c50a0a 2019-07-25 stsp fi
989 b2c50a0a 2019-07-25 stsp
990 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
991 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
992 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
993 b2c50a0a 2019-07-25 stsp ret="$?"
994 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
995 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
996 b2c50a0a 2019-07-25 stsp return 1
997 b2c50a0a 2019-07-25 stsp fi
998 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
999 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
1000 b2c50a0a 2019-07-25 stsp
1001 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1002 b2c50a0a 2019-07-25 stsp
1003 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
1004 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
1005 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1006 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1007 0160a755 2019-07-25 stsp ret="$?"
1008 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
1009 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1010 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1011 b2c50a0a 2019-07-25 stsp return 1
1012 0160a755 2019-07-25 stsp fi
1013 b2c50a0a 2019-07-25 stsp
1014 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
1015 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
1016 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
1017 b2c50a0a 2019-07-25 stsp ret="$?"
1018 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1019 b2c50a0a 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
1020 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1021 b2c50a0a 2019-07-25 stsp return 1
1022 b2c50a0a 2019-07-25 stsp fi
1023 b2c50a0a 2019-07-25 stsp
1024 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
1025 b2c50a0a 2019-07-25 stsp
1026 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
1027 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1028 b2c50a0a 2019-07-25 stsp ret="$?"
1029 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1030 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1031 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1032 b2c50a0a 2019-07-25 stsp return 1
1033 b2c50a0a 2019-07-25 stsp fi
1034 b2c50a0a 2019-07-25 stsp
1035 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1036 b2c50a0a 2019-07-25 stsp
1037 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1038 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1039 b2c50a0a 2019-07-25 stsp
1040 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1041 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1042 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1043 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1044 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1045 b2c50a0a 2019-07-25 stsp
1046 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1047 b2c50a0a 2019-07-25 stsp ret="$?"
1048 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1049 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1050 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1051 b2c50a0a 2019-07-25 stsp return 1
1052 b2c50a0a 2019-07-25 stsp fi
1053 b2c50a0a 2019-07-25 stsp
1054 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1055 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1056 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1057 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1058 b2c50a0a 2019-07-25 stsp ret="$?"
1059 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1060 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1061 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1062 b2c50a0a 2019-07-25 stsp return 1
1063 b2c50a0a 2019-07-25 stsp fi
1064 b2c50a0a 2019-07-25 stsp
1065 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1066 b2c50a0a 2019-07-25 stsp > $testroot/diff
1067 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1068 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1069 b2c50a0a 2019-07-25 stsp ret="$?"
1070 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1071 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1072 b2c50a0a 2019-07-25 stsp fi
1073 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1074 0ebf8283 2019-07-24 stsp }
1075 c7d20a3f 2019-07-30 stsp
1076 f6cae3ed 2020-09-13 naddy test_histedit_outside_refs_heads() {
1077 c7d20a3f 2019-07-30 stsp local testroot=`test_init histedit_outside_refs_heads`
1078 c7d20a3f 2019-07-30 stsp local commit1=`git_show_head $testroot/repo`
1079 c7d20a3f 2019-07-30 stsp
1080 c7d20a3f 2019-07-30 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1081 c7d20a3f 2019-07-30 stsp ret="$?"
1082 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1083 c7d20a3f 2019-07-30 stsp echo "got checkout failed unexpectedly"
1084 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1085 c7d20a3f 2019-07-30 stsp return 1
1086 c7d20a3f 2019-07-30 stsp fi
1087 c7d20a3f 2019-07-30 stsp
1088 c7d20a3f 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
1089 c7d20a3f 2019-07-30 stsp
1090 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
1091 c7d20a3f 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
1092 c7d20a3f 2019-07-30 stsp ret="$?"
1093 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1094 c7d20a3f 2019-07-30 stsp echo "got commit failed unexpectedly" >&2
1095 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1096 c7d20a3f 2019-07-30 stsp return 1
1097 c7d20a3f 2019-07-30 stsp fi
1098 c7d20a3f 2019-07-30 stsp local commit2=`git_show_head $testroot/repo`
1099 0ebf8283 2019-07-24 stsp
1100 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
1101 c7d20a3f 2019-07-30 stsp ret="$?"
1102 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1103 c7d20a3f 2019-07-30 stsp echo "got ref failed unexpectedly" >&2
1104 c7d20a3f 2019-07-30 stsp test_done "$testroot" "1"
1105 c7d20a3f 2019-07-30 stsp return 1
1106 c7d20a3f 2019-07-30 stsp fi
1107 c7d20a3f 2019-07-30 stsp
1108 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got update -b origin/master -c $commit1 >/dev/null)
1109 c7d20a3f 2019-07-30 stsp ret="$?"
1110 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1111 c7d20a3f 2019-07-30 stsp echo "got update failed unexpectedly"
1112 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1113 c7d20a3f 2019-07-30 stsp return 1
1114 c7d20a3f 2019-07-30 stsp fi
1115 c7d20a3f 2019-07-30 stsp
1116 c7d20a3f 2019-07-30 stsp echo "edit $commit2" > $testroot/histedit-script
1117 c7d20a3f 2019-07-30 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1118 c7d20a3f 2019-07-30 stsp 2> $testroot/stderr)
1119 c7d20a3f 2019-07-30 stsp
1120 c7d20a3f 2019-07-30 stsp echo -n "got: will not edit commit history of a branch outside the " \
1121 c7d20a3f 2019-07-30 stsp > $testroot/stderr.expected
1122 c7d20a3f 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
1123 c7d20a3f 2019-07-30 stsp >> $testroot/stderr.expected
1124 c7d20a3f 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1125 c7d20a3f 2019-07-30 stsp ret="$?"
1126 c7d20a3f 2019-07-30 stsp if [ "$ret" != "0" ]; then
1127 c7d20a3f 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
1128 0def28b1 2019-08-17 stsp fi
1129 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1130 0def28b1 2019-08-17 stsp }
1131 0def28b1 2019-08-17 stsp
1132 f6cae3ed 2020-09-13 naddy test_histedit_fold_last_commit_swap() {
1133 0def28b1 2019-08-17 stsp local testroot=`test_init histedit_fold_last_commit_swap`
1134 0def28b1 2019-08-17 stsp
1135 0def28b1 2019-08-17 stsp local orig_commit=`git_show_head $testroot/repo`
1136 0def28b1 2019-08-17 stsp
1137 0def28b1 2019-08-17 stsp echo "modified alpha on master" > $testroot/repo/alpha
1138 0def28b1 2019-08-17 stsp (cd $testroot/repo && git rm -q beta)
1139 0def28b1 2019-08-17 stsp echo "new file on master" > $testroot/repo/epsilon/new
1140 0def28b1 2019-08-17 stsp (cd $testroot/repo && git add epsilon/new)
1141 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing changes"
1142 0def28b1 2019-08-17 stsp local old_commit1=`git_show_head $testroot/repo`
1143 0def28b1 2019-08-17 stsp
1144 0def28b1 2019-08-17 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1145 0def28b1 2019-08-17 stsp git_commit $testroot/repo -m "committing to zeta on master"
1146 0def28b1 2019-08-17 stsp local old_commit2=`git_show_head $testroot/repo`
1147 0def28b1 2019-08-17 stsp
1148 0def28b1 2019-08-17 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1149 0def28b1 2019-08-17 stsp ret="$?"
1150 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1151 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1152 0def28b1 2019-08-17 stsp return 1
1153 0def28b1 2019-08-17 stsp fi
1154 0def28b1 2019-08-17 stsp
1155 0def28b1 2019-08-17 stsp # fold commit2 into commit1 (requires swapping commits)
1156 0def28b1 2019-08-17 stsp echo "fold $old_commit2" > $testroot/histedit-script
1157 0def28b1 2019-08-17 stsp echo "pick $old_commit1" >> $testroot/histedit-script
1158 0def28b1 2019-08-17 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
1159 0def28b1 2019-08-17 stsp
1160 0def28b1 2019-08-17 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1161 0def28b1 2019-08-17 stsp > $testroot/stdout 2> $testroot/stderr)
1162 0def28b1 2019-08-17 stsp
1163 0def28b1 2019-08-17 stsp ret="$?"
1164 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1165 0def28b1 2019-08-17 stsp echo "histedit failed unexpectedly" >&2
1166 0def28b1 2019-08-17 stsp test_done "$testroot" "$ret"
1167 0def28b1 2019-08-17 stsp return 1
1168 c7d20a3f 2019-07-30 stsp fi
1169 0def28b1 2019-08-17 stsp
1170 0def28b1 2019-08-17 stsp local new_commit=`git_show_head $testroot/repo`
1171 0def28b1 2019-08-17 stsp
1172 0def28b1 2019-08-17 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1173 0def28b1 2019-08-17 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1174 0def28b1 2019-08-17 stsp local short_new_commit=`trim_obj_id 28 $new_commit`
1175 0def28b1 2019-08-17 stsp
1176 0def28b1 2019-08-17 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1177 0def28b1 2019-08-17 stsp echo -n "$short_old_commit2 -> fold commit: committing to zeta " \
1178 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1179 0def28b1 2019-08-17 stsp echo "on master" >> $testroot/stdout.expected
1180 0def28b1 2019-08-17 stsp echo "G alpha" >> $testroot/stdout.expected
1181 0def28b1 2019-08-17 stsp echo "D beta" >> $testroot/stdout.expected
1182 0def28b1 2019-08-17 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1183 0def28b1 2019-08-17 stsp echo -n "$short_old_commit1 -> $short_new_commit: " \
1184 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1185 0def28b1 2019-08-17 stsp echo "committing folded changes" >> $testroot/stdout.expected
1186 0def28b1 2019-08-17 stsp echo "Switching work tree to refs/heads/master" \
1187 0def28b1 2019-08-17 stsp >> $testroot/stdout.expected
1188 0def28b1 2019-08-17 stsp
1189 0def28b1 2019-08-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1190 0def28b1 2019-08-17 stsp ret="$?"
1191 0def28b1 2019-08-17 stsp if [ "$ret" != "0" ]; then
1192 0def28b1 2019-08-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1193 0def28b1 2019-08-17 stsp fi
1194 c7d20a3f 2019-07-30 stsp test_done "$testroot" "$ret"
1195 c7d20a3f 2019-07-30 stsp }
1196 de05890f 2020-03-05 stsp
1197 f6cae3ed 2020-09-13 naddy test_histedit_split_commit() {
1198 de05890f 2020-03-05 stsp local testroot=`test_init histedit_split_commit`
1199 de05890f 2020-03-05 stsp
1200 de05890f 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1201 de05890f 2020-03-05 stsp
1202 de05890f 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1203 de05890f 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1204 de05890f 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1205 de05890f 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1206 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1207 de05890f 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1208 de05890f 2020-03-05 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1209 de05890f 2020-03-05 stsp
1210 de05890f 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1211 de05890f 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1212 de05890f 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1213 de05890f 2020-03-05 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1214 c7d20a3f 2019-07-30 stsp
1215 de05890f 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1216 de05890f 2020-03-05 stsp ret="$?"
1217 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1218 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1219 de05890f 2020-03-05 stsp return 1
1220 de05890f 2020-03-05 stsp fi
1221 de05890f 2020-03-05 stsp
1222 de05890f 2020-03-05 stsp # split commit1 into commitA and commitB and commitC
1223 de05890f 2020-03-05 stsp echo "e $old_commit1" > $testroot/histedit-script
1224 de05890f 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1225 de05890f 2020-03-05 stsp
1226 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1227 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1228 de05890f 2020-03-05 stsp ret="$?"
1229 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1230 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1231 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1232 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1233 de05890f 2020-03-05 stsp return 1
1234 de05890f 2020-03-05 stsp fi
1235 de05890f 2020-03-05 stsp
1236 de05890f 2020-03-05 stsp echo "G alpha" > $testroot/stdout.expected
1237 de05890f 2020-03-05 stsp echo "D beta" >> $testroot/stdout.expected
1238 de05890f 2020-03-05 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1239 de05890f 2020-03-05 stsp echo "Stopping histedit for amending commit $old_commit1" \
1240 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1241 de05890f 2020-03-05 stsp
1242 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1243 de05890f 2020-03-05 stsp ret="$?"
1244 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1245 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1246 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1247 de05890f 2020-03-05 stsp return 1
1248 de05890f 2020-03-05 stsp fi
1249 de05890f 2020-03-05 stsp
1250 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitA" alpha >/dev/null)
1251 de05890f 2020-03-05 stsp ret="$?"
1252 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1253 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1254 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1255 de05890f 2020-03-05 stsp return 1
1256 de05890f 2020-03-05 stsp fi
1257 de05890f 2020-03-05 stsp
1258 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitB" beta >/dev/null)
1259 de05890f 2020-03-05 stsp ret="$?"
1260 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1261 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1262 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1263 de05890f 2020-03-05 stsp return 1
1264 de05890f 2020-03-05 stsp fi
1265 de05890f 2020-03-05 stsp
1266 de05890f 2020-03-05 stsp (cd $testroot/wt && got ci -m "commitC" epsilon/new >/dev/null)
1267 de05890f 2020-03-05 stsp ret="$?"
1268 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1269 de05890f 2020-03-05 stsp echo "commit failed unexpectedly" >&2
1270 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1271 de05890f 2020-03-05 stsp return 1
1272 de05890f 2020-03-05 stsp fi
1273 de05890f 2020-03-05 stsp
1274 de05890f 2020-03-05 stsp (cd $testroot/wt && got histedit -c \
1275 de05890f 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1276 de05890f 2020-03-05 stsp ret="$?"
1277 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1278 de05890f 2020-03-05 stsp echo "histedit failed unexpectedly:" >&2
1279 de05890f 2020-03-05 stsp cat $testroot/stderr >&2
1280 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1281 de05890f 2020-03-05 stsp return 1
1282 de05890f 2020-03-05 stsp fi
1283 de05890f 2020-03-05 stsp local new_commit2=`git_show_head $testroot/repo`
1284 de05890f 2020-03-05 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1285 de05890f 2020-03-05 stsp
1286 de05890f 2020-03-05 stsp echo "$short_old_commit1 -> no-op change: committing changes 1" \
1287 de05890f 2020-03-05 stsp > $testroot/stdout.expected
1288 de05890f 2020-03-05 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1289 de05890f 2020-03-05 stsp echo "$short_old_commit2 -> $short_new_commit2: committing changes 2" \
1290 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1291 de05890f 2020-03-05 stsp echo "Switching work tree to refs/heads/master" \
1292 de05890f 2020-03-05 stsp >> $testroot/stdout.expected
1293 de05890f 2020-03-05 stsp
1294 de05890f 2020-03-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1295 de05890f 2020-03-05 stsp ret="$?"
1296 de05890f 2020-03-05 stsp if [ "$ret" != "0" ]; then
1297 de05890f 2020-03-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1298 5b87815e 2020-03-05 stsp fi
1299 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1300 5b87815e 2020-03-05 stsp
1301 5b87815e 2020-03-05 stsp }
1302 5b87815e 2020-03-05 stsp
1303 f6cae3ed 2020-09-13 naddy test_histedit_duplicate_commit_in_script() {
1304 5b87815e 2020-03-05 stsp local testroot=`test_init histedit_duplicate_commit_in_script`
1305 5b87815e 2020-03-05 stsp
1306 5b87815e 2020-03-05 stsp local orig_commit=`git_show_head $testroot/repo`
1307 5b87815e 2020-03-05 stsp
1308 5b87815e 2020-03-05 stsp echo "modified alpha on master" > $testroot/repo/alpha
1309 5b87815e 2020-03-05 stsp (cd $testroot/repo && git rm -q beta)
1310 5b87815e 2020-03-05 stsp echo "new file on master" > $testroot/repo/epsilon/new
1311 5b87815e 2020-03-05 stsp (cd $testroot/repo && git add epsilon/new)
1312 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 1"
1313 5b87815e 2020-03-05 stsp local old_commit1=`git_show_head $testroot/repo`
1314 5b87815e 2020-03-05 stsp
1315 5b87815e 2020-03-05 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1316 5b87815e 2020-03-05 stsp git_commit $testroot/repo -m "committing changes 2"
1317 5b87815e 2020-03-05 stsp local old_commit2=`git_show_head $testroot/repo`
1318 5b87815e 2020-03-05 stsp
1319 5b87815e 2020-03-05 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1320 5b87815e 2020-03-05 stsp ret="$?"
1321 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1322 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1323 5b87815e 2020-03-05 stsp return 1
1324 5b87815e 2020-03-05 stsp fi
1325 5b87815e 2020-03-05 stsp
1326 5b87815e 2020-03-05 stsp # This histedit script lists commit1 more than once
1327 5b87815e 2020-03-05 stsp echo "p $old_commit1" > $testroot/histedit-script
1328 5b87815e 2020-03-05 stsp echo "p $old_commit1" >> $testroot/histedit-script
1329 5b87815e 2020-03-05 stsp echo "p $old_commit2" >> $testroot/histedit-script
1330 5b87815e 2020-03-05 stsp
1331 5b87815e 2020-03-05 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1332 5b87815e 2020-03-05 stsp > $testroot/stdout 2> $testroot/stderr)
1333 5b87815e 2020-03-05 stsp ret="$?"
1334 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1335 5b87815e 2020-03-05 stsp echo "histedit succeeded unexpectedly:" >&2
1336 5b87815e 2020-03-05 stsp cat $testroot/stdout >&2
1337 5b87815e 2020-03-05 stsp test_done "$testroot" "$ret"
1338 5b87815e 2020-03-05 stsp return 1
1339 de05890f 2020-03-05 stsp fi
1340 5b87815e 2020-03-05 stsp
1341 5b87815e 2020-03-05 stsp echo -n "got: commit $old_commit1 is listed more than once " \
1342 5b87815e 2020-03-05 stsp > $testroot/stderr.expected
1343 5b87815e 2020-03-05 stsp echo "in histedit script" >> $testroot/stderr.expected
1344 5b87815e 2020-03-05 stsp
1345 5b87815e 2020-03-05 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1346 5b87815e 2020-03-05 stsp ret="$?"
1347 5b87815e 2020-03-05 stsp if [ "$ret" != "0" ]; then
1348 5b87815e 2020-03-05 stsp diff -u $testroot/stderr.expected $testroot/stderr
1349 5b87815e 2020-03-05 stsp fi
1350 de05890f 2020-03-05 stsp test_done "$testroot" "$ret"
1351 de05890f 2020-03-05 stsp
1352 de05890f 2020-03-05 stsp }
1353 ecfff807 2020-09-23 stsp
1354 ecfff807 2020-09-23 stsp # if a previous commit introduces a new file, and it is folded into a commit
1355 ecfff807 2020-09-23 stsp # that deletes the same file, the file still exists after the histedit
1356 ecfff807 2020-09-23 stsp test_histedit_fold_add_delete() {
1357 ecfff807 2020-09-23 stsp local testroot=`test_init histedit_fold`
1358 ecfff807 2020-09-23 stsp
1359 ecfff807 2020-09-23 stsp local orig_commit=`git_show_head $testroot/repo`
1360 ecfff807 2020-09-23 stsp
1361 ecfff807 2020-09-23 stsp echo "added new file epsilon/psi" > $testroot/repo/epsilon/psi
1362 ecfff807 2020-09-23 stsp (cd $testroot/repo && git add epsilon/psi)
1363 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "committing changes"
1364 ecfff807 2020-09-23 stsp local old_commit1=`git_show_head $testroot/repo`
1365 ecfff807 2020-09-23 stsp
1366 ecfff807 2020-09-23 stsp echo "modified epsilon/psi" > $testroot/repo/epsilon/psi
1367 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "editing psi"
1368 ecfff807 2020-09-23 stsp local old_commit2=`git_show_head $testroot/repo`
1369 ecfff807 2020-09-23 stsp
1370 ecfff807 2020-09-23 stsp (cd $testroot/repo && git rm -q epsilon/psi)
1371 ecfff807 2020-09-23 stsp git_commit $testroot/repo -m "removing psi"
1372 ecfff807 2020-09-23 stsp local old_commit3=`git_show_head $testroot/repo`
1373 ecfff807 2020-09-23 stsp
1374 ecfff807 2020-09-23 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1375 ecfff807 2020-09-23 stsp ret="$?"
1376 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1377 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1378 ecfff807 2020-09-23 stsp return 1
1379 ecfff807 2020-09-23 stsp fi
1380 de05890f 2020-03-05 stsp
1381 ecfff807 2020-09-23 stsp echo "fold $old_commit1" > $testroot/histedit-script
1382 ecfff807 2020-09-23 stsp echo "fold $old_commit2" >> $testroot/histedit-script
1383 ecfff807 2020-09-23 stsp echo "pick $old_commit3" >> $testroot/histedit-script
1384 ecfff807 2020-09-23 stsp echo "mesg folded changes" >> $testroot/histedit-script
1385 ecfff807 2020-09-23 stsp
1386 ecfff807 2020-09-23 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1387 ecfff807 2020-09-23 stsp > $testroot/stdout)
1388 ecfff807 2020-09-23 stsp
1389 ecfff807 2020-09-23 stsp local new_commit1=`git_show_head $testroot/repo`
1390 ecfff807 2020-09-23 stsp
1391 ecfff807 2020-09-23 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1392 ecfff807 2020-09-23 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1393 ecfff807 2020-09-23 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1394 ecfff807 2020-09-23 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1395 ecfff807 2020-09-23 stsp
1396 ecfff807 2020-09-23 stsp echo "A epsilon/psi" >> $testroot/stdout.expected
1397 ecfff807 2020-09-23 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1398 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1399 ecfff807 2020-09-23 stsp echo "G epsilon/psi" >> $testroot/stdout.expected
1400 ecfff807 2020-09-23 stsp echo "$short_old_commit2 -> fold commit: editing psi" \
1401 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1402 0a22ca1a 2020-09-23 stsp echo "D epsilon/psi" >> $testroot/stdout.expected
1403 0a22ca1a 2020-09-23 stsp echo "$short_old_commit3 -> no-op change: folded changes" \
1404 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1405 ecfff807 2020-09-23 stsp echo "Switching work tree to refs/heads/master" \
1406 ecfff807 2020-09-23 stsp >> $testroot/stdout.expected
1407 ecfff807 2020-09-23 stsp
1408 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1409 ecfff807 2020-09-23 stsp ret="$?"
1410 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1411 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1412 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1413 ecfff807 2020-09-23 stsp return 1
1414 ecfff807 2020-09-23 stsp fi
1415 ecfff807 2020-09-23 stsp
1416 ecfff807 2020-09-23 stsp if [ -e $testroot/wt/epsilon/psi ]; then
1417 0a22ca1a 2020-09-23 stsp echo "removed file psi still exists on disk" >&2
1418 0a22ca1a 2020-09-23 stsp test_done "$testroot" "1"
1419 ecfff807 2020-09-23 stsp return 1
1420 ecfff807 2020-09-23 stsp fi
1421 ecfff807 2020-09-23 stsp
1422 ecfff807 2020-09-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1423 ecfff807 2020-09-23 stsp
1424 ecfff807 2020-09-23 stsp echo -n > $testroot/stdout.expected
1425 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1426 ecfff807 2020-09-23 stsp ret="$?"
1427 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1428 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1429 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1430 ecfff807 2020-09-23 stsp return 1
1431 ecfff807 2020-09-23 stsp fi
1432 ecfff807 2020-09-23 stsp
1433 ecfff807 2020-09-23 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1434 ecfff807 2020-09-23 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1435 29c68398 2020-09-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1436 29c68398 2020-09-24 stsp ret="$?"
1437 29c68398 2020-09-24 stsp if [ "$ret" != "0" ]; then
1438 29c68398 2020-09-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 29c68398 2020-09-24 stsp test_done "$testroot" "$ret"
1440 29c68398 2020-09-24 stsp return 1
1441 29c68398 2020-09-24 stsp fi
1442 29c68398 2020-09-24 stsp
1443 29c68398 2020-09-24 stsp got tree -r $testroot/repo epsilon > $testroot/stdout
1444 29c68398 2020-09-24 stsp echo "zeta" > $testroot/stdout.expected
1445 ecfff807 2020-09-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1446 ecfff807 2020-09-23 stsp ret="$?"
1447 ecfff807 2020-09-23 stsp if [ "$ret" != "0" ]; then
1448 ecfff807 2020-09-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1449 ecfff807 2020-09-23 stsp fi
1450 ecfff807 2020-09-23 stsp test_done "$testroot" "$ret"
1451 ecfff807 2020-09-23 stsp }
1452 239f5c5a 2020-12-13 stsp
1453 239f5c5a 2020-12-13 stsp test_histedit_fold_only() {
1454 239f5c5a 2020-12-13 stsp local testroot=`test_init histedit_fold_only`
1455 239f5c5a 2020-12-13 stsp
1456 239f5c5a 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1457 239f5c5a 2020-12-13 stsp
1458 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1459 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1460 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1461 239f5c5a 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1462 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1463 239f5c5a 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1464 239f5c5a 2020-12-13 stsp
1465 239f5c5a 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1466 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1467 239f5c5a 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1468 239f5c5a 2020-12-13 stsp
1469 239f5c5a 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1470 239f5c5a 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1471 239f5c5a 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1472 239f5c5a 2020-12-13 stsp
1473 239f5c5a 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1474 239f5c5a 2020-12-13 stsp ret="$?"
1475 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1476 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1477 239f5c5a 2020-12-13 stsp return 1
1478 239f5c5a 2020-12-13 stsp fi
1479 239f5c5a 2020-12-13 stsp
1480 239f5c5a 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1481 239f5c5a 2020-12-13 stsp #!/bin/sh
1482 239f5c5a 2020-12-13 stsp sed -i 's/.*/committing folded changes/' "\$1"
1483 239f5c5a 2020-12-13 stsp EOF
1484 239f5c5a 2020-12-13 stsp chmod +x $testroot/editor.sh
1485 239f5c5a 2020-12-13 stsp
1486 239f5c5a 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1487 239f5c5a 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1488 239f5c5a 2020-12-13 stsp
1489 239f5c5a 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1490 239f5c5a 2020-12-13 stsp
1491 239f5c5a 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1492 239f5c5a 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1493 239f5c5a 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1494 239f5c5a 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1495 239f5c5a 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1496 239f5c5a 2020-12-13 stsp
1497 239f5c5a 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1498 239f5c5a 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1499 239f5c5a 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1500 239f5c5a 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1501 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1502 239f5c5a 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1503 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1504 239f5c5a 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1505 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1506 239f5c5a 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1507 239f5c5a 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1508 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1509 239f5c5a 2020-12-13 stsp echo "committing folded changes" >> $testroot/stdout.expected
1510 239f5c5a 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1511 239f5c5a 2020-12-13 stsp >> $testroot/stdout.expected
1512 ecfff807 2020-09-23 stsp
1513 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1514 239f5c5a 2020-12-13 stsp ret="$?"
1515 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1516 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1517 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1518 239f5c5a 2020-12-13 stsp return 1
1519 239f5c5a 2020-12-13 stsp fi
1520 ecfff807 2020-09-23 stsp
1521 239f5c5a 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1522 239f5c5a 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1523 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1524 239f5c5a 2020-12-13 stsp ret="$?"
1525 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1526 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1527 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1528 239f5c5a 2020-12-13 stsp return 1
1529 239f5c5a 2020-12-13 stsp fi
1530 239f5c5a 2020-12-13 stsp
1531 239f5c5a 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1532 239f5c5a 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1533 239f5c5a 2020-12-13 stsp test_done "$testroot" "1"
1534 239f5c5a 2020-12-13 stsp return 1
1535 239f5c5a 2020-12-13 stsp fi
1536 239f5c5a 2020-12-13 stsp
1537 239f5c5a 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1538 239f5c5a 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1539 239f5c5a 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1540 239f5c5a 2020-12-13 stsp ret="$?"
1541 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1542 239f5c5a 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1543 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1544 239f5c5a 2020-12-13 stsp return 1
1545 239f5c5a 2020-12-13 stsp fi
1546 239f5c5a 2020-12-13 stsp
1547 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1548 239f5c5a 2020-12-13 stsp
1549 239f5c5a 2020-12-13 stsp echo -n > $testroot/stdout.expected
1550 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1551 239f5c5a 2020-12-13 stsp ret="$?"
1552 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1553 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1554 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1555 239f5c5a 2020-12-13 stsp return 1
1556 239f5c5a 2020-12-13 stsp fi
1557 239f5c5a 2020-12-13 stsp
1558 239f5c5a 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1559 239f5c5a 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1560 239f5c5a 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1561 239f5c5a 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1562 239f5c5a 2020-12-13 stsp ret="$?"
1563 239f5c5a 2020-12-13 stsp if [ "$ret" != "0" ]; then
1564 239f5c5a 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1565 239f5c5a 2020-12-13 stsp fi
1566 239f5c5a 2020-12-13 stsp test_done "$testroot" "$ret"
1567 239f5c5a 2020-12-13 stsp }
1568 a347e6bb 2020-12-13 stsp
1569 a347e6bb 2020-12-13 stsp test_histedit_fold_only_empty_logmsg() {
1570 a347e6bb 2020-12-13 stsp local testroot=`test_init histedit_fold_only_empty_logmsg`
1571 a347e6bb 2020-12-13 stsp
1572 a347e6bb 2020-12-13 stsp local orig_commit=`git_show_head $testroot/repo`
1573 a347e6bb 2020-12-13 stsp
1574 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/repo/alpha
1575 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git rm -q beta)
1576 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/repo/epsilon/new
1577 a347e6bb 2020-12-13 stsp (cd $testroot/repo && git add epsilon/new)
1578 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing changes"
1579 a347e6bb 2020-12-13 stsp local old_commit1=`git_show_head $testroot/repo`
1580 239f5c5a 2020-12-13 stsp
1581 a347e6bb 2020-12-13 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1582 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to zeta on master"
1583 a347e6bb 2020-12-13 stsp local old_commit2=`git_show_head $testroot/repo`
1584 a347e6bb 2020-12-13 stsp
1585 a347e6bb 2020-12-13 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
1586 a347e6bb 2020-12-13 stsp git_commit $testroot/repo -m "committing to delta on master"
1587 a347e6bb 2020-12-13 stsp local old_commit3=`git_show_head $testroot/repo`
1588 a347e6bb 2020-12-13 stsp
1589 a347e6bb 2020-12-13 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1590 a347e6bb 2020-12-13 stsp ret="$?"
1591 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1592 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1593 a347e6bb 2020-12-13 stsp return 1
1594 a347e6bb 2020-12-13 stsp fi
1595 a347e6bb 2020-12-13 stsp
1596 a347e6bb 2020-12-13 stsp cat > $testroot/editor.sh <<EOF
1597 a347e6bb 2020-12-13 stsp #!/bin/sh
1598 a347e6bb 2020-12-13 stsp sed -i 'd' "\$1"
1599 a347e6bb 2020-12-13 stsp EOF
1600 a347e6bb 2020-12-13 stsp chmod +x $testroot/editor.sh
1601 a347e6bb 2020-12-13 stsp
1602 a347e6bb 2020-12-13 stsp (cd $testroot/wt && env EDITOR="$testroot/editor.sh" \
1603 a347e6bb 2020-12-13 stsp VISUAL="$testroot/editor.sh" got histedit -f > $testroot/stdout)
1604 a347e6bb 2020-12-13 stsp
1605 a347e6bb 2020-12-13 stsp local new_commit1=`git_show_head $testroot/repo`
1606 a347e6bb 2020-12-13 stsp
1607 a347e6bb 2020-12-13 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
1608 a347e6bb 2020-12-13 stsp local very_short_old_commit1=`trim_obj_id 29 $old_commit1`
1609 a347e6bb 2020-12-13 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
1610 a347e6bb 2020-12-13 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
1611 a347e6bb 2020-12-13 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1612 a347e6bb 2020-12-13 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1613 a347e6bb 2020-12-13 stsp
1614 a347e6bb 2020-12-13 stsp echo "G alpha" > $testroot/stdout.expected
1615 a347e6bb 2020-12-13 stsp echo "D beta" >> $testroot/stdout.expected
1616 a347e6bb 2020-12-13 stsp echo "A epsilon/new" >> $testroot/stdout.expected
1617 a347e6bb 2020-12-13 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
1618 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1619 a347e6bb 2020-12-13 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
1620 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
1621 a347e6bb 2020-12-13 stsp echo "fold commit: committing to zeta on master" \
1622 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1623 a347e6bb 2020-12-13 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1624 a347e6bb 2020-12-13 stsp echo -n "$short_old_commit3 -> $short_new_commit1: " \
1625 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1626 a347e6bb 2020-12-13 stsp echo "# log message of folded commit $very_short_old_commit1" \
1627 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1628 a347e6bb 2020-12-13 stsp echo "Switching work tree to refs/heads/master" \
1629 a347e6bb 2020-12-13 stsp >> $testroot/stdout.expected
1630 a347e6bb 2020-12-13 stsp
1631 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1632 a347e6bb 2020-12-13 stsp ret="$?"
1633 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1634 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1635 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1636 a347e6bb 2020-12-13 stsp return 1
1637 a347e6bb 2020-12-13 stsp fi
1638 a347e6bb 2020-12-13 stsp
1639 a347e6bb 2020-12-13 stsp echo "modified alpha on master" > $testroot/content.expected
1640 a347e6bb 2020-12-13 stsp cat $testroot/wt/alpha > $testroot/content
1641 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1642 a347e6bb 2020-12-13 stsp ret="$?"
1643 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1644 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1645 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1646 a347e6bb 2020-12-13 stsp return 1
1647 a347e6bb 2020-12-13 stsp fi
1648 a347e6bb 2020-12-13 stsp
1649 a347e6bb 2020-12-13 stsp if [ -e $testroot/wt/beta ]; then
1650 a347e6bb 2020-12-13 stsp echo "removed file beta still exists on disk" >&2
1651 a347e6bb 2020-12-13 stsp test_done "$testroot" "1"
1652 a347e6bb 2020-12-13 stsp return 1
1653 a347e6bb 2020-12-13 stsp fi
1654 a347e6bb 2020-12-13 stsp
1655 a347e6bb 2020-12-13 stsp echo "new file on master" > $testroot/content.expected
1656 a347e6bb 2020-12-13 stsp cat $testroot/wt/epsilon/new > $testroot/content
1657 a347e6bb 2020-12-13 stsp cmp -s $testroot/content.expected $testroot/content
1658 a347e6bb 2020-12-13 stsp ret="$?"
1659 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1660 a347e6bb 2020-12-13 stsp diff -u $testroot/content.expected $testroot/content
1661 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1662 a347e6bb 2020-12-13 stsp return 1
1663 a347e6bb 2020-12-13 stsp fi
1664 a347e6bb 2020-12-13 stsp
1665 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
1666 a347e6bb 2020-12-13 stsp
1667 a347e6bb 2020-12-13 stsp echo -n > $testroot/stdout.expected
1668 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1669 a347e6bb 2020-12-13 stsp ret="$?"
1670 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1671 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1672 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1673 a347e6bb 2020-12-13 stsp return 1
1674 a347e6bb 2020-12-13 stsp fi
1675 a347e6bb 2020-12-13 stsp
1676 a347e6bb 2020-12-13 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
1677 a347e6bb 2020-12-13 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1678 a347e6bb 2020-12-13 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1679 a347e6bb 2020-12-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1680 a347e6bb 2020-12-13 stsp ret="$?"
1681 a347e6bb 2020-12-13 stsp if [ "$ret" != "0" ]; then
1682 a347e6bb 2020-12-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1683 a347e6bb 2020-12-13 stsp fi
1684 a347e6bb 2020-12-13 stsp test_done "$testroot" "$ret"
1685 a347e6bb 2020-12-13 stsp }
1686 a347e6bb 2020-12-13 stsp
1687 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1688 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1689 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1690 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1691 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1692 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1693 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1694 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1695 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1696 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1697 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit
1698 c7d20a3f 2019-07-30 stsp run_test test_histedit_outside_refs_heads
1699 0def28b1 2019-08-17 stsp run_test test_histedit_fold_last_commit_swap
1700 de05890f 2020-03-05 stsp run_test test_histedit_split_commit
1701 5b87815e 2020-03-05 stsp run_test test_histedit_duplicate_commit_in_script
1702 ecfff807 2020-09-23 stsp run_test test_histedit_fold_add_delete
1703 239f5c5a 2020-12-13 stsp run_test test_histedit_fold_only
1704 a347e6bb 2020-12-13 stsp run_test test_histedit_fold_only_empty_logmsg