Blame


1 818c7501 2019-07-11 stsp #!/bin/sh
2 818c7501 2019-07-11 stsp #
3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 818c7501 2019-07-11 stsp #
5 818c7501 2019-07-11 stsp # Permission to use, copy, modify, and distribute this software for any
6 818c7501 2019-07-11 stsp # purpose with or without fee is hereby granted, provided that the above
7 818c7501 2019-07-11 stsp # copyright notice and this permission notice appear in all copies.
8 818c7501 2019-07-11 stsp #
9 818c7501 2019-07-11 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 818c7501 2019-07-11 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 818c7501 2019-07-11 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 818c7501 2019-07-11 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 818c7501 2019-07-11 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 818c7501 2019-07-11 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 818c7501 2019-07-11 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 818c7501 2019-07-11 stsp
17 818c7501 2019-07-11 stsp . ./common.sh
18 818c7501 2019-07-11 stsp
19 f6cae3ed 2020-09-13 naddy test_rebase_basic() {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
21 e600f124 2021-03-21 stsp local commit0=`git_show_head $testroot/repo`
22 e600f124 2021-03-21 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
23 818c7501 2019-07-11 stsp
24 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
27 818c7501 2019-07-11 stsp
28 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
30 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
31 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
32 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
33 818c7501 2019-07-11 stsp
34 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
35 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
36 e600f124 2021-03-21 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
37 818c7501 2019-07-11 stsp
38 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
39 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
40 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
41 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
42 818c7501 2019-07-11 stsp
43 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
44 fc414659 2022-04-16 thomas ret=$?
45 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
46 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
47 818c7501 2019-07-11 stsp return 1
48 818c7501 2019-07-11 stsp fi
49 818c7501 2019-07-11 stsp
50 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
51 818c7501 2019-07-11 stsp
52 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
53 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
54 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
55 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
56 818c7501 2019-07-11 stsp
57 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
58 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
59 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
61 818c7501 2019-07-11 stsp
62 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
64 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
66 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
68 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
72 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
73 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
74 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
75 818c7501 2019-07-11 stsp
76 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
77 fc414659 2022-04-16 thomas ret=$?
78 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
79 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
81 818c7501 2019-07-11 stsp return 1
82 818c7501 2019-07-11 stsp fi
83 818c7501 2019-07-11 stsp
84 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/content.expected
85 818c7501 2019-07-11 stsp cat $testroot/wt/gamma/delta > $testroot/content
86 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
87 fc414659 2022-04-16 thomas ret=$?
88 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
89 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
90 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
91 818c7501 2019-07-11 stsp return 1
92 818c7501 2019-07-11 stsp fi
93 818c7501 2019-07-11 stsp
94 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/content.expected
95 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
96 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
97 fc414659 2022-04-16 thomas ret=$?
98 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
99 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
100 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
101 818c7501 2019-07-11 stsp return 1
102 818c7501 2019-07-11 stsp fi
103 818c7501 2019-07-11 stsp
104 818c7501 2019-07-11 stsp if [ -e $testroot/wt/beta ]; then
105 818c7501 2019-07-11 stsp echo "removed file beta still exists on disk" >&2
106 818c7501 2019-07-11 stsp test_done "$testroot" "1"
107 818c7501 2019-07-11 stsp return 1
108 818c7501 2019-07-11 stsp fi
109 818c7501 2019-07-11 stsp
110 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/content.expected
111 818c7501 2019-07-11 stsp cat $testroot/wt/epsilon/new > $testroot/content
112 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
113 fc414659 2022-04-16 thomas ret=$?
114 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
115 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
116 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
117 818c7501 2019-07-11 stsp return 1
118 818c7501 2019-07-11 stsp fi
119 818c7501 2019-07-11 stsp
120 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
121 818c7501 2019-07-11 stsp
122 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
123 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
124 fc414659 2022-04-16 thomas ret=$?
125 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
126 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
128 818c7501 2019-07-11 stsp return 1
129 818c7501 2019-07-11 stsp fi
130 818c7501 2019-07-11 stsp
131 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
132 818c7501 2019-07-11 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
133 818c7501 2019-07-11 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
134 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
135 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
136 fc414659 2022-04-16 thomas ret=$?
137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
138 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
140 a615e0e7 2020-12-16 stsp return 1
141 818c7501 2019-07-11 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 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
147 fc414659 2022-04-16 thomas ret=$?
148 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
149 a615e0e7 2020-12-16 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 a615e0e7 2020-12-16 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 rebase -l > $testroot/stdout)
156 1c72bab5 2023-03-03 thomas d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
157 1c72bab5 2023-03-03 thomas d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
158 1c72bab5 2023-03-03 thomas d_0=`date -u -r $commit0_author_time +"%G-%m-%d"`
159 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
160 e600f124 2021-03-21 stsp -----------------------------------------------
161 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
162 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
163 e600f124 2021-03-21 stsp date: $d_orig2
164 e600f124 2021-03-21 stsp
165 e600f124 2021-03-21 stsp committing more changes on newbranch
166 e600f124 2021-03-21 stsp
167 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
168 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
169 e600f124 2021-03-21 stsp history forked at $commit0
170 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
171 e600f124 2021-03-21 stsp EOF
172 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 fc414659 2022-04-16 thomas ret=$?
174 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
175 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
177 a9662115 2021-08-29 naddy return 1
178 e600f124 2021-03-21 stsp fi
179 9e822917 2021-03-23 stsp
180 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
181 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
182 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
183 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
184 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
185 9e822917 2021-03-23 stsp > $testroot/stderr.expected
186 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 fc414659 2022-04-16 thomas ret=$?
188 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
189 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
191 643b85bc 2021-07-16 stsp return 1
192 9e822917 2021-03-23 stsp fi
193 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
194 fc414659 2022-04-16 thomas ret=$?
195 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
196 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
197 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
198 643b85bc 2021-07-16 stsp return 1
199 9e822917 2021-03-23 stsp fi
200 643b85bc 2021-07-16 stsp
201 643b85bc 2021-07-16 stsp # Delete all backup refs
202 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
203 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
204 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
205 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
206 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
207 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
208 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 fc414659 2022-04-16 thomas ret=$?
210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
211 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
213 643b85bc 2021-07-16 stsp return 1
214 643b85bc 2021-07-16 stsp fi
215 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
216 fc414659 2022-04-16 thomas ret=$?
217 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
218 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
219 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
220 643b85bc 2021-07-16 stsp return 1
221 643b85bc 2021-07-16 stsp fi
222 643b85bc 2021-07-16 stsp
223 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
224 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
225 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
226 fc414659 2022-04-16 thomas ret=$?
227 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
228 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 643b85bc 2021-07-16 stsp fi
230 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
231 818c7501 2019-07-11 stsp }
232 818c7501 2019-07-11 stsp
233 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
234 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
235 818c7501 2019-07-11 stsp
236 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
237 fc414659 2022-04-16 thomas ret=$?
238 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
239 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
240 818c7501 2019-07-11 stsp return 1
241 818c7501 2019-07-11 stsp fi
242 818c7501 2019-07-11 stsp
243 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
244 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
245 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
246 82d979c5 2021-11-04 thomas local newbranch_id=`git_show_head $testroot/repo`
247 818c7501 2019-07-11 stsp
248 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
249 818c7501 2019-07-11 stsp 2> $testroot/stderr)
250 818c7501 2019-07-11 stsp
251 82d979c5 2021-11-04 thomas echo "refs/heads/newbranch is already based on refs/heads/master" \
252 82d979c5 2021-11-04 thomas > $testroot/stdout.expected
253 82d979c5 2021-11-04 thomas echo "Switching work tree from refs/heads/master to refs/heads/newbranch" \
254 82d979c5 2021-11-04 thomas >> $testroot/stdout.expected
255 82d979c5 2021-11-04 thomas echo "U gamma/delta" >> $testroot/stdout.expected
256 82d979c5 2021-11-04 thomas echo "Updated to refs/heads/newbranch: ${newbranch_id}" \
257 82d979c5 2021-11-04 thomas >> $testroot/stdout.expected
258 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
259 fc414659 2022-04-16 thomas ret=$?
260 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
261 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
263 818c7501 2019-07-11 stsp return 1
264 818c7501 2019-07-11 stsp fi
265 818c7501 2019-07-11 stsp
266 82d979c5 2021-11-04 thomas echo -n > $testroot/stderr.expected
267 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
268 fc414659 2022-04-16 thomas ret=$?
269 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
270 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
271 818c7501 2019-07-11 stsp fi
272 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
273 818c7501 2019-07-11 stsp }
274 818c7501 2019-07-11 stsp
275 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
276 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
277 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
278 818c7501 2019-07-11 stsp
279 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
280 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
281 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
282 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
283 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
284 818c7501 2019-07-11 stsp
285 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
286 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
287 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
288 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
289 818c7501 2019-07-11 stsp
290 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
291 fc414659 2022-04-16 thomas ret=$?
292 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
293 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
294 818c7501 2019-07-11 stsp return 1
295 818c7501 2019-07-11 stsp fi
296 818c7501 2019-07-11 stsp
297 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
298 818c7501 2019-07-11 stsp 2> $testroot/stderr)
299 818c7501 2019-07-11 stsp
300 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
301 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
302 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
303 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
304 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
305 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
306 fc414659 2022-04-16 thomas ret=$?
307 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
308 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
310 818c7501 2019-07-11 stsp return 1
311 818c7501 2019-07-11 stsp fi
312 818c7501 2019-07-11 stsp
313 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
314 818c7501 2019-07-11 stsp > $testroot/stderr.expected
315 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
316 fc414659 2022-04-16 thomas ret=$?
317 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
318 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
319 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
320 818c7501 2019-07-11 stsp return 1
321 818c7501 2019-07-11 stsp fi
322 818c7501 2019-07-11 stsp
323 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
324 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
325 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
326 f69721c3 2019-10-21 stsp >> $testroot/content.expected
327 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
328 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
329 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
330 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
331 54d5be07 2021-06-03 stsp >> $testroot/content.expected
332 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
333 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
334 fc414659 2022-04-16 thomas ret=$?
335 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
336 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
337 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
338 818c7501 2019-07-11 stsp return 1
339 818c7501 2019-07-11 stsp fi
340 818c7501 2019-07-11 stsp
341 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
342 818c7501 2019-07-11 stsp
343 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
344 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
345 fc414659 2022-04-16 thomas ret=$?
346 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
347 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
348 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
349 818c7501 2019-07-11 stsp return 1
350 818c7501 2019-07-11 stsp fi
351 818c7501 2019-07-11 stsp
352 818c7501 2019-07-11 stsp # resolve the conflict
353 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
354 818c7501 2019-07-11 stsp
355 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
356 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
357 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
358 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
359 fc414659 2022-04-16 thomas ret=$?
360 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
361 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
362 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
363 f032f1f7 2019-08-04 stsp return 1
364 f032f1f7 2019-08-04 stsp fi
365 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
366 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
367 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
368 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
369 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
370 fc414659 2022-04-16 thomas ret=$?
371 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
372 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
373 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
374 f032f1f7 2019-08-04 stsp return 1
375 f032f1f7 2019-08-04 stsp fi
376 f032f1f7 2019-08-04 stsp
377 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
378 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
379 818c7501 2019-07-11 stsp
380 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
381 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
382 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
383 818c7501 2019-07-11 stsp
384 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
385 818c7501 2019-07-11 stsp > $testroot/stdout.expected
386 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
387 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
388 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
389 818c7501 2019-07-11 stsp
390 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
391 fc414659 2022-04-16 thomas ret=$?
392 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
393 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
394 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
395 818c7501 2019-07-11 stsp return 1
396 818c7501 2019-07-11 stsp fi
397 818c7501 2019-07-11 stsp
398 818c7501 2019-07-11 stsp
399 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
400 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
401 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
402 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
403 fc414659 2022-04-16 thomas ret=$?
404 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
405 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
406 818c7501 2019-07-11 stsp fi
407 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
408 818c7501 2019-07-11 stsp }
409 818c7501 2019-07-11 stsp
410 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
411 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
412 818c7501 2019-07-11 stsp
413 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
414 818c7501 2019-07-11 stsp
415 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
416 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
417 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
418 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
419 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
420 818c7501 2019-07-11 stsp
421 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
422 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
423 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
424 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
425 818c7501 2019-07-11 stsp
426 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
427 fc414659 2022-04-16 thomas ret=$?
428 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
429 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
430 818c7501 2019-07-11 stsp return 1
431 818c7501 2019-07-11 stsp fi
432 d52bac28 2021-10-08 thomas
433 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
434 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
435 818c7501 2019-07-11 stsp
436 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
437 818c7501 2019-07-11 stsp 2> $testroot/stderr)
438 818c7501 2019-07-11 stsp
439 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
440 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
441 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
442 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
443 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
444 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 fc414659 2022-04-16 thomas ret=$?
446 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
447 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
449 818c7501 2019-07-11 stsp return 1
450 818c7501 2019-07-11 stsp fi
451 818c7501 2019-07-11 stsp
452 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
453 818c7501 2019-07-11 stsp > $testroot/stderr.expected
454 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
455 fc414659 2022-04-16 thomas ret=$?
456 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
457 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
458 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
459 818c7501 2019-07-11 stsp return 1
460 818c7501 2019-07-11 stsp fi
461 818c7501 2019-07-11 stsp
462 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
463 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
464 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
465 f69721c3 2019-10-21 stsp >> $testroot/content.expected
466 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
467 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
468 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
469 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
470 54d5be07 2021-06-03 stsp >> $testroot/content.expected
471 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
472 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
473 fc414659 2022-04-16 thomas ret=$?
474 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
475 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
476 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
477 818c7501 2019-07-11 stsp return 1
478 818c7501 2019-07-11 stsp fi
479 818c7501 2019-07-11 stsp
480 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
481 818c7501 2019-07-11 stsp
482 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
483 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
484 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
485 fc414659 2022-04-16 thomas ret=$?
486 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
487 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
488 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
489 818c7501 2019-07-11 stsp return 1
490 818c7501 2019-07-11 stsp fi
491 818c7501 2019-07-11 stsp
492 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
493 818c7501 2019-07-11 stsp
494 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
495 818c7501 2019-07-11 stsp
496 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
497 818c7501 2019-07-11 stsp > $testroot/stdout.expected
498 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
499 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
500 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
501 818c7501 2019-07-11 stsp
502 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
503 fc414659 2022-04-16 thomas ret=$?
504 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
505 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
506 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
507 818c7501 2019-07-11 stsp return 1
508 818c7501 2019-07-11 stsp fi
509 818c7501 2019-07-11 stsp
510 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
511 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
512 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
513 fc414659 2022-04-16 thomas ret=$?
514 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
515 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
516 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
517 818c7501 2019-07-11 stsp return 1
518 818c7501 2019-07-11 stsp fi
519 818c7501 2019-07-11 stsp
520 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
521 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
522 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
523 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
524 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
525 fc414659 2022-04-16 thomas ret=$?
526 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
527 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
528 818c7501 2019-07-11 stsp fi
529 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
530 818c7501 2019-07-11 stsp }
531 818c7501 2019-07-11 stsp
532 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
533 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
534 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
535 ff0d2220 2019-07-11 stsp
536 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
537 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
538 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
539 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
540 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
541 ff0d2220 2019-07-11 stsp
542 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
543 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
544 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
545 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
546 ff0d2220 2019-07-11 stsp
547 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
548 fc414659 2022-04-16 thomas ret=$?
549 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
550 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
551 ff0d2220 2019-07-11 stsp return 1
552 ff0d2220 2019-07-11 stsp fi
553 ff0d2220 2019-07-11 stsp
554 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
555 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
556 ff0d2220 2019-07-11 stsp
557 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
558 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
559 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
560 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
561 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
562 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
563 fc414659 2022-04-16 thomas ret=$?
564 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
565 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
566 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
567 ff0d2220 2019-07-11 stsp return 1
568 ff0d2220 2019-07-11 stsp fi
569 ff0d2220 2019-07-11 stsp
570 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
571 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
572 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
573 fc414659 2022-04-16 thomas ret=$?
574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
575 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
576 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
577 ff0d2220 2019-07-11 stsp return 1
578 ff0d2220 2019-07-11 stsp fi
579 ff0d2220 2019-07-11 stsp
580 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
581 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
582 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
583 f69721c3 2019-10-21 stsp >> $testroot/content.expected
584 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
585 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
586 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
587 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
588 54d5be07 2021-06-03 stsp >> $testroot/content.expected
589 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
590 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
591 fc414659 2022-04-16 thomas ret=$?
592 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
593 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
594 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
595 ff0d2220 2019-07-11 stsp return 1
596 ff0d2220 2019-07-11 stsp fi
597 ff0d2220 2019-07-11 stsp
598 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
599 ff0d2220 2019-07-11 stsp
600 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
601 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
602 fc414659 2022-04-16 thomas ret=$?
603 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
604 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
605 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
606 ff0d2220 2019-07-11 stsp return 1
607 ff0d2220 2019-07-11 stsp fi
608 ff0d2220 2019-07-11 stsp
609 ff0d2220 2019-07-11 stsp # resolve the conflict
610 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
611 ff0d2220 2019-07-11 stsp
612 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
613 ff0d2220 2019-07-11 stsp
614 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
615 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
616 ff0d2220 2019-07-11 stsp
617 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
618 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
619 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
620 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
621 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
622 ff0d2220 2019-07-11 stsp
623 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
624 fc414659 2022-04-16 thomas ret=$?
625 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
626 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
627 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
628 ff0d2220 2019-07-11 stsp return 1
629 ff0d2220 2019-07-11 stsp fi
630 ff0d2220 2019-07-11 stsp
631 ff0d2220 2019-07-11 stsp
632 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
633 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
634 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
635 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
636 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
637 fc414659 2022-04-16 thomas ret=$?
638 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
639 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
640 7d5807f4 2019-07-11 stsp fi
641 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
642 7d5807f4 2019-07-11 stsp }
643 7d5807f4 2019-07-11 stsp
644 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
645 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
646 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
647 7d5807f4 2019-07-11 stsp
648 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
649 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
650 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
651 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
652 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
653 7d5807f4 2019-07-11 stsp
654 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
655 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
656 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
657 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
658 7d5807f4 2019-07-11 stsp
659 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
660 fc414659 2022-04-16 thomas ret=$?
661 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
662 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
663 7d5807f4 2019-07-11 stsp return 1
664 7d5807f4 2019-07-11 stsp fi
665 7d5807f4 2019-07-11 stsp
666 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
667 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
668 7d5807f4 2019-07-11 stsp
669 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
670 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
671 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
672 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
673 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
674 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
675 fc414659 2022-04-16 thomas ret=$?
676 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
677 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
679 7d5807f4 2019-07-11 stsp return 1
680 7d5807f4 2019-07-11 stsp fi
681 7d5807f4 2019-07-11 stsp
682 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
683 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
684 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
685 fc414659 2022-04-16 thomas ret=$?
686 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
687 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
688 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
689 7d5807f4 2019-07-11 stsp return 1
690 7d5807f4 2019-07-11 stsp fi
691 7d5807f4 2019-07-11 stsp
692 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
693 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
694 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
695 f69721c3 2019-10-21 stsp >> $testroot/content.expected
696 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
697 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
698 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
699 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
700 54d5be07 2021-06-03 stsp >> $testroot/content.expected
701 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
702 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
703 fc414659 2022-04-16 thomas ret=$?
704 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
705 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
706 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
707 7d5807f4 2019-07-11 stsp return 1
708 7d5807f4 2019-07-11 stsp fi
709 7d5807f4 2019-07-11 stsp
710 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
711 7d5807f4 2019-07-11 stsp
712 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
713 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
714 fc414659 2022-04-16 thomas ret=$?
715 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
716 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
718 7d5807f4 2019-07-11 stsp return 1
719 ff0d2220 2019-07-11 stsp fi
720 7d5807f4 2019-07-11 stsp
721 7d5807f4 2019-07-11 stsp for cmd in update commit; do
722 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
723 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
724 7d5807f4 2019-07-11 stsp
725 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
726 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
727 fc414659 2022-04-16 thomas ret=$?
728 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
729 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
730 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
731 7d5807f4 2019-07-11 stsp return 1
732 7d5807f4 2019-07-11 stsp fi
733 7d5807f4 2019-07-11 stsp
734 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
735 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
736 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
737 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
738 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
739 fc414659 2022-04-16 thomas ret=$?
740 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
741 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
742 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
743 7d5807f4 2019-07-11 stsp return 1
744 7d5807f4 2019-07-11 stsp fi
745 7d5807f4 2019-07-11 stsp done
746 64c6d990 2019-07-11 stsp
747 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
748 64c6d990 2019-07-11 stsp }
749 64c6d990 2019-07-11 stsp
750 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
751 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
752 64c6d990 2019-07-11 stsp
753 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
754 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
755 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
756 64c6d990 2019-07-11 stsp
757 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
758 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
759 64c6d990 2019-07-11 stsp
760 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
761 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
762 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
763 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
764 64c6d990 2019-07-11 stsp
765 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
766 fc414659 2022-04-16 thomas ret=$?
767 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
768 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
769 64c6d990 2019-07-11 stsp return 1
770 64c6d990 2019-07-11 stsp fi
771 7d5807f4 2019-07-11 stsp
772 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
773 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
774 64c6d990 2019-07-11 stsp
775 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
776 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
777 fc414659 2022-04-16 thomas ret=$?
778 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
779 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
781 64c6d990 2019-07-11 stsp return 1
782 64c6d990 2019-07-11 stsp fi
783 64c6d990 2019-07-11 stsp
784 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
785 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
786 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
787 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
788 fc414659 2022-04-16 thomas ret=$?
789 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
790 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
791 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
792 f4a34a66 2022-04-16 thomas return 1
793 f4a34a66 2022-04-16 thomas fi
794 f4a34a66 2022-04-16 thomas
795 f4a34a66 2022-04-16 thomas # rebase should succeed when using a complete work tree
796 f4a34a66 2022-04-16 thomas got checkout $testroot/repo $testroot/wt2 > /dev/null
797 f4a34a66 2022-04-16 thomas ret=$?
798 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
799 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
800 f4a34a66 2022-04-16 thomas return 1
801 f4a34a66 2022-04-16 thomas fi
802 f4a34a66 2022-04-16 thomas
803 f4a34a66 2022-04-16 thomas (cd $testroot/wt2 && got rebase newbranch \
804 f4a34a66 2022-04-16 thomas > $testroot/stdout 2> $testroot/stderr)
805 f4a34a66 2022-04-16 thomas
806 f4a34a66 2022-04-16 thomas (cd $testroot/repo && git checkout -q newbranch)
807 f4a34a66 2022-04-16 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
808 f4a34a66 2022-04-16 thomas local new_commit2=`git_show_head $testroot/repo`
809 f4a34a66 2022-04-16 thomas
810 f4a34a66 2022-04-16 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
811 f4a34a66 2022-04-16 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
812 f4a34a66 2022-04-16 thomas
813 f4a34a66 2022-04-16 thomas echo "G gamma/delta" > $testroot/stdout.expected
814 f4a34a66 2022-04-16 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
815 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
816 f4a34a66 2022-04-16 thomas echo ": committing to delta on newbranch" \
817 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
818 f4a34a66 2022-04-16 thomas echo "Switching work tree to refs/heads/newbranch" \
819 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
820 f4a34a66 2022-04-16 thomas
821 f4a34a66 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
822 f4a34a66 2022-04-16 thomas ret=$?
823 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
824 f4a34a66 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
825 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
826 f4a34a66 2022-04-16 thomas return 1
827 787c8eb6 2019-07-11 stsp fi
828 f4a34a66 2022-04-16 thomas
829 f4a34a66 2022-04-16 thomas # the first work tree should remain usable
830 f4a34a66 2022-04-16 thomas (cd $testroot/wt && got update -b master \
831 f4a34a66 2022-04-16 thomas > $testroot/stdout 2> $testroot/stderr)
832 f4a34a66 2022-04-16 thomas ret=$?
833 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
834 f4a34a66 2022-04-16 thomas echo "update failed unexpectedly" >&2
835 f4a34a66 2022-04-16 thomas test_done "$testroot" "1"
836 f4a34a66 2022-04-16 thomas return 1
837 f4a34a66 2022-04-16 thomas fi
838 f4a34a66 2022-04-16 thomas
839 f4a34a66 2022-04-16 thomas echo 'Already up-to-date' > $testroot/stdout.expected
840 f4a34a66 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
841 f4a34a66 2022-04-16 thomas ret=$?
842 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
843 f4a34a66 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
844 f4a34a66 2022-04-16 thomas fi
845 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
846 787c8eb6 2019-07-11 stsp }
847 787c8eb6 2019-07-11 stsp
848 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
849 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
850 787c8eb6 2019-07-11 stsp
851 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
852 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
853 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
854 787c8eb6 2019-07-11 stsp
855 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
856 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
857 787c8eb6 2019-07-11 stsp
858 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
859 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
860 787c8eb6 2019-07-11 stsp
861 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
862 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
863 787c8eb6 2019-07-11 stsp
864 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
865 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
866 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
867 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
868 787c8eb6 2019-07-11 stsp
869 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
870 fc414659 2022-04-16 thomas ret=$?
871 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
872 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
873 787c8eb6 2019-07-11 stsp return 1
874 787c8eb6 2019-07-11 stsp fi
875 787c8eb6 2019-07-11 stsp
876 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
877 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
878 787c8eb6 2019-07-11 stsp
879 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
880 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
881 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
882 787c8eb6 2019-07-11 stsp
883 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
884 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
885 fc414659 2022-04-16 thomas ret=$?
886 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
887 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
888 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
889 787c8eb6 2019-07-11 stsp return 1
890 64c6d990 2019-07-11 stsp fi
891 787c8eb6 2019-07-11 stsp
892 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
893 787c8eb6 2019-07-11 stsp > $testroot/log)
894 ac3cdf31 2023-03-06 thomas ed -s $testroot/log.expected <<-EOF
895 ac3cdf31 2023-03-06 thomas ,s/$orig_commit1/$new_commit1/
896 ac3cdf31 2023-03-06 thomas ,s/$orig_commit2/$new_commit2/
897 ac3cdf31 2023-03-06 thomas w
898 ac3cdf31 2023-03-06 thomas EOF
899 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
900 fc414659 2022-04-16 thomas ret=$?
901 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
902 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
903 fc66b545 2019-08-12 stsp fi
904 fc66b545 2019-08-12 stsp
905 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
906 fc66b545 2019-08-12 stsp }
907 fc66b545 2019-08-12 stsp
908 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
909 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
910 fc66b545 2019-08-12 stsp
911 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
912 fc414659 2022-04-16 thomas ret=$?
913 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
914 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
915 fc66b545 2019-08-12 stsp return 1
916 fc66b545 2019-08-12 stsp fi
917 fc66b545 2019-08-12 stsp
918 0b36e980 2023-01-31 thomas # Create an unrelated branch with 'got import'.
919 0b36e980 2023-01-31 thomas mkdir -p $testroot/newtree
920 0b36e980 2023-01-31 thomas echo "new file" > $testroot/newtree/newfile
921 0b36e980 2023-01-31 thomas got import -m new -b newbranch -r $testroot/repo \
922 0b36e980 2023-01-31 thomas $testroot/newtree > /dev/null
923 fc66b545 2019-08-12 stsp
924 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
925 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
926 fc66b545 2019-08-12 stsp > /dev/null)
927 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
928 fc66b545 2019-08-12 stsp
929 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
930 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
931 fc66b545 2019-08-12 stsp
932 0b36e980 2023-01-31 thomas echo -n "got: specified branch shares no common ancestry " \
933 0b36e980 2023-01-31 thomas > $testroot/stderr.expected
934 0b36e980 2023-01-31 thomas echo "with work tree's branch" >> $testroot/stderr.expected
935 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
936 fc414659 2022-04-16 thomas ret=$?
937 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
938 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
939 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
940 fc66b545 2019-08-12 stsp return 1
941 787c8eb6 2019-07-11 stsp fi
942 787c8eb6 2019-07-11 stsp
943 f4a34a66 2022-04-16 thomas echo -n > $testroot/stdout.expected
944 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
945 fc414659 2022-04-16 thomas ret=$?
946 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
947 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
948 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
949 fc66b545 2019-08-12 stsp return 1
950 fc66b545 2019-08-12 stsp fi
951 fc66b545 2019-08-12 stsp
952 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
953 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
954 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
955 fc414659 2022-04-16 thomas ret=$?
956 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
957 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
958 fc66b545 2019-08-12 stsp fi
959 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
960 ff0d2220 2019-07-11 stsp }
961 38b0338b 2019-11-29 stsp
962 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
963 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
964 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
965 38b0338b 2019-11-29 stsp
966 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
967 fc414659 2022-04-16 thomas ret=$?
968 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
969 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
970 38b0338b 2019-11-29 stsp return 1
971 38b0338b 2019-11-29 stsp fi
972 38b0338b 2019-11-29 stsp
973 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
974 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
975 38b0338b 2019-11-29 stsp > /dev/null)
976 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
977 ff0d2220 2019-07-11 stsp
978 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
979 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
980 38b0338b 2019-11-29 stsp > /dev/null)
981 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
982 38b0338b 2019-11-29 stsp
983 b6b86fd1 2022-08-30 thomas # Simulate a situation where fast-forward is required.
984 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
985 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
986 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
987 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
988 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
989 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
990 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
991 38b0338b 2019-11-29 stsp
992 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
993 38b0338b 2019-11-29 stsp
994 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
995 1996dd72 2022-09-21 thomas > $testroot/stdout 2> $testroot/stderr)
996 1996dd72 2022-09-21 thomas
997 1996dd72 2022-09-21 thomas echo "Forwarding refs/heads/master to commit $commit2" \
998 1996dd72 2022-09-21 thomas > $testroot/stdout.expected
999 1996dd72 2022-09-21 thomas echo "Switching work tree to refs/heads/master" \
1000 1996dd72 2022-09-21 thomas >> $testroot/stdout.expected
1001 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1002 1996dd72 2022-09-21 thomas ret=$?
1003 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1004 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1005 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1006 1996dd72 2022-09-21 thomas return 1
1007 1996dd72 2022-09-21 thomas fi
1008 1996dd72 2022-09-21 thomas
1009 1996dd72 2022-09-21 thomas # Ensure that rebase operation was completed correctly
1010 1996dd72 2022-09-21 thomas (cd $testroot/wt && got rebase -a \
1011 1996dd72 2022-09-21 thomas > $testroot/stdout 2> $testroot/stderr)
1012 1996dd72 2022-09-21 thomas echo -n "" > $testroot/stdout.expected
1013 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1014 1996dd72 2022-09-21 thomas ret=$?
1015 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1016 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1017 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1018 1996dd72 2022-09-21 thomas return 1
1019 1996dd72 2022-09-21 thomas fi
1020 1996dd72 2022-09-21 thomas echo "got: rebase operation not in progress" > $testroot/stderr.expected
1021 1996dd72 2022-09-21 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1022 1996dd72 2022-09-21 thomas ret=$?
1023 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1024 1996dd72 2022-09-21 thomas diff -u $testroot/stderr.expected $testroot/stderr
1025 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1026 1996dd72 2022-09-21 thomas return 1
1027 1996dd72 2022-09-21 thomas fi
1028 1996dd72 2022-09-21 thomas
1029 1996dd72 2022-09-21 thomas (cd $testroot/wt && got branch -n > $testroot/stdout)
1030 1996dd72 2022-09-21 thomas echo "master" > $testroot/stdout.expected
1031 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1032 1996dd72 2022-09-21 thomas ret=$?
1033 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1034 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1035 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1036 1996dd72 2022-09-21 thomas return 1
1037 1996dd72 2022-09-21 thomas fi
1038 1996dd72 2022-09-21 thomas
1039 1996dd72 2022-09-21 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1040 1996dd72 2022-09-21 thomas echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1041 1996dd72 2022-09-21 thomas echo "commit $commit1" >> $testroot/stdout.expected
1042 1996dd72 2022-09-21 thomas echo "commit $commit0" >> $testroot/stdout.expected
1043 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1044 1996dd72 2022-09-21 thomas ret=$?
1045 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1046 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1047 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1048 1996dd72 2022-09-21 thomas return 1
1049 1996dd72 2022-09-21 thomas fi
1050 1996dd72 2022-09-21 thomas
1051 1996dd72 2022-09-21 thomas # Forward-only rebase operations should not be backed up
1052 1996dd72 2022-09-21 thomas (cd $testroot/repo && got rebase -l > $testroot/stdout)
1053 1996dd72 2022-09-21 thomas echo -n > $testroot/stdout.expected
1054 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1055 1996dd72 2022-09-21 thomas ret=$?
1056 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1057 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1058 1996dd72 2022-09-21 thomas fi
1059 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1060 1996dd72 2022-09-21 thomas }
1061 1996dd72 2022-09-21 thomas
1062 1996dd72 2022-09-21 thomas test_rebase_forward_path_prefix() {
1063 1996dd72 2022-09-21 thomas local testroot=`test_init rebase_forward_path_prefix`
1064 1996dd72 2022-09-21 thomas local commit0=`git_show_head $testroot/repo`
1065 1996dd72 2022-09-21 thomas
1066 1996dd72 2022-09-21 thomas got checkout $testroot/repo $testroot/wt-full > /dev/null
1067 1996dd72 2022-09-21 thomas ret=$?
1068 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1069 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1070 1996dd72 2022-09-21 thomas return 1
1071 1996dd72 2022-09-21 thomas fi
1072 1996dd72 2022-09-21 thomas
1073 1996dd72 2022-09-21 thomas echo "change alpha 1" > $testroot/wt-full/alpha
1074 1996dd72 2022-09-21 thomas (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1075 1996dd72 2022-09-21 thomas > /dev/null)
1076 1996dd72 2022-09-21 thomas local commit1=`git_show_head $testroot/repo`
1077 1996dd72 2022-09-21 thomas
1078 1996dd72 2022-09-21 thomas echo "change alpha 2" > $testroot/wt-full/alpha
1079 1996dd72 2022-09-21 thomas (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1080 1996dd72 2022-09-21 thomas > /dev/null)
1081 1996dd72 2022-09-21 thomas local commit2=`git_show_head $testroot/repo`
1082 1996dd72 2022-09-21 thomas
1083 1996dd72 2022-09-21 thomas # Simulate a situation where fast-forward is required.
1084 1996dd72 2022-09-21 thomas # We want to fast-forward master to origin/master:
1085 1996dd72 2022-09-21 thomas # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1086 1996dd72 2022-09-21 thomas # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1087 1996dd72 2022-09-21 thomas # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1088 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -d master >/dev/null)
1089 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1090 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1091 1996dd72 2022-09-21 thomas
1092 1996dd72 2022-09-21 thomas # Work tree which uses a path-prefix and will be used for rebasing
1093 1996dd72 2022-09-21 thomas got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1094 1996dd72 2022-09-21 thomas > /dev/null
1095 1996dd72 2022-09-21 thomas ret=$?
1096 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1097 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1098 1996dd72 2022-09-21 thomas return 1
1099 1996dd72 2022-09-21 thomas fi
1100 1996dd72 2022-09-21 thomas
1101 4f29e1f1 2022-10-24 thomas (cd $testroot/wt && got rebase master \
1102 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1103 38b0338b 2019-11-29 stsp
1104 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1105 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
1106 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
1107 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
1108 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1109 fc414659 2022-04-16 thomas ret=$?
1110 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1111 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1112 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1113 38b0338b 2019-11-29 stsp return 1
1114 38b0338b 2019-11-29 stsp fi
1115 38b0338b 2019-11-29 stsp
1116 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1117 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1118 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1119 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1120 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1121 fc414659 2022-04-16 thomas ret=$?
1122 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1123 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1124 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1125 38b0338b 2019-11-29 stsp return 1
1126 38b0338b 2019-11-29 stsp fi
1127 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1128 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1129 fc414659 2022-04-16 thomas ret=$?
1130 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1131 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1132 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1133 38b0338b 2019-11-29 stsp return 1
1134 38b0338b 2019-11-29 stsp fi
1135 38b0338b 2019-11-29 stsp
1136 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1137 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1138 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1139 fc414659 2022-04-16 thomas ret=$?
1140 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1141 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1142 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1143 38b0338b 2019-11-29 stsp return 1
1144 38b0338b 2019-11-29 stsp fi
1145 38b0338b 2019-11-29 stsp
1146 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1147 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1148 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1149 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1150 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1151 fc414659 2022-04-16 thomas ret=$?
1152 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1153 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1154 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1155 a9662115 2021-08-29 naddy return 1
1156 38b0338b 2019-11-29 stsp fi
1157 e600f124 2021-03-21 stsp
1158 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1159 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1160 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1161 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1162 fc414659 2022-04-16 thomas ret=$?
1163 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1164 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1165 e600f124 2021-03-21 stsp fi
1166 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1167 38b0338b 2019-11-29 stsp }
1168 e51d7b55 2020-01-04 stsp
1169 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1170 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1171 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1172 e51d7b55 2020-01-04 stsp
1173 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1174 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1175 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1176 38b0338b 2019-11-29 stsp
1177 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1178 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1179 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1180 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1181 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1182 e51d7b55 2020-01-04 stsp
1183 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1184 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1185 e51d7b55 2020-01-04 stsp
1186 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1187 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1188 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1189 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1190 e51d7b55 2020-01-04 stsp
1191 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1192 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1193 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1194 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1195 e51d7b55 2020-01-04 stsp
1196 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1197 e51d7b55 2020-01-04 stsp > /dev/null
1198 fc414659 2022-04-16 thomas ret=$?
1199 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1200 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1201 e51d7b55 2020-01-04 stsp return 1
1202 e51d7b55 2020-01-04 stsp fi
1203 e51d7b55 2020-01-04 stsp
1204 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1205 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1206 e51d7b55 2020-01-04 stsp
1207 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1208 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1209 fc414659 2022-04-16 thomas ret=$?
1210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1211 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1212 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1213 e51d7b55 2020-01-04 stsp return 1
1214 e51d7b55 2020-01-04 stsp fi
1215 e51d7b55 2020-01-04 stsp
1216 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1217 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1218 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1219 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1220 fc414659 2022-04-16 thomas ret=$?
1221 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1222 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1223 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1224 e51d7b55 2020-01-04 stsp return 1
1225 e51d7b55 2020-01-04 stsp fi
1226 e51d7b55 2020-01-04 stsp
1227 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1228 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1229 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1230 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1231 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1232 fc414659 2022-04-16 thomas ret=$?
1233 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1234 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 1ae0a341 2020-02-14 stsp fi
1236 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1237 1ae0a341 2020-02-14 stsp }
1238 1ae0a341 2020-02-14 stsp
1239 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1240 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1241 1ae0a341 2020-02-14 stsp
1242 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1243 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1244 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1245 1ae0a341 2020-02-14 stsp
1246 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1247 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1248 1ae0a341 2020-02-14 stsp
1249 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1250 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1251 1ae0a341 2020-02-14 stsp
1252 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1253 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1254 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1255 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1256 1ae0a341 2020-02-14 stsp
1257 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1258 fc414659 2022-04-16 thomas ret=$?
1259 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1260 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1261 1ae0a341 2020-02-14 stsp return 1
1262 1ae0a341 2020-02-14 stsp fi
1263 1ae0a341 2020-02-14 stsp
1264 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1265 1ae0a341 2020-02-14 stsp
1266 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1267 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1268 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1269 1ae0a341 2020-02-14 stsp
1270 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1271 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1272 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1273 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1274 1ae0a341 2020-02-14 stsp
1275 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1276 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1277 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1278 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1279 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1280 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1281 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1282 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1283 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1284 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1285 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1286 1ae0a341 2020-02-14 stsp
1287 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1288 fc414659 2022-04-16 thomas ret=$?
1289 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1290 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1291 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1292 1ae0a341 2020-02-14 stsp return 1
1293 e51d7b55 2020-01-04 stsp fi
1294 1ae0a341 2020-02-14 stsp
1295 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1296 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1297 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1298 fc414659 2022-04-16 thomas ret=$?
1299 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1300 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1301 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1302 1ae0a341 2020-02-14 stsp return 1
1303 1ae0a341 2020-02-14 stsp fi
1304 1ae0a341 2020-02-14 stsp
1305 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1306 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1307 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1308 fc414659 2022-04-16 thomas ret=$?
1309 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1310 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1311 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1312 1ae0a341 2020-02-14 stsp return 1
1313 1ae0a341 2020-02-14 stsp fi
1314 1ae0a341 2020-02-14 stsp
1315 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1316 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1317 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1318 1ae0a341 2020-02-14 stsp return 1
1319 1ae0a341 2020-02-14 stsp fi
1320 1ae0a341 2020-02-14 stsp
1321 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1322 1ae0a341 2020-02-14 stsp
1323 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1324 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1325 fc414659 2022-04-16 thomas ret=$?
1326 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1327 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1328 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1329 1ae0a341 2020-02-14 stsp return 1
1330 1ae0a341 2020-02-14 stsp fi
1331 1ae0a341 2020-02-14 stsp
1332 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1333 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1334 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1335 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1336 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1337 fc414659 2022-04-16 thomas ret=$?
1338 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1339 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1340 1ae0a341 2020-02-14 stsp fi
1341 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1342 e51d7b55 2020-01-04 stsp }
1343 ca6da77d 2020-03-22 stsp
1344 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1345 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1346 ca6da77d 2020-03-22 stsp
1347 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1348 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1349 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1350 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1351 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1352 ca6da77d 2020-03-22 stsp
1353 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1354 a740a1b3 2020-03-22 stsp
1355 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1356 ca6da77d 2020-03-22 stsp
1357 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1358 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1359 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1360 ca6da77d 2020-03-22 stsp
1361 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1362 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1363 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1364 a740a1b3 2020-03-22 stsp
1365 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1366 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1367 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1368 bb494413 2021-09-28 thomas
1369 bb494413 2021-09-28 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1370 bb494413 2021-09-28 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1371 ca6da77d 2020-03-22 stsp
1372 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1373 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1374 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1375 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1376 a740a1b3 2020-03-22 stsp
1377 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1378 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1379 ca6da77d 2020-03-22 stsp
1380 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1381 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1382 bb494413 2021-09-28 thomas 2> $testroot/stderr)
1383 fc414659 2022-04-16 thomas ret=$?
1384 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1385 bb494413 2021-09-28 thomas echo "rebase succeeded unexpectedly" >&2
1386 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1387 bb494413 2021-09-28 thomas return 1
1388 bb494413 2021-09-28 thomas fi
1389 ca6da77d 2020-03-22 stsp
1390 bb494413 2021-09-28 thomas local new_commit1=$(cd $testroot/wt && got info | \
1391 bb494413 2021-09-28 thomas grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1392 ca6da77d 2020-03-22 stsp
1393 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1394 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1395 ca6da77d 2020-03-22 stsp
1396 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1397 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1398 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1399 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1400 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1401 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1402 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1403 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1404 0ef68859 2021-09-28 thomas echo "in the work tree: 2" >> $testroot/stdout.expected
1405 bb494413 2021-09-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1406 fc414659 2022-04-16 thomas ret=$?
1407 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1408 bb494413 2021-09-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
1409 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1410 bb494413 2021-09-28 thomas return 1
1411 bb494413 2021-09-28 thomas fi
1412 bb494413 2021-09-28 thomas
1413 bb494413 2021-09-28 thomas echo -n "got: changes destined for some files were not yet merged " \
1414 bb494413 2021-09-28 thomas > $testroot/stderr.expected
1415 bb494413 2021-09-28 thomas echo -n "and should be merged manually if required before the " \
1416 bb494413 2021-09-28 thomas >> $testroot/stderr.expected
1417 bb494413 2021-09-28 thomas echo "rebase operation is continued" >> $testroot/stderr.expected
1418 bb494413 2021-09-28 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1419 fc414659 2022-04-16 thomas ret=$?
1420 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1421 bb494413 2021-09-28 thomas diff -u $testroot/stderr.expected $testroot/stderr
1422 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1423 bb494413 2021-09-28 thomas return 1
1424 bb494413 2021-09-28 thomas fi
1425 bb494413 2021-09-28 thomas
1426 bb494413 2021-09-28 thomas # ignore the missing changes and continue
1427 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase -c > $testroot/stdout)
1428 fc414659 2022-04-16 thomas ret=$?
1429 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1430 bb494413 2021-09-28 thomas echo "rebase failed unexpectedly" >&2
1431 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1432 bb494413 2021-09-28 thomas return 1
1433 bb494413 2021-09-28 thomas fi
1434 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1435 bb494413 2021-09-28 thomas > $testroot/stdout.expected
1436 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1437 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1438 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1439 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1440 ca6da77d 2020-03-22 stsp
1441 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1442 fc414659 2022-04-16 thomas ret=$?
1443 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1444 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1445 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1446 ca6da77d 2020-03-22 stsp return 1
1447 ca6da77d 2020-03-22 stsp fi
1448 ca6da77d 2020-03-22 stsp
1449 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1450 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1451 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1452 fc414659 2022-04-16 thomas ret=$?
1453 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1454 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1455 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1456 ca6da77d 2020-03-22 stsp return 1
1457 ca6da77d 2020-03-22 stsp fi
1458 ca6da77d 2020-03-22 stsp
1459 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1460 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1461 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1462 ca6da77d 2020-03-22 stsp return 1
1463 ca6da77d 2020-03-22 stsp fi
1464 ca6da77d 2020-03-22 stsp
1465 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1466 ca6da77d 2020-03-22 stsp
1467 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1468 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1469 fc414659 2022-04-16 thomas ret=$?
1470 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1471 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1472 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1473 ca6da77d 2020-03-22 stsp return 1
1474 ca6da77d 2020-03-22 stsp fi
1475 ca6da77d 2020-03-22 stsp
1476 bb494413 2021-09-28 thomas (cd $testroot/repo && git checkout -q newbranch)
1477 bb494413 2021-09-28 thomas local new_commit1=`git_show_head $testroot/repo`
1478 bb494413 2021-09-28 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1479 bb494413 2021-09-28 thomas
1480 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1481 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1482 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1483 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1484 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1485 fc414659 2022-04-16 thomas ret=$?
1486 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1487 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1488 70551d57 2020-04-24 stsp fi
1489 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1490 70551d57 2020-04-24 stsp }
1491 70551d57 2020-04-24 stsp
1492 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1493 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1494 70551d57 2020-04-24 stsp
1495 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1496 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1497 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1498 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1499 70551d57 2020-04-24 stsp
1500 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1501 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1502 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1503 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1504 70551d57 2020-04-24 stsp
1505 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1506 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1507 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1508 70551d57 2020-04-24 stsp
1509 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1510 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1511 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1512 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1513 70551d57 2020-04-24 stsp
1514 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1515 fc414659 2022-04-16 thomas ret=$?
1516 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1517 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1518 70551d57 2020-04-24 stsp return 1
1519 70551d57 2020-04-24 stsp fi
1520 70551d57 2020-04-24 stsp
1521 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1522 70551d57 2020-04-24 stsp
1523 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1524 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1525 fc414659 2022-04-16 thomas ret=$?
1526 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1527 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1528 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1529 70551d57 2020-04-24 stsp return 1
1530 70551d57 2020-04-24 stsp fi
1531 70551d57 2020-04-24 stsp
1532 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1533 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1534 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1535 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1536 70551d57 2020-04-24 stsp
1537 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1538 70551d57 2020-04-24 stsp
1539 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1540 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1541 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1542 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1543 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1544 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1545 70551d57 2020-04-24 stsp
1546 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1547 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1548 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1549 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1550 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1551 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1552 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1553 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1554 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1555 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1556 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1557 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1558 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1559 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1560 70551d57 2020-04-24 stsp
1561 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1562 fc414659 2022-04-16 thomas ret=$?
1563 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1564 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1565 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1566 70551d57 2020-04-24 stsp return 1
1567 ca6da77d 2020-03-22 stsp fi
1568 70551d57 2020-04-24 stsp
1569 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1570 fc414659 2022-04-16 thomas ret=$?
1571 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1572 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1573 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1574 70551d57 2020-04-24 stsp return 1
1575 70551d57 2020-04-24 stsp fi
1576 70551d57 2020-04-24 stsp
1577 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1578 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1579 fc414659 2022-04-16 thomas ret=$?
1580 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1581 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1582 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1583 70551d57 2020-04-24 stsp return 1
1584 70551d57 2020-04-24 stsp fi
1585 70551d57 2020-04-24 stsp
1586 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1587 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1588 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1589 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1590 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1591 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1592 fc414659 2022-04-16 thomas ret=$?
1593 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1594 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1595 70551d57 2020-04-24 stsp fi
1596 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1597 ca6da77d 2020-03-22 stsp }
1598 150d7275 2022-07-22 thomas
1599 150d7275 2022-07-22 thomas test_rebase_resets_committer() {
1600 150d7275 2022-07-22 thomas local testroot=`test_init rebase_resets_committer`
1601 150d7275 2022-07-22 thomas local commit0=`git_show_head $testroot/repo`
1602 150d7275 2022-07-22 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1603 150d7275 2022-07-22 thomas local committer="Flan Luck <flan_luck@openbsd.org>"
1604 150d7275 2022-07-22 thomas
1605 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1606 150d7275 2022-07-22 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1607 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
1608 150d7275 2022-07-22 thomas
1609 150d7275 2022-07-22 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1610 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing more changes on newbranch"
1611 150d7275 2022-07-22 thomas
1612 150d7275 2022-07-22 thomas local orig_commit1=`git_show_parent_commit $testroot/repo`
1613 150d7275 2022-07-22 thomas local orig_commit2=`git_show_head $testroot/repo`
1614 150d7275 2022-07-22 thomas local orig_author_time2=`git_show_author_time $testroot/repo`
1615 150d7275 2022-07-22 thomas
1616 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q master)
1617 150d7275 2022-07-22 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1618 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing to zeta on master"
1619 150d7275 2022-07-22 thomas local master_commit=`git_show_head $testroot/repo`
1620 150d7275 2022-07-22 thomas
1621 150d7275 2022-07-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1622 150d7275 2022-07-22 thomas ret=$?
1623 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1624 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1625 150d7275 2022-07-22 thomas return 1
1626 150d7275 2022-07-22 thomas fi
1627 ca6da77d 2020-03-22 stsp
1628 150d7275 2022-07-22 thomas (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1629 150d7275 2022-07-22 thomas got rebase newbranch > $testroot/stdout)
1630 150d7275 2022-07-22 thomas
1631 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q newbranch)
1632 150d7275 2022-07-22 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
1633 150d7275 2022-07-22 thomas local new_commit2=`git_show_head $testroot/repo`
1634 150d7275 2022-07-22 thomas local new_author_time2=`git_show_author_time $testroot/repo`
1635 150d7275 2022-07-22 thomas
1636 150d7275 2022-07-22 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1637 150d7275 2022-07-22 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1638 150d7275 2022-07-22 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1639 150d7275 2022-07-22 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
1640 150d7275 2022-07-22 thomas
1641 150d7275 2022-07-22 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1642 150d7275 2022-07-22 thomas echo -n "$short_orig_commit1 -> $short_new_commit1" \
1643 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1644 150d7275 2022-07-22 thomas echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1645 150d7275 2022-07-22 thomas echo "G alpha" >> $testroot/stdout.expected
1646 150d7275 2022-07-22 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
1647 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1648 150d7275 2022-07-22 thomas echo ": committing more changes on newbranch" \
1649 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1650 150d7275 2022-07-22 thomas echo "Switching work tree to refs/heads/newbranch" \
1651 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1652 150d7275 2022-07-22 thomas
1653 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1654 150d7275 2022-07-22 thomas ret=$?
1655 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1656 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1657 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1658 150d7275 2022-07-22 thomas return 1
1659 150d7275 2022-07-22 thomas fi
1660 150d7275 2022-07-22 thomas
1661 150d7275 2022-07-22 thomas # Original commit only had one author
1662 150d7275 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1663 150d7275 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1664 150d7275 2022-07-22 thomas echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1665 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1666 150d7275 2022-07-22 thomas ret=$?
1667 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1668 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1669 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1670 150d7275 2022-07-22 thomas return 1
1671 150d7275 2022-07-22 thomas fi
1672 150d7275 2022-07-22 thomas
1673 150d7275 2022-07-22 thomas # Rebased commit should have new committer name added
1674 150d7275 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1675 150d7275 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1676 150d7275 2022-07-22 thomas echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1677 150d7275 2022-07-22 thomas echo "via: $committer" >> $testroot/stdout.expected
1678 8db00f97 2022-07-22 thomas
1679 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1680 8db00f97 2022-07-22 thomas ret=$?
1681 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1682 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1683 8db00f97 2022-07-22 thomas fi
1684 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1685 8db00f97 2022-07-22 thomas }
1686 8db00f97 2022-07-22 thomas
1687 8db00f97 2022-07-22 thomas test_rebase_no_author_info() {
1688 8db00f97 2022-07-22 thomas local testroot=`test_init rebase_no_author_info`
1689 8db00f97 2022-07-22 thomas local commit0=`git_show_head $testroot/repo`
1690 8db00f97 2022-07-22 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1691 8db00f97 2022-07-22 thomas local committer="$GOT_AUTHOR"
1692 8db00f97 2022-07-22 thomas
1693 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1694 8db00f97 2022-07-22 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1695 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
1696 8db00f97 2022-07-22 thomas
1697 8db00f97 2022-07-22 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1698 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing more changes on newbranch"
1699 8db00f97 2022-07-22 thomas
1700 8db00f97 2022-07-22 thomas local orig_commit1=`git_show_parent_commit $testroot/repo`
1701 8db00f97 2022-07-22 thomas local orig_commit2=`git_show_head $testroot/repo`
1702 8db00f97 2022-07-22 thomas local orig_author_time2=`git_show_author_time $testroot/repo`
1703 8db00f97 2022-07-22 thomas
1704 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q master)
1705 8db00f97 2022-07-22 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1706 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing to zeta on master"
1707 8db00f97 2022-07-22 thomas local master_commit=`git_show_head $testroot/repo`
1708 8db00f97 2022-07-22 thomas
1709 8db00f97 2022-07-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1710 8db00f97 2022-07-22 thomas ret=$?
1711 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1712 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1713 8db00f97 2022-07-22 thomas return 1
1714 8db00f97 2022-07-22 thomas fi
1715 8db00f97 2022-07-22 thomas
1716 95ad1e7d 2022-07-24 thomas # unset in a subshell to avoid affecting our environment
1717 95ad1e7d 2022-07-24 thomas (unset GOT_AUTHOR && cd $testroot/wt && \
1718 95ad1e7d 2022-07-24 thomas got rebase newbranch > $testroot/stdout)
1719 8db00f97 2022-07-22 thomas
1720 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q newbranch)
1721 8db00f97 2022-07-22 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
1722 8db00f97 2022-07-22 thomas local new_commit2=`git_show_head $testroot/repo`
1723 8db00f97 2022-07-22 thomas local new_author_time2=`git_show_author_time $testroot/repo`
1724 150d7275 2022-07-22 thomas
1725 8db00f97 2022-07-22 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1726 8db00f97 2022-07-22 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1727 8db00f97 2022-07-22 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1728 8db00f97 2022-07-22 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
1729 8db00f97 2022-07-22 thomas
1730 8db00f97 2022-07-22 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1731 8db00f97 2022-07-22 thomas echo -n "$short_orig_commit1 -> $short_new_commit1" \
1732 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1733 8db00f97 2022-07-22 thomas echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1734 8db00f97 2022-07-22 thomas echo "G alpha" >> $testroot/stdout.expected
1735 8db00f97 2022-07-22 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
1736 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1737 8db00f97 2022-07-22 thomas echo ": committing more changes on newbranch" \
1738 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1739 8db00f97 2022-07-22 thomas echo "Switching work tree to refs/heads/newbranch" \
1740 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1741 8db00f97 2022-07-22 thomas
1742 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1743 150d7275 2022-07-22 thomas ret=$?
1744 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1745 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1746 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1747 8db00f97 2022-07-22 thomas return 1
1748 150d7275 2022-07-22 thomas fi
1749 8db00f97 2022-07-22 thomas
1750 8db00f97 2022-07-22 thomas # Original commit only had one author
1751 8db00f97 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1752 8db00f97 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1753 8db00f97 2022-07-22 thomas echo "from: $committer" > $testroot/stdout.expected
1754 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1755 8db00f97 2022-07-22 thomas ret=$?
1756 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1757 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1758 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1759 8db00f97 2022-07-22 thomas return 1
1760 8db00f97 2022-07-22 thomas fi
1761 8db00f97 2022-07-22 thomas
1762 8db00f97 2022-07-22 thomas # Author info of rebased commit should match the original
1763 8db00f97 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1764 8db00f97 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1765 8db00f97 2022-07-22 thomas echo "from: $committer" > $testroot/stdout.expected
1766 8db00f97 2022-07-22 thomas
1767 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1768 8db00f97 2022-07-22 thomas ret=$?
1769 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1770 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1771 8dbcf388 2022-09-04 thomas fi
1772 8dbcf388 2022-09-04 thomas test_done "$testroot" "$ret"
1773 8dbcf388 2022-09-04 thomas }
1774 8dbcf388 2022-09-04 thomas
1775 8dbcf388 2022-09-04 thomas test_rebase_nonbranch() {
1776 8dbcf388 2022-09-04 thomas local testroot=`test_init rebase_nonbranch`
1777 8dbcf388 2022-09-04 thomas
1778 8dbcf388 2022-09-04 thomas got ref -r $testroot/repo -c refs/heads/master \
1779 8dbcf388 2022-09-04 thomas refs/remotes/origin/master >/dev/null
1780 8dbcf388 2022-09-04 thomas
1781 8dbcf388 2022-09-04 thomas got checkout -b master $testroot/repo $testroot/wt >/dev/null
1782 8dbcf388 2022-09-04 thomas
1783 8dbcf388 2022-09-04 thomas (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1784 8dbcf388 2022-09-04 thomas 2> $testroot/stderr)
1785 8dbcf388 2022-09-04 thomas ret=$?
1786 8dbcf388 2022-09-04 thomas if [ $ret -eq 0 ]; then
1787 8dbcf388 2022-09-04 thomas echo "rebase succeeded unexpectedly" >&2
1788 8dbcf388 2022-09-04 thomas test_done "$testroot" "1"
1789 8dbcf388 2022-09-04 thomas return 1
1790 8db00f97 2022-07-22 thomas fi
1791 8dbcf388 2022-09-04 thomas echo -n "got: will not rebase a branch which lives outside the " \
1792 8dbcf388 2022-09-04 thomas > $testroot/stderr.expected
1793 8dbcf388 2022-09-04 thomas echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1794 8dbcf388 2022-09-04 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1795 8dbcf388 2022-09-04 thomas ret=$?
1796 8dbcf388 2022-09-04 thomas if [ $ret -ne 0 ]; then
1797 8dbcf388 2022-09-04 thomas diff -u $testroot/stderr.expected $testroot/stderr
1798 8dbcf388 2022-09-04 thomas fi
1799 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1800 150d7275 2022-07-22 thomas }
1801 a2c162eb 2022-10-30 thomas
1802 a2c162eb 2022-10-30 thomas test_rebase_umask() {
1803 a2c162eb 2022-10-30 thomas local testroot=`test_init rebase_umask`
1804 a2c162eb 2022-10-30 thomas local commit0=`git_show_head "$testroot/repo"`
1805 a2c162eb 2022-10-30 thomas
1806 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1807 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got branch newbranch) >/dev/null
1808 a2c162eb 2022-10-30 thomas
1809 a2c162eb 2022-10-30 thomas echo "modified alpha on branch" >$testroot/wt/alpha
1810 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got commit -m 'modified alpha on newbranch') \
1811 a2c162eb 2022-10-30 thomas >/dev/null
1812 a2c162eb 2022-10-30 thomas
1813 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got update -b master) >/dev/null
1814 a2c162eb 2022-10-30 thomas ret=$?
1815 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
1816 a2c162eb 2022-10-30 thomas echo "got update failed!" >&2
1817 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
1818 a2c162eb 2022-10-30 thomas return 1
1819 a2c162eb 2022-10-30 thomas fi
1820 150d7275 2022-07-22 thomas
1821 a2c162eb 2022-10-30 thomas echo "modified beta on master" >$testroot/wt/beta
1822 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got commit -m 'modified beta on master') \
1823 a2c162eb 2022-10-30 thomas >/dev/null
1824 a2c162eb 2022-10-30 thomas (cd "$testroot/wt" && got update) >/dev/null
1825 a2c162eb 2022-10-30 thomas
1826 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
1827 a2c162eb 2022-10-30 thomas (umask 077 && cd "$testroot/wt" && got rebase newbranch) >/dev/null
1828 a2c162eb 2022-10-30 thomas ret=$?
1829 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
1830 a2c162eb 2022-10-30 thomas echo "got rebase failed" >&2
1831 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
1832 a2c162eb 2022-10-30 thomas return 1
1833 a2c162eb 2022-10-30 thomas fi
1834 a2c162eb 2022-10-30 thomas
1835 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/alpha" | grep -q ^-rw-------
1836 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
1837 a2c162eb 2022-10-30 thomas echo "alpha is not 0600 after rebase" >&2
1838 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/alpha" >&2
1839 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
1840 a2c162eb 2022-10-30 thomas return 1
1841 a2c162eb 2022-10-30 thomas fi
1842 a2c162eb 2022-10-30 thomas
1843 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
1844 60db6857 2023-01-08 thomas }
1845 60db6857 2023-01-08 thomas
1846 60db6857 2023-01-08 thomas test_rebase_out_of_date2() {
1847 60db6857 2023-01-08 thomas local testroot=`test_init rebase_out_of_date2`
1848 60db6857 2023-01-08 thomas local commit0=`git_show_head $testroot/repo`
1849 60db6857 2023-01-08 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1850 60db6857 2023-01-08 thomas
1851 60db6857 2023-01-08 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1852 60db6857 2023-01-08 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1853 60db6857 2023-01-08 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
1854 60db6857 2023-01-08 thomas
1855 60db6857 2023-01-08 thomas local orig_commit1=`git_show_parent_commit $testroot/repo`
1856 60db6857 2023-01-08 thomas local orig_commit2=`git_show_head $testroot/repo`
1857 60db6857 2023-01-08 thomas local orig_author_time2=`git_show_author_time $testroot/repo`
1858 60db6857 2023-01-08 thomas
1859 60db6857 2023-01-08 thomas (cd $testroot/repo && git checkout -q master)
1860 60db6857 2023-01-08 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1861 60db6857 2023-01-08 thomas git_commit $testroot/repo -m "committing to zeta on master"
1862 60db6857 2023-01-08 thomas local master_commit=`git_show_head $testroot/repo`
1863 60db6857 2023-01-08 thomas
1864 60db6857 2023-01-08 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1865 60db6857 2023-01-08 thomas ret=$?
1866 60db6857 2023-01-08 thomas if [ $ret -ne 0 ]; then
1867 60db6857 2023-01-08 thomas test_done "$testroot" "$ret"
1868 60db6857 2023-01-08 thomas return 1
1869 60db6857 2023-01-08 thomas fi
1870 60db6857 2023-01-08 thomas
1871 60db6857 2023-01-08 thomas # Backdate the file alpha to an earlier version.
1872 60db6857 2023-01-08 thomas # This sets the work tree's base commit ID back to $commit0,
1873 60db6857 2023-01-08 thomas # which is out-of-date with respect to the master branch.
1874 60db6857 2023-01-08 thomas (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
1875 60db6857 2023-01-08 thomas
1876 60db6857 2023-01-08 thomas # Rebase into an out-of-date work tree should be refused.
1877 60db6857 2023-01-08 thomas (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1878 60db6857 2023-01-08 thomas 2> $testroot/stderr)
1879 60db6857 2023-01-08 thomas ret=$?
1880 60db6857 2023-01-08 thomas if [ $ret -eq 0 ]; then
1881 60db6857 2023-01-08 thomas echo "rebase succeeded unexpectedly" >&2
1882 60db6857 2023-01-08 thomas test_done "$testroot" "1"
1883 60db6857 2023-01-08 thomas return 1
1884 60db6857 2023-01-08 thomas fi
1885 60db6857 2023-01-08 thomas echo -n > $testroot/stdout.expected
1886 60db6857 2023-01-08 thomas echo -n "got: work tree must be updated before it can be used to " \
1887 60db6857 2023-01-08 thomas > $testroot/stderr.expected
1888 60db6857 2023-01-08 thomas echo "rebase a branch" >> $testroot/stderr.expected
1889 60db6857 2023-01-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1890 60db6857 2023-01-08 thomas ret=$?
1891 60db6857 2023-01-08 thomas if [ $ret -ne 0 ]; then
1892 60db6857 2023-01-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
1893 60db6857 2023-01-08 thomas fi
1894 60db6857 2023-01-08 thomas test_done "$testroot" "$ret"
1895 0b36e980 2023-01-31 thomas }
1896 0b36e980 2023-01-31 thomas
1897 0b36e980 2023-01-31 thomas test_rebase_one_commit() {
1898 0b36e980 2023-01-31 thomas local testroot=`test_init rebase_one_commit`
1899 0b36e980 2023-01-31 thomas
1900 0b36e980 2023-01-31 thomas if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1901 0b36e980 2023-01-31 thomas test_done "$testroot" 1
1902 0b36e980 2023-01-31 thomas return 1
1903 0b36e980 2023-01-31 thomas fi
1904 0b36e980 2023-01-31 thomas
1905 0b36e980 2023-01-31 thomas (cd $testroot/wt && got branch newbranch) >/dev/null
1906 0b36e980 2023-01-31 thomas
1907 0b36e980 2023-01-31 thomas echo "modified alpha on newbranch" >$testroot/wt/alpha
1908 0b36e980 2023-01-31 thomas (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
1909 0b36e980 2023-01-31 thomas (cd $testroot/wt && got update) >/dev/null
1910 0b36e980 2023-01-31 thomas local commit=`git_show_branch_head $testroot/repo newbranch`
1911 0b36e980 2023-01-31 thomas
1912 0b36e980 2023-01-31 thomas echo -n '' > $testroot/stderr.expected
1913 0b36e980 2023-01-31 thomas
1914 0b36e980 2023-01-31 thomas (cd $testroot/wt && got rebase master >$testroot/stdout \
1915 0b36e980 2023-01-31 thomas 2> $testroot/stderr)
1916 0b36e980 2023-01-31 thomas ret=$?
1917 0b36e980 2023-01-31 thomas if [ $ret -ne 0 ]; then
1918 0b36e980 2023-01-31 thomas echo "rebase comand failed unexpectedly" >&2
1919 0b36e980 2023-01-31 thomas diff -u $testroot/stderr.expected $testroot/stderr
1920 0b36e980 2023-01-31 thomas test_done "$testroot" "1"
1921 0b36e980 2023-01-31 thomas return 1
1922 0b36e980 2023-01-31 thomas fi
1923 0b36e980 2023-01-31 thomas
1924 0b36e980 2023-01-31 thomas echo "Forwarding refs/heads/master to commit $commit" \
1925 0b36e980 2023-01-31 thomas >$testroot/stdout.expected
1926 0b36e980 2023-01-31 thomas echo "Switching work tree to refs/heads/master" \
1927 0b36e980 2023-01-31 thomas >> $testroot/stdout.expected
1928 0b36e980 2023-01-31 thomas
1929 0b36e980 2023-01-31 thomas if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1930 0b36e980 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
1931 0b36e980 2023-01-31 thomas test_done "$testroot" 1
1932 0b36e980 2023-01-31 thomas return 1
1933 0b36e980 2023-01-31 thomas fi
1934 0b36e980 2023-01-31 thomas
1935 0b36e980 2023-01-31 thomas test_done "$testroot" 0
1936 a2c162eb 2022-10-30 thomas }
1937 a2c162eb 2022-10-30 thomas
1938 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1939 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1940 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1941 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1942 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1943 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1944 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1945 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1946 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1947 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1948 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1949 1996dd72 2022-09-21 thomas run_test test_rebase_forward_path_prefix
1950 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1951 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1952 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1953 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
1954 150d7275 2022-07-22 thomas run_test test_rebase_resets_committer
1955 8db00f97 2022-07-22 thomas run_test test_rebase_no_author_info
1956 8dbcf388 2022-09-04 thomas run_test test_rebase_nonbranch
1957 a2c162eb 2022-10-30 thomas run_test test_rebase_umask
1958 60db6857 2023-01-08 thomas run_test test_rebase_out_of_date2
1959 0b36e980 2023-01-31 thomas run_test test_rebase_one_commit