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 0ebf8283 2019-07-24 stsp function 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 86ac67ee 2019-07-25 stsp fi
136 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
137 0ebf8283 2019-07-24 stsp }
138 0ebf8283 2019-07-24 stsp
139 0ebf8283 2019-07-24 stsp function test_histedit_swap {
140 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_swap`
141 0ebf8283 2019-07-24 stsp
142 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
143 0ebf8283 2019-07-24 stsp
144 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
145 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
146 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
147 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
148 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
149 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
150 0ebf8283 2019-07-24 stsp
151 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
152 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
153 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
154 0ebf8283 2019-07-24 stsp
155 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit2 \
156 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
157 86ac67ee 2019-07-25 stsp
158 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
159 0ebf8283 2019-07-24 stsp ret="$?"
160 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
161 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
162 0ebf8283 2019-07-24 stsp return 1
163 0ebf8283 2019-07-24 stsp fi
164 0ebf8283 2019-07-24 stsp
165 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" > $testroot/histedit-script
166 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" >> $testroot/histedit-script
167 0ebf8283 2019-07-24 stsp
168 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
169 0ebf8283 2019-07-24 stsp > $testroot/stdout)
170 0ebf8283 2019-07-24 stsp
171 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
172 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_head $testroot/repo`
173 0ebf8283 2019-07-24 stsp
174 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
175 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
176 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
177 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
178 0ebf8283 2019-07-24 stsp
179 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" > $testroot/stdout.expected
180 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
181 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
182 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
183 0ebf8283 2019-07-24 stsp echo "G alpha" >> $testroot/stdout.expected
184 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
185 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
186 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
187 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
188 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
189 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
190 0ebf8283 2019-07-24 stsp
191 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
192 0ebf8283 2019-07-24 stsp ret="$?"
193 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
194 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
195 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
196 0ebf8283 2019-07-24 stsp return 1
197 0ebf8283 2019-07-24 stsp fi
198 0ebf8283 2019-07-24 stsp
199 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
200 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
201 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
202 0ebf8283 2019-07-24 stsp ret="$?"
203 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
204 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
205 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
206 0ebf8283 2019-07-24 stsp return 1
207 0ebf8283 2019-07-24 stsp fi
208 0ebf8283 2019-07-24 stsp
209 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
210 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
211 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
212 0ebf8283 2019-07-24 stsp return 1
213 0ebf8283 2019-07-24 stsp fi
214 0ebf8283 2019-07-24 stsp
215 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
216 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
217 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
218 0ebf8283 2019-07-24 stsp ret="$?"
219 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
220 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
221 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
222 0ebf8283 2019-07-24 stsp return 1
223 0ebf8283 2019-07-24 stsp fi
224 0ebf8283 2019-07-24 stsp
225 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
226 0ebf8283 2019-07-24 stsp
227 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
228 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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/stdout.expected $testroot/stdout
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 log -l3 | grep ^commit > $testroot/stdout)
237 0ebf8283 2019-07-24 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
238 0ebf8283 2019-07-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
239 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
240 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
241 0ebf8283 2019-07-24 stsp ret="$?"
242 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
243 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
244 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
245 86ac67ee 2019-07-25 stsp return 1
246 86ac67ee 2019-07-25 stsp fi
247 86ac67ee 2019-07-25 stsp
248 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
249 86ac67ee 2019-07-25 stsp > $testroot/diff
250 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit1/" $testroot/diff.expected
251 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
252 86ac67ee 2019-07-25 stsp ret="$?"
253 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
254 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
255 0ebf8283 2019-07-24 stsp fi
256 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
257 0ebf8283 2019-07-24 stsp }
258 0ebf8283 2019-07-24 stsp
259 0ebf8283 2019-07-24 stsp function test_histedit_drop {
260 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_drop`
261 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
262 0ebf8283 2019-07-24 stsp
263 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
264 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
265 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
266 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
267 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
268 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
269 0ebf8283 2019-07-24 stsp
270 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
271 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
272 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
273 0ebf8283 2019-07-24 stsp
274 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $old_commit1 $old_commit2 \
275 86ac67ee 2019-07-25 stsp > $testroot/diff.expected
276 86ac67ee 2019-07-25 stsp
277 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
278 0ebf8283 2019-07-24 stsp ret="$?"
279 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
280 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
281 0ebf8283 2019-07-24 stsp return 1
282 0ebf8283 2019-07-24 stsp fi
283 0ebf8283 2019-07-24 stsp
284 0ebf8283 2019-07-24 stsp echo "drop $old_commit1" > $testroot/histedit-script
285 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
286 0ebf8283 2019-07-24 stsp
287 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
288 0ebf8283 2019-07-24 stsp > $testroot/stdout)
289 0ebf8283 2019-07-24 stsp
290 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
291 0ebf8283 2019-07-24 stsp
292 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
293 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
294 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
295 0ebf8283 2019-07-24 stsp
296 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> drop commit: committing changes" \
297 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
298 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
299 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
300 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
301 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
302 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
303 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
304 0ebf8283 2019-07-24 stsp
305 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
306 0ebf8283 2019-07-24 stsp ret="$?"
307 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
308 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
310 0ebf8283 2019-07-24 stsp return 1
311 0ebf8283 2019-07-24 stsp fi
312 0ebf8283 2019-07-24 stsp
313 0ebf8283 2019-07-24 stsp for f in alpha beta; do
314 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
315 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
316 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
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/content.expected $testroot/content
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 done
324 0ebf8283 2019-07-24 stsp
325 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/new ]; then
326 0ebf8283 2019-07-24 stsp echo "file new exists on disk but should not" >&2
327 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
328 0ebf8283 2019-07-24 stsp return 1
329 0ebf8283 2019-07-24 stsp fi
330 0ebf8283 2019-07-24 stsp
331 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
332 0ebf8283 2019-07-24 stsp
333 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
334 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
335 0ebf8283 2019-07-24 stsp ret="$?"
336 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
337 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
338 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
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 log -l3 | grep ^commit > $testroot/stdout)
343 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
344 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $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 86ac67ee 2019-07-25 stsp test_done "$testroot" "$ret"
350 86ac67ee 2019-07-25 stsp return 1
351 86ac67ee 2019-07-25 stsp fi
352 86ac67ee 2019-07-25 stsp
353 86ac67ee 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit2 \
354 86ac67ee 2019-07-25 stsp > $testroot/diff
355 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit1/$orig_commit/" $testroot/diff.expected
356 86ac67ee 2019-07-25 stsp sed -i -e "s/$old_commit2/$new_commit2/" $testroot/diff.expected
357 86ac67ee 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
358 86ac67ee 2019-07-25 stsp ret="$?"
359 86ac67ee 2019-07-25 stsp if [ "$ret" != "0" ]; then
360 86ac67ee 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
361 0ebf8283 2019-07-24 stsp fi
362 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
363 0ebf8283 2019-07-24 stsp }
364 0ebf8283 2019-07-24 stsp
365 0ebf8283 2019-07-24 stsp function test_histedit_fold {
366 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold`
367 0ebf8283 2019-07-24 stsp
368 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
369 0ebf8283 2019-07-24 stsp
370 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
371 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
372 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
373 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
374 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
375 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
376 0ebf8283 2019-07-24 stsp
377 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
378 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
379 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
380 3f9de99f 2019-07-24 stsp
381 3f9de99f 2019-07-24 stsp echo "modified delta on master" > $testroot/repo/gamma/delta
382 3f9de99f 2019-07-24 stsp git_commit $testroot/repo -m "committing to delta on master"
383 3f9de99f 2019-07-24 stsp local old_commit3=`git_show_head $testroot/repo`
384 0ebf8283 2019-07-24 stsp
385 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
386 0ebf8283 2019-07-24 stsp ret="$?"
387 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
388 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
389 0ebf8283 2019-07-24 stsp return 1
390 0ebf8283 2019-07-24 stsp fi
391 0ebf8283 2019-07-24 stsp
392 0ebf8283 2019-07-24 stsp echo "fold $old_commit1" > $testroot/histedit-script
393 3f9de99f 2019-07-24 stsp echo "drop $old_commit2" >> $testroot/histedit-script
394 3f9de99f 2019-07-24 stsp echo "pick $old_commit3" >> $testroot/histedit-script
395 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
396 0ebf8283 2019-07-24 stsp
397 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
398 0ebf8283 2019-07-24 stsp > $testroot/stdout)
399 0ebf8283 2019-07-24 stsp
400 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
401 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
402 0ebf8283 2019-07-24 stsp
403 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
404 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
405 3f9de99f 2019-07-24 stsp local short_old_commit3=`trim_obj_id 28 $old_commit3`
406 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
407 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
408 0ebf8283 2019-07-24 stsp
409 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
410 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
411 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
412 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> fold commit: committing changes" \
413 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
414 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit2 -> " >> $testroot/stdout.expected
415 3f9de99f 2019-07-24 stsp echo "drop commit: committing to zeta on master" \
416 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
417 3f9de99f 2019-07-24 stsp echo "G gamma/delta" >> $testroot/stdout.expected
418 3f9de99f 2019-07-24 stsp echo -n "$short_old_commit3 -> $short_new_commit2: " \
419 3f9de99f 2019-07-24 stsp >> $testroot/stdout.expected
420 0ebf8283 2019-07-24 stsp echo "committing folded changes" >> $testroot/stdout.expected
421 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
422 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
423 0ebf8283 2019-07-24 stsp
424 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
425 0ebf8283 2019-07-24 stsp ret="$?"
426 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
427 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
429 0ebf8283 2019-07-24 stsp return 1
430 0ebf8283 2019-07-24 stsp fi
431 0ebf8283 2019-07-24 stsp
432 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/content.expected
433 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
434 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
435 0ebf8283 2019-07-24 stsp ret="$?"
436 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
437 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
438 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
439 0ebf8283 2019-07-24 stsp return 1
440 0ebf8283 2019-07-24 stsp fi
441 0ebf8283 2019-07-24 stsp
442 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
443 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
444 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
445 0ebf8283 2019-07-24 stsp return 1
446 0ebf8283 2019-07-24 stsp fi
447 0ebf8283 2019-07-24 stsp
448 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
449 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
450 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
451 0ebf8283 2019-07-24 stsp ret="$?"
452 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
453 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
454 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
455 0ebf8283 2019-07-24 stsp return 1
456 0ebf8283 2019-07-24 stsp fi
457 0ebf8283 2019-07-24 stsp
458 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
459 0ebf8283 2019-07-24 stsp
460 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
461 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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/stdout.expected $testroot/stdout
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 log -l3 | grep ^commit > $testroot/stdout)
470 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
471 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $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 fi
477 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
478 0ebf8283 2019-07-24 stsp }
479 0ebf8283 2019-07-24 stsp
480 0ebf8283 2019-07-24 stsp function test_histedit_edit {
481 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_edit`
482 0ebf8283 2019-07-24 stsp
483 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
484 0ebf8283 2019-07-24 stsp
485 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
486 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
487 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
488 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
489 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
490 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
491 0ebf8283 2019-07-24 stsp
492 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
493 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
494 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
495 0ebf8283 2019-07-24 stsp
496 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
497 0ebf8283 2019-07-24 stsp ret="$?"
498 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
499 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
500 0ebf8283 2019-07-24 stsp return 1
501 0ebf8283 2019-07-24 stsp fi
502 0ebf8283 2019-07-24 stsp
503 0ebf8283 2019-07-24 stsp echo "edit $old_commit1" > $testroot/histedit-script
504 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
505 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
506 0ebf8283 2019-07-24 stsp
507 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
508 0ebf8283 2019-07-24 stsp > $testroot/stdout)
509 0ebf8283 2019-07-24 stsp
510 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
511 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
512 0ebf8283 2019-07-24 stsp
513 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
514 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
515 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
516 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
517 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
518 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
519 0ebf8283 2019-07-24 stsp ret="$?"
520 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
521 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
523 0ebf8283 2019-07-24 stsp return 1
524 0ebf8283 2019-07-24 stsp fi
525 0ebf8283 2019-07-24 stsp
526 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
527 0ebf8283 2019-07-24 stsp
528 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
529 0ebf8283 2019-07-24 stsp
530 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
531 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
532 0ebf8283 2019-07-24 stsp
533 0ebf8283 2019-07-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
534 0ebf8283 2019-07-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
535 0ebf8283 2019-07-24 stsp
536 0ebf8283 2019-07-24 stsp echo "$short_old_commit1 -> $short_new_commit1: committing changes" \
537 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
538 0ebf8283 2019-07-24 stsp echo "G epsilon/zeta" >> $testroot/stdout.expected
539 0ebf8283 2019-07-24 stsp echo -n "$short_old_commit2 -> $short_new_commit2: " \
540 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
541 0ebf8283 2019-07-24 stsp echo "committing to zeta on master" >> $testroot/stdout.expected
542 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
543 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
544 0ebf8283 2019-07-24 stsp
545 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
546 0ebf8283 2019-07-24 stsp ret="$?"
547 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
548 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
549 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
550 0ebf8283 2019-07-24 stsp return 1
551 0ebf8283 2019-07-24 stsp fi
552 0ebf8283 2019-07-24 stsp
553 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/content.expected
554 0ebf8283 2019-07-24 stsp cat $testroot/wt/alpha > $testroot/content
555 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
556 0ebf8283 2019-07-24 stsp ret="$?"
557 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
558 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
559 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
560 0ebf8283 2019-07-24 stsp return 1
561 0ebf8283 2019-07-24 stsp fi
562 0ebf8283 2019-07-24 stsp
563 0ebf8283 2019-07-24 stsp if [ -e $testroot/wt/beta ]; then
564 0ebf8283 2019-07-24 stsp echo "removed file beta still exists on disk" >&2
565 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
566 0ebf8283 2019-07-24 stsp return 1
567 0ebf8283 2019-07-24 stsp fi
568 0ebf8283 2019-07-24 stsp
569 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
570 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
571 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
572 0ebf8283 2019-07-24 stsp ret="$?"
573 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
574 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
575 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
576 0ebf8283 2019-07-24 stsp return 1
577 0ebf8283 2019-07-24 stsp fi
578 0ebf8283 2019-07-24 stsp
579 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
580 0ebf8283 2019-07-24 stsp
581 0ebf8283 2019-07-24 stsp echo -n > $testroot/stdout.expected
582 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
583 0ebf8283 2019-07-24 stsp ret="$?"
584 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
585 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
586 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
587 0ebf8283 2019-07-24 stsp return 1
588 0ebf8283 2019-07-24 stsp fi
589 0ebf8283 2019-07-24 stsp
590 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
591 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
592 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
593 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
594 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
595 0ebf8283 2019-07-24 stsp ret="$?"
596 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
597 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
598 0ebf8283 2019-07-24 stsp fi
599 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
600 0ebf8283 2019-07-24 stsp }
601 0ebf8283 2019-07-24 stsp
602 0ebf8283 2019-07-24 stsp function test_histedit_fold_last_commit {
603 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_fold_last_commit`
604 0ebf8283 2019-07-24 stsp
605 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
606 0ebf8283 2019-07-24 stsp
607 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
608 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
609 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
610 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
611 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
612 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
613 0ebf8283 2019-07-24 stsp
614 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
615 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
616 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
617 0ebf8283 2019-07-24 stsp
618 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
619 0ebf8283 2019-07-24 stsp ret="$?"
620 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
621 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
622 0ebf8283 2019-07-24 stsp return 1
623 0ebf8283 2019-07-24 stsp fi
624 0ebf8283 2019-07-24 stsp
625 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
626 0ebf8283 2019-07-24 stsp echo "fold $old_commit2" >> $testroot/histedit-script
627 0ebf8283 2019-07-24 stsp echo "mesg committing folded changes" >> $testroot/histedit-script
628 0ebf8283 2019-07-24 stsp
629 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
630 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
631 0ebf8283 2019-07-24 stsp
632 0ebf8283 2019-07-24 stsp ret="$?"
633 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
634 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
635 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
636 0ebf8283 2019-07-24 stsp return 1
637 0ebf8283 2019-07-24 stsp fi
638 0ebf8283 2019-07-24 stsp
639 0ebf8283 2019-07-24 stsp echo "got: last commit in histedit script cannot be folded" \
640 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
641 0ebf8283 2019-07-24 stsp
642 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
643 0ebf8283 2019-07-24 stsp ret="$?"
644 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
645 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
646 0ebf8283 2019-07-24 stsp fi
647 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
648 0ebf8283 2019-07-24 stsp }
649 0ebf8283 2019-07-24 stsp
650 0ebf8283 2019-07-24 stsp function test_histedit_missing_commit {
651 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_missing_commit`
652 0ebf8283 2019-07-24 stsp
653 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
654 0ebf8283 2019-07-24 stsp
655 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
656 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
657 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
658 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
659 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
660 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
661 0ebf8283 2019-07-24 stsp
662 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
663 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
664 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
665 0ebf8283 2019-07-24 stsp
666 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
667 0ebf8283 2019-07-24 stsp ret="$?"
668 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
669 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
670 0ebf8283 2019-07-24 stsp return 1
671 0ebf8283 2019-07-24 stsp fi
672 0ebf8283 2019-07-24 stsp
673 0ebf8283 2019-07-24 stsp echo "pick $old_commit1" > $testroot/histedit-script
674 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
675 0ebf8283 2019-07-24 stsp
676 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
677 0ebf8283 2019-07-24 stsp > $testroot/stdout 2> $testroot/stderr)
678 0ebf8283 2019-07-24 stsp
679 0ebf8283 2019-07-24 stsp ret="$?"
680 0ebf8283 2019-07-24 stsp if [ "$ret" == "0" ]; then
681 0ebf8283 2019-07-24 stsp echo "histedit succeeded unexpectedly" >&2
682 0ebf8283 2019-07-24 stsp test_done "$testroot" "1"
683 0ebf8283 2019-07-24 stsp return 1
684 0ebf8283 2019-07-24 stsp fi
685 0ebf8283 2019-07-24 stsp
686 0ebf8283 2019-07-24 stsp echo "got: commit $old_commit2 missing from histedit script" \
687 0ebf8283 2019-07-24 stsp > $testroot/stderr.expected
688 0ebf8283 2019-07-24 stsp
689 0ebf8283 2019-07-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
690 0ebf8283 2019-07-24 stsp ret="$?"
691 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
692 0ebf8283 2019-07-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
693 0ebf8283 2019-07-24 stsp fi
694 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
695 0ebf8283 2019-07-24 stsp }
696 0ebf8283 2019-07-24 stsp
697 0ebf8283 2019-07-24 stsp function test_histedit_abort {
698 0ebf8283 2019-07-24 stsp local testroot=`test_init histedit_abort`
699 0ebf8283 2019-07-24 stsp
700 0ebf8283 2019-07-24 stsp local orig_commit=`git_show_head $testroot/repo`
701 0ebf8283 2019-07-24 stsp
702 0ebf8283 2019-07-24 stsp echo "modified alpha on master" > $testroot/repo/alpha
703 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git rm -q beta)
704 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/repo/epsilon/new
705 0ebf8283 2019-07-24 stsp (cd $testroot/repo && git add epsilon/new)
706 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing changes"
707 0ebf8283 2019-07-24 stsp local old_commit1=`git_show_head $testroot/repo`
708 0ebf8283 2019-07-24 stsp
709 0ebf8283 2019-07-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
710 0ebf8283 2019-07-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
711 0ebf8283 2019-07-24 stsp local old_commit2=`git_show_head $testroot/repo`
712 0ebf8283 2019-07-24 stsp
713 0ebf8283 2019-07-24 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
714 0ebf8283 2019-07-24 stsp ret="$?"
715 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
716 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
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 "edit $old_commit1" > $testroot/histedit-script
721 0ebf8283 2019-07-24 stsp echo "mesg committing changes" >> $testroot/histedit-script
722 0ebf8283 2019-07-24 stsp echo "pick $old_commit2" >> $testroot/histedit-script
723 0ebf8283 2019-07-24 stsp
724 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
725 0ebf8283 2019-07-24 stsp > $testroot/stdout)
726 0ebf8283 2019-07-24 stsp
727 0ebf8283 2019-07-24 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
728 0ebf8283 2019-07-24 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
729 0ebf8283 2019-07-24 stsp
730 0ebf8283 2019-07-24 stsp echo "G alpha" > $testroot/stdout.expected
731 0ebf8283 2019-07-24 stsp echo "D beta" >> $testroot/stdout.expected
732 0ebf8283 2019-07-24 stsp echo "A epsilon/new" >> $testroot/stdout.expected
733 0ebf8283 2019-07-24 stsp echo "Stopping histedit for amending commit $old_commit1" \
734 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
735 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
736 0ebf8283 2019-07-24 stsp ret="$?"
737 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
738 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
740 0ebf8283 2019-07-24 stsp return 1
741 0ebf8283 2019-07-24 stsp fi
742 0ebf8283 2019-07-24 stsp
743 0ebf8283 2019-07-24 stsp echo "edited modified alpha on master" > $testroot/wt/alpha
744 0ebf8283 2019-07-24 stsp
745 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got histedit -a > $testroot/stdout)
746 0ebf8283 2019-07-24 stsp
747 0ebf8283 2019-07-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
748 0ebf8283 2019-07-24 stsp local new_commit2=`git_show_head $testroot/repo`
749 0ebf8283 2019-07-24 stsp
750 0ebf8283 2019-07-24 stsp echo "Switching work tree to refs/heads/master" \
751 0ebf8283 2019-07-24 stsp > $testroot/stdout.expected
752 0ebf8283 2019-07-24 stsp echo "R alpha" >> $testroot/stdout.expected
753 0ebf8283 2019-07-24 stsp echo "R beta" >> $testroot/stdout.expected
754 0ebf8283 2019-07-24 stsp echo "R epsilon/new" >> $testroot/stdout.expected
755 0ebf8283 2019-07-24 stsp echo "Histedit of refs/heads/master aborted" \
756 0ebf8283 2019-07-24 stsp >> $testroot/stdout.expected
757 0ebf8283 2019-07-24 stsp
758 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
759 0ebf8283 2019-07-24 stsp ret="$?"
760 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
761 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
762 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
763 0ebf8283 2019-07-24 stsp return 1
764 0ebf8283 2019-07-24 stsp fi
765 0ebf8283 2019-07-24 stsp
766 0ebf8283 2019-07-24 stsp for f in alpha beta; do
767 0ebf8283 2019-07-24 stsp echo "$f" > $testroot/content.expected
768 0ebf8283 2019-07-24 stsp cat $testroot/wt/$f > $testroot/content
769 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
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/content.expected $testroot/content
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 done
777 0ebf8283 2019-07-24 stsp
778 0ebf8283 2019-07-24 stsp echo "new file on master" > $testroot/content.expected
779 0ebf8283 2019-07-24 stsp cat $testroot/wt/epsilon/new > $testroot/content
780 0ebf8283 2019-07-24 stsp cmp -s $testroot/content.expected $testroot/content
781 0ebf8283 2019-07-24 stsp ret="$?"
782 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
783 0ebf8283 2019-07-24 stsp diff -u $testroot/content.expected $testroot/content
784 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
785 0ebf8283 2019-07-24 stsp return 1
786 0ebf8283 2019-07-24 stsp fi
787 0ebf8283 2019-07-24 stsp
788 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
789 0ebf8283 2019-07-24 stsp
790 0ebf8283 2019-07-24 stsp echo "? epsilon/new" > $testroot/stdout.expected
791 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
792 0ebf8283 2019-07-24 stsp ret="$?"
793 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
794 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
795 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
796 0ebf8283 2019-07-24 stsp return 1
797 0ebf8283 2019-07-24 stsp fi
798 0ebf8283 2019-07-24 stsp
799 0ebf8283 2019-07-24 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
800 0ebf8283 2019-07-24 stsp echo "commit $new_commit2 (master)" > $testroot/stdout.expected
801 0ebf8283 2019-07-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
802 0ebf8283 2019-07-24 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
803 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
804 0160a755 2019-07-25 stsp ret="$?"
805 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
806 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
807 0160a755 2019-07-25 stsp fi
808 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
809 0160a755 2019-07-25 stsp }
810 0160a755 2019-07-25 stsp
811 a4027091 2019-07-25 stsp function test_histedit_path_prefix_drop {
812 a4027091 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_drop`
813 0160a755 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
814 0160a755 2019-07-25 stsp
815 0160a755 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
816 0160a755 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
817 0160a755 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
818 0160a755 2019-07-25 stsp
819 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
820 0160a755 2019-07-25 stsp $testroot/wt > /dev/null
821 0160a755 2019-07-25 stsp ret="$?"
822 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
823 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
824 0160a755 2019-07-25 stsp return 1
825 0160a755 2019-07-25 stsp fi
826 0160a755 2019-07-25 stsp
827 0160a755 2019-07-25 stsp echo "drop $old_commit1" > $testroot/histedit-script
828 0160a755 2019-07-25 stsp
829 0160a755 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
830 0160a755 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
831 0160a755 2019-07-25 stsp
832 0160a755 2019-07-25 stsp ret="$?"
833 0160a755 2019-07-25 stsp if [ "$ret" == "0" ]; then
834 0160a755 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
835 0160a755 2019-07-25 stsp test_done "$testroot" "1"
836 0160a755 2019-07-25 stsp return 1
837 0160a755 2019-07-25 stsp fi
838 0160a755 2019-07-25 stsp
839 0160a755 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
840 0160a755 2019-07-25 stsp > $testroot/stderr.expected
841 0160a755 2019-07-25 stsp echo "outside of this work tree's path prefix" \
842 0160a755 2019-07-25 stsp >> $testroot/stderr.expected
843 0160a755 2019-07-25 stsp
844 0160a755 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
845 0160a755 2019-07-25 stsp ret="$?"
846 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
847 0160a755 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
848 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
849 0160a755 2019-07-25 stsp return 1
850 0160a755 2019-07-25 stsp fi
851 0160a755 2019-07-25 stsp
852 0160a755 2019-07-25 stsp rm -rf $testroot/wt
853 0160a755 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $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 (cd $testroot/wt && got histedit -F $testroot/histedit-script \
861 0160a755 2019-07-25 stsp > $testroot/stdout)
862 0160a755 2019-07-25 stsp
863 0160a755 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
864 0160a755 2019-07-25 stsp local short_old_commit2=`trim_obj_id 28 $old_commit2`
865 0160a755 2019-07-25 stsp
866 0160a755 2019-07-25 stsp echo "$short_old_commit1 -> drop commit: changing zeta" \
867 0160a755 2019-07-25 stsp > $testroot/stdout.expected
868 0160a755 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
869 0160a755 2019-07-25 stsp >> $testroot/stdout.expected
870 0160a755 2019-07-25 stsp
871 0ebf8283 2019-07-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
872 0ebf8283 2019-07-24 stsp ret="$?"
873 0ebf8283 2019-07-24 stsp if [ "$ret" != "0" ]; then
874 0ebf8283 2019-07-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
875 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
876 0160a755 2019-07-25 stsp return 1
877 0ebf8283 2019-07-24 stsp fi
878 0160a755 2019-07-25 stsp
879 0160a755 2019-07-25 stsp echo "zeta" > $testroot/content.expected
880 0160a755 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
881 0160a755 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
882 0160a755 2019-07-25 stsp ret="$?"
883 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
884 0160a755 2019-07-25 stsp diff -u $testroot/content.expected $testroot/content
885 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
886 0160a755 2019-07-25 stsp return 1
887 0160a755 2019-07-25 stsp fi
888 0160a755 2019-07-25 stsp
889 0160a755 2019-07-25 stsp
890 0160a755 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
891 0160a755 2019-07-25 stsp
892 0160a755 2019-07-25 stsp echo -n > $testroot/stdout.expected
893 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
894 0160a755 2019-07-25 stsp ret="$?"
895 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
896 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 0160a755 2019-07-25 stsp test_done "$testroot" "$ret"
898 0160a755 2019-07-25 stsp return 1
899 0160a755 2019-07-25 stsp fi
900 0160a755 2019-07-25 stsp
901 0160a755 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
902 0160a755 2019-07-25 stsp echo "commit $orig_commit (master)" > $testroot/stdout.expected
903 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
904 b2c50a0a 2019-07-25 stsp ret="$?"
905 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
906 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
907 b2c50a0a 2019-07-25 stsp fi
908 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
909 b2c50a0a 2019-07-25 stsp }
910 b2c50a0a 2019-07-25 stsp
911 b2c50a0a 2019-07-25 stsp function test_histedit_path_prefix_edit {
912 b2c50a0a 2019-07-25 stsp local testroot=`test_init histedit_path_prefix_edit`
913 b2c50a0a 2019-07-25 stsp local orig_commit=`git_show_head $testroot/repo`
914 b2c50a0a 2019-07-25 stsp
915 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
916 b2c50a0a 2019-07-25 stsp git_commit $testroot/repo -m "changing zeta"
917 b2c50a0a 2019-07-25 stsp local old_commit1=`git_show_head $testroot/repo`
918 b2c50a0a 2019-07-25 stsp
919 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $old_commit1 \
920 b2c50a0a 2019-07-25 stsp > $testroot/diff.expected
921 b2c50a0a 2019-07-25 stsp
922 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p gamma $testroot/repo \
923 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
924 b2c50a0a 2019-07-25 stsp ret="$?"
925 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
926 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
927 b2c50a0a 2019-07-25 stsp return 1
928 b2c50a0a 2019-07-25 stsp fi
929 b2c50a0a 2019-07-25 stsp
930 b2c50a0a 2019-07-25 stsp echo "edit $old_commit1" > $testroot/histedit-script
931 b2c50a0a 2019-07-25 stsp echo "mesg modified zeta" >> $testroot/histedit-script
932 b2c50a0a 2019-07-25 stsp
933 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
934 b2c50a0a 2019-07-25 stsp > $testroot/stdout 2> $testroot/stderr)
935 b2c50a0a 2019-07-25 stsp
936 b2c50a0a 2019-07-25 stsp ret="$?"
937 b2c50a0a 2019-07-25 stsp if [ "$ret" == "0" ]; then
938 b2c50a0a 2019-07-25 stsp echo "histedit succeeded unexpectedly" >&2
939 b2c50a0a 2019-07-25 stsp test_done "$testroot" "1"
940 b2c50a0a 2019-07-25 stsp return 1
941 b2c50a0a 2019-07-25 stsp fi
942 b2c50a0a 2019-07-25 stsp
943 b2c50a0a 2019-07-25 stsp echo -n "got: cannot edit branch history which contains changes " \
944 b2c50a0a 2019-07-25 stsp > $testroot/stderr.expected
945 b2c50a0a 2019-07-25 stsp echo "outside of this work tree's path prefix" \
946 b2c50a0a 2019-07-25 stsp >> $testroot/stderr.expected
947 b2c50a0a 2019-07-25 stsp
948 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stderr.expected $testroot/stderr
949 b2c50a0a 2019-07-25 stsp ret="$?"
950 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
951 b2c50a0a 2019-07-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
952 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
953 b2c50a0a 2019-07-25 stsp return 1
954 b2c50a0a 2019-07-25 stsp fi
955 b2c50a0a 2019-07-25 stsp
956 b2c50a0a 2019-07-25 stsp rm -rf $testroot/wt
957 b2c50a0a 2019-07-25 stsp got checkout -c $orig_commit -p epsilon $testroot/repo \
958 b2c50a0a 2019-07-25 stsp $testroot/wt > /dev/null
959 b2c50a0a 2019-07-25 stsp ret="$?"
960 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
961 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
962 b2c50a0a 2019-07-25 stsp return 1
963 b2c50a0a 2019-07-25 stsp fi
964 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
965 b2c50a0a 2019-07-25 stsp > $testroot/stdout)
966 b2c50a0a 2019-07-25 stsp
967 b2c50a0a 2019-07-25 stsp local short_old_commit1=`trim_obj_id 28 $old_commit1`
968 b2c50a0a 2019-07-25 stsp
969 b2c50a0a 2019-07-25 stsp echo "G zeta" > $testroot/stdout.expected
970 b2c50a0a 2019-07-25 stsp echo "Stopping histedit for amending commit $old_commit1" \
971 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
972 0160a755 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
973 0160a755 2019-07-25 stsp ret="$?"
974 0160a755 2019-07-25 stsp if [ "$ret" != "0" ]; then
975 0160a755 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
976 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
977 b2c50a0a 2019-07-25 stsp return 1
978 0160a755 2019-07-25 stsp fi
979 b2c50a0a 2019-07-25 stsp
980 b2c50a0a 2019-07-25 stsp echo "modified zeta" > $testroot/content.expected
981 b2c50a0a 2019-07-25 stsp cat $testroot/wt/zeta > $testroot/content
982 b2c50a0a 2019-07-25 stsp cmp -s $testroot/content.expected $testroot/content
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/content.expected $testroot/content
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 (cd $testroot/wt && got status > $testroot/stdout)
991 b2c50a0a 2019-07-25 stsp
992 b2c50a0a 2019-07-25 stsp echo "M zeta"> $testroot/stdout.expected
993 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
994 b2c50a0a 2019-07-25 stsp ret="$?"
995 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
996 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
997 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
998 b2c50a0a 2019-07-25 stsp return 1
999 b2c50a0a 2019-07-25 stsp fi
1000 b2c50a0a 2019-07-25 stsp
1001 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got histedit -c > $testroot/stdout)
1002 b2c50a0a 2019-07-25 stsp
1003 b2c50a0a 2019-07-25 stsp local new_commit1=`git_show_head $testroot/repo`
1004 b2c50a0a 2019-07-25 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1005 b2c50a0a 2019-07-25 stsp
1006 b2c50a0a 2019-07-25 stsp echo -n "$short_old_commit1 -> $short_new_commit1: " \
1007 b2c50a0a 2019-07-25 stsp > $testroot/stdout.expected
1008 b2c50a0a 2019-07-25 stsp echo "modified zeta" >> $testroot/stdout.expected
1009 b2c50a0a 2019-07-25 stsp echo "Switching work tree to refs/heads/master" \
1010 b2c50a0a 2019-07-25 stsp >> $testroot/stdout.expected
1011 b2c50a0a 2019-07-25 stsp
1012 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1013 b2c50a0a 2019-07-25 stsp ret="$?"
1014 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1015 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1016 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1017 b2c50a0a 2019-07-25 stsp return 1
1018 b2c50a0a 2019-07-25 stsp fi
1019 b2c50a0a 2019-07-25 stsp
1020 b2c50a0a 2019-07-25 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1021 b2c50a0a 2019-07-25 stsp echo "commit $new_commit1 (master)" > $testroot/stdout.expected
1022 b2c50a0a 2019-07-25 stsp echo "commit $orig_commit" >> $testroot/stdout.expected
1023 b2c50a0a 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1024 b2c50a0a 2019-07-25 stsp ret="$?"
1025 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1026 b2c50a0a 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
1027 b2c50a0a 2019-07-25 stsp test_done "$testroot" "$ret"
1028 b2c50a0a 2019-07-25 stsp return 1
1029 b2c50a0a 2019-07-25 stsp fi
1030 b2c50a0a 2019-07-25 stsp
1031 b2c50a0a 2019-07-25 stsp got diff -r $testroot/repo $orig_commit $new_commit1 \
1032 b2c50a0a 2019-07-25 stsp > $testroot/diff
1033 b2c50a0a 2019-07-25 stsp sed -i -e "s/$old_commit1/$new_commit1/" $testroot/diff.expected
1034 b2c50a0a 2019-07-25 stsp cmp -s $testroot/diff.expected $testroot/diff
1035 b2c50a0a 2019-07-25 stsp ret="$?"
1036 b2c50a0a 2019-07-25 stsp if [ "$ret" != "0" ]; then
1037 b2c50a0a 2019-07-25 stsp diff -u $testroot/diff.expected $testroot/diff
1038 b2c50a0a 2019-07-25 stsp fi
1039 0ebf8283 2019-07-24 stsp test_done "$testroot" "$ret"
1040 0ebf8283 2019-07-24 stsp }
1041 0ebf8283 2019-07-24 stsp
1042 0ebf8283 2019-07-24 stsp run_test test_histedit_no_op
1043 0ebf8283 2019-07-24 stsp run_test test_histedit_swap
1044 0ebf8283 2019-07-24 stsp run_test test_histedit_drop
1045 0ebf8283 2019-07-24 stsp run_test test_histedit_fold
1046 0ebf8283 2019-07-24 stsp run_test test_histedit_edit
1047 0ebf8283 2019-07-24 stsp run_test test_histedit_fold_last_commit
1048 0ebf8283 2019-07-24 stsp run_test test_histedit_missing_commit
1049 0ebf8283 2019-07-24 stsp run_test test_histedit_abort
1050 a4027091 2019-07-25 stsp run_test test_histedit_path_prefix_drop
1051 b2c50a0a 2019-07-25 stsp run_test test_histedit_path_prefix_edit