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 818c7501 2019-07-11 stsp ret="$?"
45 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
78 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
88 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
98 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
114 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
125 818c7501 2019-07-11 stsp if [ "$ret" != "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 818c7501 2019-07-11 stsp ret="$?"
137 818c7501 2019-07-11 stsp if [ "$ret" != "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 a615e0e7 2020-12-16 stsp ret="$?"
148 a615e0e7 2020-12-16 stsp if [ "$ret" != "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 a615e0e7 2020-12-16 stsp fi
152 e600f124 2021-03-21 stsp
153 e600f124 2021-03-21 stsp # We should have a backup of old commits
154 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
155 e600f124 2021-03-21 stsp d_orig2=`env TZ=UTC date -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
156 e600f124 2021-03-21 stsp d_new2=`env TZ=UTC date -r $new_author_time2 +"%G-%m-%d"`
157 e600f124 2021-03-21 stsp d_0=`env TZ=UTC date -r $commit0_author_time +"%G-%m-%d"`
158 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
159 e600f124 2021-03-21 stsp -----------------------------------------------
160 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
161 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
162 e600f124 2021-03-21 stsp date: $d_orig2
163 e600f124 2021-03-21 stsp
164 e600f124 2021-03-21 stsp committing more changes on newbranch
165 e600f124 2021-03-21 stsp
166 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
167 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
168 e600f124 2021-03-21 stsp history forked at $commit0
169 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
170 e600f124 2021-03-21 stsp EOF
171 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
172 e600f124 2021-03-21 stsp ret="$?"
173 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
174 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
175 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
176 e600f124 2021-03-21 stsp fi
177 9e822917 2021-03-23 stsp
178 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
179 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
180 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
181 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
182 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
183 9e822917 2021-03-23 stsp > $testroot/stderr.expected
184 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
185 9e822917 2021-03-23 stsp ret="$?"
186 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
187 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
188 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
189 9e822917 2021-03-23 stsp fi
190 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
191 9e822917 2021-03-23 stsp ret="$?"
192 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
193 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
194 9e822917 2021-03-23 stsp fi
195 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
196 818c7501 2019-07-11 stsp }
197 818c7501 2019-07-11 stsp
198 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
199 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
200 818c7501 2019-07-11 stsp
201 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
202 818c7501 2019-07-11 stsp ret="$?"
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
205 818c7501 2019-07-11 stsp return 1
206 818c7501 2019-07-11 stsp fi
207 818c7501 2019-07-11 stsp
208 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
209 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
210 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
211 818c7501 2019-07-11 stsp
212 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
213 818c7501 2019-07-11 stsp 2> $testroot/stderr)
214 818c7501 2019-07-11 stsp
215 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
216 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
217 818c7501 2019-07-11 stsp ret="$?"
218 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
219 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
221 818c7501 2019-07-11 stsp return 1
222 818c7501 2019-07-11 stsp fi
223 818c7501 2019-07-11 stsp
224 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
225 818c7501 2019-07-11 stsp > $testroot/stderr.expected
226 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
227 818c7501 2019-07-11 stsp ret="$?"
228 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
229 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
230 818c7501 2019-07-11 stsp fi
231 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
232 818c7501 2019-07-11 stsp }
233 818c7501 2019-07-11 stsp
234 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
235 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
236 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
237 818c7501 2019-07-11 stsp
238 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
239 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
240 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
241 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
242 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
243 818c7501 2019-07-11 stsp
244 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
245 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
246 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
247 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
248 818c7501 2019-07-11 stsp
249 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
250 818c7501 2019-07-11 stsp ret="$?"
251 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
252 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
253 818c7501 2019-07-11 stsp return 1
254 818c7501 2019-07-11 stsp fi
255 818c7501 2019-07-11 stsp
256 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
257 818c7501 2019-07-11 stsp 2> $testroot/stderr)
258 818c7501 2019-07-11 stsp
259 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
260 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
261 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
262 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
263 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
264 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
265 818c7501 2019-07-11 stsp ret="$?"
266 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
267 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
268 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
269 818c7501 2019-07-11 stsp return 1
270 818c7501 2019-07-11 stsp fi
271 818c7501 2019-07-11 stsp
272 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
273 818c7501 2019-07-11 stsp > $testroot/stderr.expected
274 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
275 818c7501 2019-07-11 stsp ret="$?"
276 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
277 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
278 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
279 818c7501 2019-07-11 stsp return 1
280 818c7501 2019-07-11 stsp fi
281 818c7501 2019-07-11 stsp
282 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
283 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
284 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
285 f69721c3 2019-10-21 stsp >> $testroot/content.expected
286 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
287 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
288 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
289 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
290 54d5be07 2021-06-03 stsp >> $testroot/content.expected
291 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
292 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
293 818c7501 2019-07-11 stsp ret="$?"
294 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
295 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
296 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
297 818c7501 2019-07-11 stsp return 1
298 818c7501 2019-07-11 stsp fi
299 818c7501 2019-07-11 stsp
300 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
301 818c7501 2019-07-11 stsp
302 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
303 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
304 818c7501 2019-07-11 stsp ret="$?"
305 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
306 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
307 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
308 818c7501 2019-07-11 stsp return 1
309 818c7501 2019-07-11 stsp fi
310 818c7501 2019-07-11 stsp
311 818c7501 2019-07-11 stsp # resolve the conflict
312 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
313 818c7501 2019-07-11 stsp
314 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
315 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
316 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
317 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
318 f032f1f7 2019-08-04 stsp ret="$?"
319 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
320 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
321 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
322 f032f1f7 2019-08-04 stsp return 1
323 f032f1f7 2019-08-04 stsp fi
324 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
325 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
326 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
327 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
328 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
329 f032f1f7 2019-08-04 stsp ret="$?"
330 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
331 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
332 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
333 f032f1f7 2019-08-04 stsp return 1
334 f032f1f7 2019-08-04 stsp fi
335 f032f1f7 2019-08-04 stsp
336 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
337 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
338 818c7501 2019-07-11 stsp
339 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
340 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
341 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
342 818c7501 2019-07-11 stsp
343 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
344 818c7501 2019-07-11 stsp > $testroot/stdout.expected
345 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
346 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
347 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
348 818c7501 2019-07-11 stsp
349 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
350 818c7501 2019-07-11 stsp ret="$?"
351 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
352 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
353 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
354 818c7501 2019-07-11 stsp return 1
355 818c7501 2019-07-11 stsp fi
356 818c7501 2019-07-11 stsp
357 818c7501 2019-07-11 stsp
358 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
359 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
360 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
361 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
362 818c7501 2019-07-11 stsp ret="$?"
363 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
364 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
365 818c7501 2019-07-11 stsp fi
366 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
367 818c7501 2019-07-11 stsp }
368 818c7501 2019-07-11 stsp
369 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
370 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
371 818c7501 2019-07-11 stsp
372 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
373 818c7501 2019-07-11 stsp
374 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
375 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
376 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
377 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
378 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
379 818c7501 2019-07-11 stsp
380 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
381 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
382 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
383 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
384 818c7501 2019-07-11 stsp
385 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
386 818c7501 2019-07-11 stsp ret="$?"
387 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
388 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
389 818c7501 2019-07-11 stsp return 1
390 818c7501 2019-07-11 stsp fi
391 818c7501 2019-07-11 stsp
392 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
393 818c7501 2019-07-11 stsp 2> $testroot/stderr)
394 818c7501 2019-07-11 stsp
395 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
396 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
397 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
398 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
399 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
400 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
401 818c7501 2019-07-11 stsp ret="$?"
402 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
403 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
405 818c7501 2019-07-11 stsp return 1
406 818c7501 2019-07-11 stsp fi
407 818c7501 2019-07-11 stsp
408 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
409 818c7501 2019-07-11 stsp > $testroot/stderr.expected
410 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
411 818c7501 2019-07-11 stsp ret="$?"
412 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
413 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
414 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
415 818c7501 2019-07-11 stsp return 1
416 818c7501 2019-07-11 stsp fi
417 818c7501 2019-07-11 stsp
418 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
419 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
420 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
421 f69721c3 2019-10-21 stsp >> $testroot/content.expected
422 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
423 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
424 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
425 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
426 54d5be07 2021-06-03 stsp >> $testroot/content.expected
427 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
428 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
429 818c7501 2019-07-11 stsp ret="$?"
430 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
431 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
432 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
433 818c7501 2019-07-11 stsp return 1
434 818c7501 2019-07-11 stsp fi
435 818c7501 2019-07-11 stsp
436 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
437 818c7501 2019-07-11 stsp
438 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
439 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
440 818c7501 2019-07-11 stsp ret="$?"
441 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
442 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
443 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
444 818c7501 2019-07-11 stsp return 1
445 818c7501 2019-07-11 stsp fi
446 818c7501 2019-07-11 stsp
447 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
448 818c7501 2019-07-11 stsp
449 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
450 818c7501 2019-07-11 stsp
451 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
452 818c7501 2019-07-11 stsp > $testroot/stdout.expected
453 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
454 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
455 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
456 818c7501 2019-07-11 stsp
457 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
458 818c7501 2019-07-11 stsp ret="$?"
459 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
460 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
461 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
462 818c7501 2019-07-11 stsp return 1
463 818c7501 2019-07-11 stsp fi
464 818c7501 2019-07-11 stsp
465 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
466 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
467 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
468 818c7501 2019-07-11 stsp ret="$?"
469 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
470 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
471 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
472 818c7501 2019-07-11 stsp return 1
473 818c7501 2019-07-11 stsp fi
474 818c7501 2019-07-11 stsp
475 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
476 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
477 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
478 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
479 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
480 818c7501 2019-07-11 stsp ret="$?"
481 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
482 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
483 818c7501 2019-07-11 stsp fi
484 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
485 818c7501 2019-07-11 stsp }
486 818c7501 2019-07-11 stsp
487 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
488 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
489 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
490 ff0d2220 2019-07-11 stsp
491 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
492 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
493 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
494 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
495 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
496 ff0d2220 2019-07-11 stsp
497 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
498 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
499 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
500 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
501 ff0d2220 2019-07-11 stsp
502 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
503 ff0d2220 2019-07-11 stsp ret="$?"
504 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
505 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
506 ff0d2220 2019-07-11 stsp return 1
507 ff0d2220 2019-07-11 stsp fi
508 ff0d2220 2019-07-11 stsp
509 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
510 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
511 ff0d2220 2019-07-11 stsp
512 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
513 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
514 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
515 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
516 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
517 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
518 ff0d2220 2019-07-11 stsp ret="$?"
519 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
520 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
521 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
522 ff0d2220 2019-07-11 stsp return 1
523 ff0d2220 2019-07-11 stsp fi
524 ff0d2220 2019-07-11 stsp
525 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
526 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
527 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
528 ff0d2220 2019-07-11 stsp ret="$?"
529 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
530 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
531 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
532 ff0d2220 2019-07-11 stsp return 1
533 ff0d2220 2019-07-11 stsp fi
534 ff0d2220 2019-07-11 stsp
535 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
536 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
537 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
538 f69721c3 2019-10-21 stsp >> $testroot/content.expected
539 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
540 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
541 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
542 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
543 54d5be07 2021-06-03 stsp >> $testroot/content.expected
544 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
545 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
546 ff0d2220 2019-07-11 stsp ret="$?"
547 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
548 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
549 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
550 ff0d2220 2019-07-11 stsp return 1
551 ff0d2220 2019-07-11 stsp fi
552 ff0d2220 2019-07-11 stsp
553 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
554 ff0d2220 2019-07-11 stsp
555 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
556 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
557 ff0d2220 2019-07-11 stsp ret="$?"
558 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
559 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
561 ff0d2220 2019-07-11 stsp return 1
562 ff0d2220 2019-07-11 stsp fi
563 ff0d2220 2019-07-11 stsp
564 ff0d2220 2019-07-11 stsp # resolve the conflict
565 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
566 ff0d2220 2019-07-11 stsp
567 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
568 ff0d2220 2019-07-11 stsp
569 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
570 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
571 ff0d2220 2019-07-11 stsp
572 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
573 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
574 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
575 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
576 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
577 ff0d2220 2019-07-11 stsp
578 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
579 ff0d2220 2019-07-11 stsp ret="$?"
580 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
581 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
582 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
583 ff0d2220 2019-07-11 stsp return 1
584 ff0d2220 2019-07-11 stsp fi
585 ff0d2220 2019-07-11 stsp
586 ff0d2220 2019-07-11 stsp
587 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
588 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
589 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
590 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
591 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
592 7d5807f4 2019-07-11 stsp ret="$?"
593 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
594 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
595 7d5807f4 2019-07-11 stsp fi
596 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
597 7d5807f4 2019-07-11 stsp }
598 7d5807f4 2019-07-11 stsp
599 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
600 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
601 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
602 7d5807f4 2019-07-11 stsp
603 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
604 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
605 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
606 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
607 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
608 7d5807f4 2019-07-11 stsp
609 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
610 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
611 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
612 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
613 7d5807f4 2019-07-11 stsp
614 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
615 7d5807f4 2019-07-11 stsp ret="$?"
616 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
617 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
618 7d5807f4 2019-07-11 stsp return 1
619 7d5807f4 2019-07-11 stsp fi
620 7d5807f4 2019-07-11 stsp
621 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
622 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
623 7d5807f4 2019-07-11 stsp
624 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
625 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
626 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
627 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
628 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
629 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
630 7d5807f4 2019-07-11 stsp ret="$?"
631 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
632 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
633 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
634 7d5807f4 2019-07-11 stsp return 1
635 7d5807f4 2019-07-11 stsp fi
636 7d5807f4 2019-07-11 stsp
637 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
638 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
639 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
640 7d5807f4 2019-07-11 stsp ret="$?"
641 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
642 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
643 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
644 7d5807f4 2019-07-11 stsp return 1
645 7d5807f4 2019-07-11 stsp fi
646 7d5807f4 2019-07-11 stsp
647 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
648 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
649 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
650 f69721c3 2019-10-21 stsp >> $testroot/content.expected
651 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
652 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
653 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
654 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
655 54d5be07 2021-06-03 stsp >> $testroot/content.expected
656 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
657 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
658 7d5807f4 2019-07-11 stsp ret="$?"
659 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
660 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
661 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
662 7d5807f4 2019-07-11 stsp return 1
663 7d5807f4 2019-07-11 stsp fi
664 7d5807f4 2019-07-11 stsp
665 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
666 7d5807f4 2019-07-11 stsp
667 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
668 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
669 ff0d2220 2019-07-11 stsp ret="$?"
670 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
671 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
672 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
673 7d5807f4 2019-07-11 stsp return 1
674 ff0d2220 2019-07-11 stsp fi
675 7d5807f4 2019-07-11 stsp
676 7d5807f4 2019-07-11 stsp for cmd in update commit; do
677 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
678 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
679 7d5807f4 2019-07-11 stsp
680 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
681 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
682 7d5807f4 2019-07-11 stsp ret="$?"
683 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
684 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
685 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
686 7d5807f4 2019-07-11 stsp return 1
687 7d5807f4 2019-07-11 stsp fi
688 7d5807f4 2019-07-11 stsp
689 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
690 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
691 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
692 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
693 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
694 7d5807f4 2019-07-11 stsp ret="$?"
695 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
696 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
697 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
698 7d5807f4 2019-07-11 stsp return 1
699 7d5807f4 2019-07-11 stsp fi
700 7d5807f4 2019-07-11 stsp done
701 64c6d990 2019-07-11 stsp
702 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
703 64c6d990 2019-07-11 stsp }
704 64c6d990 2019-07-11 stsp
705 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
706 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
707 64c6d990 2019-07-11 stsp
708 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
709 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
710 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
711 64c6d990 2019-07-11 stsp
712 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
713 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
714 64c6d990 2019-07-11 stsp
715 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
716 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
717 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
718 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
719 64c6d990 2019-07-11 stsp
720 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
721 64c6d990 2019-07-11 stsp ret="$?"
722 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
723 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
724 64c6d990 2019-07-11 stsp return 1
725 64c6d990 2019-07-11 stsp fi
726 7d5807f4 2019-07-11 stsp
727 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
728 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
729 64c6d990 2019-07-11 stsp
730 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
731 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
732 64c6d990 2019-07-11 stsp ret="$?"
733 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
734 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
735 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
736 64c6d990 2019-07-11 stsp return 1
737 64c6d990 2019-07-11 stsp fi
738 64c6d990 2019-07-11 stsp
739 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
740 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
741 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
742 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
743 787c8eb6 2019-07-11 stsp ret="$?"
744 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
745 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
746 787c8eb6 2019-07-11 stsp fi
747 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
748 787c8eb6 2019-07-11 stsp }
749 787c8eb6 2019-07-11 stsp
750 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
751 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
752 787c8eb6 2019-07-11 stsp
753 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
754 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
755 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
756 787c8eb6 2019-07-11 stsp
757 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
758 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
759 787c8eb6 2019-07-11 stsp
760 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
761 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
762 787c8eb6 2019-07-11 stsp
763 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
764 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
765 787c8eb6 2019-07-11 stsp
766 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
767 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
768 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
769 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
770 787c8eb6 2019-07-11 stsp
771 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
772 787c8eb6 2019-07-11 stsp ret="$?"
773 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
774 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
775 787c8eb6 2019-07-11 stsp return 1
776 787c8eb6 2019-07-11 stsp fi
777 787c8eb6 2019-07-11 stsp
778 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
779 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
780 787c8eb6 2019-07-11 stsp
781 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
782 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
783 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
784 787c8eb6 2019-07-11 stsp
785 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
786 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
787 64c6d990 2019-07-11 stsp ret="$?"
788 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
789 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
790 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
791 787c8eb6 2019-07-11 stsp return 1
792 64c6d990 2019-07-11 stsp fi
793 787c8eb6 2019-07-11 stsp
794 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
795 787c8eb6 2019-07-11 stsp > $testroot/log)
796 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
797 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
798 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
799 787c8eb6 2019-07-11 stsp ret="$?"
800 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
801 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
802 fc66b545 2019-08-12 stsp fi
803 fc66b545 2019-08-12 stsp
804 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
805 fc66b545 2019-08-12 stsp }
806 fc66b545 2019-08-12 stsp
807 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
808 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
809 fc66b545 2019-08-12 stsp
810 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
811 fc66b545 2019-08-12 stsp ret="$?"
812 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
813 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
814 fc66b545 2019-08-12 stsp return 1
815 fc66b545 2019-08-12 stsp fi
816 fc66b545 2019-08-12 stsp
817 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
818 fc66b545 2019-08-12 stsp
819 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
820 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
821 fc66b545 2019-08-12 stsp > /dev/null)
822 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
823 fc66b545 2019-08-12 stsp
824 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
825 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
826 fc66b545 2019-08-12 stsp
827 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
828 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
829 fc66b545 2019-08-12 stsp ret="$?"
830 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
831 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
832 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
833 fc66b545 2019-08-12 stsp return 1
834 787c8eb6 2019-07-11 stsp fi
835 787c8eb6 2019-07-11 stsp
836 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
837 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
838 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
839 fc66b545 2019-08-12 stsp ret="$?"
840 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
841 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
842 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
843 fc66b545 2019-08-12 stsp return 1
844 fc66b545 2019-08-12 stsp fi
845 fc66b545 2019-08-12 stsp
846 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
847 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
848 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 fc66b545 2019-08-12 stsp ret="$?"
850 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
851 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 fc66b545 2019-08-12 stsp fi
853 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
854 ff0d2220 2019-07-11 stsp }
855 38b0338b 2019-11-29 stsp
856 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
857 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
858 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
859 38b0338b 2019-11-29 stsp
860 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
861 38b0338b 2019-11-29 stsp ret="$?"
862 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
863 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
864 38b0338b 2019-11-29 stsp return 1
865 38b0338b 2019-11-29 stsp fi
866 38b0338b 2019-11-29 stsp
867 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
868 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
869 38b0338b 2019-11-29 stsp > /dev/null)
870 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
871 ff0d2220 2019-07-11 stsp
872 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
873 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
874 38b0338b 2019-11-29 stsp > /dev/null)
875 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
876 38b0338b 2019-11-29 stsp
877 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
878 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
879 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
880 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
881 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
882 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
883 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
884 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
885 38b0338b 2019-11-29 stsp
886 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
887 38b0338b 2019-11-29 stsp
888 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
889 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
890 38b0338b 2019-11-29 stsp
891 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
892 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
893 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
894 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
895 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
896 38b0338b 2019-11-29 stsp ret="$?"
897 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
898 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
899 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
900 38b0338b 2019-11-29 stsp return 1
901 38b0338b 2019-11-29 stsp fi
902 38b0338b 2019-11-29 stsp
903 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
904 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
905 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
906 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
907 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
908 38b0338b 2019-11-29 stsp ret="$?"
909 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
910 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
911 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
912 38b0338b 2019-11-29 stsp return 1
913 38b0338b 2019-11-29 stsp fi
914 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
915 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
916 38b0338b 2019-11-29 stsp ret="$?"
917 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
918 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
919 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
920 38b0338b 2019-11-29 stsp return 1
921 38b0338b 2019-11-29 stsp fi
922 38b0338b 2019-11-29 stsp
923 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
924 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
925 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
926 38b0338b 2019-11-29 stsp ret="$?"
927 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
928 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
929 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
930 38b0338b 2019-11-29 stsp return 1
931 38b0338b 2019-11-29 stsp fi
932 38b0338b 2019-11-29 stsp
933 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
934 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
935 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
936 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
937 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
938 38b0338b 2019-11-29 stsp ret="$?"
939 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
940 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
942 38b0338b 2019-11-29 stsp fi
943 e600f124 2021-03-21 stsp
944 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
945 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
946 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
947 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 e600f124 2021-03-21 stsp ret="$?"
949 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
950 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
951 e600f124 2021-03-21 stsp fi
952 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
953 38b0338b 2019-11-29 stsp }
954 e51d7b55 2020-01-04 stsp
955 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
956 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
957 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
958 e51d7b55 2020-01-04 stsp
959 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
960 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
961 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
962 38b0338b 2019-11-29 stsp
963 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
964 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
965 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
966 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
967 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
968 e51d7b55 2020-01-04 stsp
969 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
970 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
971 e51d7b55 2020-01-04 stsp
972 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
973 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
974 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
975 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
976 e51d7b55 2020-01-04 stsp
977 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
978 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
979 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
980 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
981 e51d7b55 2020-01-04 stsp
982 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
983 e51d7b55 2020-01-04 stsp > /dev/null
984 e51d7b55 2020-01-04 stsp ret="$?"
985 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
986 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
987 e51d7b55 2020-01-04 stsp return 1
988 e51d7b55 2020-01-04 stsp fi
989 e51d7b55 2020-01-04 stsp
990 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
991 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
992 e51d7b55 2020-01-04 stsp
993 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
994 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
995 e51d7b55 2020-01-04 stsp ret="$?"
996 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
997 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
998 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
999 e51d7b55 2020-01-04 stsp return 1
1000 e51d7b55 2020-01-04 stsp fi
1001 e51d7b55 2020-01-04 stsp
1002 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1003 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1004 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1005 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1006 e51d7b55 2020-01-04 stsp ret="$?"
1007 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1008 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1009 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1010 e51d7b55 2020-01-04 stsp return 1
1011 e51d7b55 2020-01-04 stsp fi
1012 e51d7b55 2020-01-04 stsp
1013 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1014 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1015 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1016 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1017 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1018 1ae0a341 2020-02-14 stsp ret="$?"
1019 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1020 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1021 1ae0a341 2020-02-14 stsp fi
1022 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1023 1ae0a341 2020-02-14 stsp }
1024 1ae0a341 2020-02-14 stsp
1025 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1026 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1027 1ae0a341 2020-02-14 stsp
1028 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1029 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1030 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1031 1ae0a341 2020-02-14 stsp
1032 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1033 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1034 1ae0a341 2020-02-14 stsp
1035 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1036 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1037 1ae0a341 2020-02-14 stsp
1038 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1039 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1040 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1041 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1042 1ae0a341 2020-02-14 stsp
1043 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1044 1ae0a341 2020-02-14 stsp ret="$?"
1045 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1046 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1047 1ae0a341 2020-02-14 stsp return 1
1048 1ae0a341 2020-02-14 stsp fi
1049 1ae0a341 2020-02-14 stsp
1050 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1051 1ae0a341 2020-02-14 stsp
1052 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1053 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1054 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1055 1ae0a341 2020-02-14 stsp
1056 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1057 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1058 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1059 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1060 1ae0a341 2020-02-14 stsp
1061 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1062 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1063 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1064 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1065 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1066 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1067 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1068 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1069 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1070 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1071 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1072 1ae0a341 2020-02-14 stsp
1073 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1074 e51d7b55 2020-01-04 stsp ret="$?"
1075 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1076 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1078 1ae0a341 2020-02-14 stsp return 1
1079 e51d7b55 2020-01-04 stsp fi
1080 1ae0a341 2020-02-14 stsp
1081 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1082 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1083 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1084 1ae0a341 2020-02-14 stsp ret="$?"
1085 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1086 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1087 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1088 1ae0a341 2020-02-14 stsp return 1
1089 1ae0a341 2020-02-14 stsp fi
1090 1ae0a341 2020-02-14 stsp
1091 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1092 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1093 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1094 1ae0a341 2020-02-14 stsp ret="$?"
1095 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1096 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1097 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1098 1ae0a341 2020-02-14 stsp return 1
1099 1ae0a341 2020-02-14 stsp fi
1100 1ae0a341 2020-02-14 stsp
1101 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1102 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1103 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1104 1ae0a341 2020-02-14 stsp return 1
1105 1ae0a341 2020-02-14 stsp fi
1106 1ae0a341 2020-02-14 stsp
1107 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1108 1ae0a341 2020-02-14 stsp
1109 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1110 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1111 1ae0a341 2020-02-14 stsp ret="$?"
1112 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1113 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1114 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1115 1ae0a341 2020-02-14 stsp return 1
1116 1ae0a341 2020-02-14 stsp fi
1117 1ae0a341 2020-02-14 stsp
1118 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1119 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1120 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1121 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1122 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1123 1ae0a341 2020-02-14 stsp ret="$?"
1124 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1125 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1126 1ae0a341 2020-02-14 stsp fi
1127 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1128 e51d7b55 2020-01-04 stsp }
1129 ca6da77d 2020-03-22 stsp
1130 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1131 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1132 ca6da77d 2020-03-22 stsp
1133 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1134 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1135 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1136 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1137 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1138 ca6da77d 2020-03-22 stsp
1139 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1140 a740a1b3 2020-03-22 stsp
1141 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1142 ca6da77d 2020-03-22 stsp
1143 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1144 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1145 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1146 ca6da77d 2020-03-22 stsp
1147 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1148 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1149 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1150 a740a1b3 2020-03-22 stsp
1151 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1152 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1153 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1154 ca6da77d 2020-03-22 stsp
1155 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1156 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1157 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1158 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1159 a740a1b3 2020-03-22 stsp
1160 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1161 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1162 ca6da77d 2020-03-22 stsp
1163 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1164 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1165 ca6da77d 2020-03-22 stsp
1166 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1167 ca6da77d 2020-03-22 stsp local new_commit1=`git_show_head $testroot/repo`
1168 ca6da77d 2020-03-22 stsp
1169 ca6da77d 2020-03-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1170 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1171 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1172 ca6da77d 2020-03-22 stsp
1173 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1174 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1175 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1176 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1177 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1178 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1179 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1180 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1181 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1182 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1183 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1184 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1185 ca6da77d 2020-03-22 stsp
1186 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1187 ca6da77d 2020-03-22 stsp ret="$?"
1188 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1189 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1190 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1191 ca6da77d 2020-03-22 stsp return 1
1192 ca6da77d 2020-03-22 stsp fi
1193 ca6da77d 2020-03-22 stsp
1194 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1195 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1196 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1197 ca6da77d 2020-03-22 stsp ret="$?"
1198 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1199 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1200 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1201 ca6da77d 2020-03-22 stsp return 1
1202 ca6da77d 2020-03-22 stsp fi
1203 ca6da77d 2020-03-22 stsp
1204 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1205 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1206 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1207 ca6da77d 2020-03-22 stsp return 1
1208 ca6da77d 2020-03-22 stsp fi
1209 ca6da77d 2020-03-22 stsp
1210 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1211 ca6da77d 2020-03-22 stsp
1212 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1213 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1214 ca6da77d 2020-03-22 stsp ret="$?"
1215 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1216 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1217 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1218 ca6da77d 2020-03-22 stsp return 1
1219 ca6da77d 2020-03-22 stsp fi
1220 ca6da77d 2020-03-22 stsp
1221 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1222 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1223 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1224 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1225 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1226 70551d57 2020-04-24 stsp ret="$?"
1227 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1228 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1229 70551d57 2020-04-24 stsp fi
1230 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1231 70551d57 2020-04-24 stsp }
1232 70551d57 2020-04-24 stsp
1233 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1234 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1235 70551d57 2020-04-24 stsp
1236 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1237 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1238 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1239 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1240 70551d57 2020-04-24 stsp
1241 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1242 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1243 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1244 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1245 70551d57 2020-04-24 stsp
1246 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1247 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1248 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1249 70551d57 2020-04-24 stsp
1250 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1251 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1252 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1253 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1254 70551d57 2020-04-24 stsp
1255 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1256 70551d57 2020-04-24 stsp ret="$?"
1257 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1258 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1259 70551d57 2020-04-24 stsp return 1
1260 70551d57 2020-04-24 stsp fi
1261 70551d57 2020-04-24 stsp
1262 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1263 70551d57 2020-04-24 stsp
1264 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1265 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1266 70551d57 2020-04-24 stsp ret="$?"
1267 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1268 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1269 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1270 70551d57 2020-04-24 stsp return 1
1271 70551d57 2020-04-24 stsp fi
1272 70551d57 2020-04-24 stsp
1273 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1274 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1275 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1276 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1277 70551d57 2020-04-24 stsp
1278 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1279 70551d57 2020-04-24 stsp
1280 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1281 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1282 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1283 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1284 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1285 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1286 70551d57 2020-04-24 stsp
1287 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1288 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1289 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1290 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1291 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1292 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1293 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1294 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1295 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1296 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1297 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1298 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1299 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1300 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1301 70551d57 2020-04-24 stsp
1302 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1303 ca6da77d 2020-03-22 stsp ret="$?"
1304 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1305 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1306 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1307 70551d57 2020-04-24 stsp return 1
1308 ca6da77d 2020-03-22 stsp fi
1309 70551d57 2020-04-24 stsp
1310 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1311 70551d57 2020-04-24 stsp ret="$?"
1312 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1313 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1314 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1315 70551d57 2020-04-24 stsp return 1
1316 70551d57 2020-04-24 stsp fi
1317 70551d57 2020-04-24 stsp
1318 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1319 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1320 70551d57 2020-04-24 stsp ret="$?"
1321 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1322 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1323 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1324 70551d57 2020-04-24 stsp return 1
1325 70551d57 2020-04-24 stsp fi
1326 70551d57 2020-04-24 stsp
1327 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1328 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1329 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1330 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1331 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1332 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1333 70551d57 2020-04-24 stsp ret="$?"
1334 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1335 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1336 70551d57 2020-04-24 stsp fi
1337 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1338 ca6da77d 2020-03-22 stsp }
1339 ca6da77d 2020-03-22 stsp
1340 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1341 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1342 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1343 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1344 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1345 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1346 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1347 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1348 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1349 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1350 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1351 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1352 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1353 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1354 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file