Blame


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