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