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