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