Blame


1 234035bc 2019-06-01 stsp #!/bin/sh
2 234035bc 2019-06-01 stsp #
3 234035bc 2019-06-01 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 234035bc 2019-06-01 stsp #
5 234035bc 2019-06-01 stsp # Permission to use, copy, modify, and distribute this software for any
6 234035bc 2019-06-01 stsp # purpose with or without fee is hereby granted, provided that the above
7 234035bc 2019-06-01 stsp # copyright notice and this permission notice appear in all copies.
8 234035bc 2019-06-01 stsp #
9 234035bc 2019-06-01 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 234035bc 2019-06-01 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 234035bc 2019-06-01 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 234035bc 2019-06-01 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 234035bc 2019-06-01 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 234035bc 2019-06-01 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 234035bc 2019-06-01 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 234035bc 2019-06-01 stsp
17 234035bc 2019-06-01 stsp . ./common.sh
18 234035bc 2019-06-01 stsp
19 234035bc 2019-06-01 stsp function test_cherrypick_basic {
20 234035bc 2019-06-01 stsp local testroot=`test_init cherrypick_basic`
21 234035bc 2019-06-01 stsp
22 234035bc 2019-06-01 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 234035bc 2019-06-01 stsp ret="$?"
24 234035bc 2019-06-01 stsp if [ "$ret" != "0" ]; then
25 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
26 234035bc 2019-06-01 stsp return 1
27 234035bc 2019-06-01 stsp fi
28 234035bc 2019-06-01 stsp
29 234035bc 2019-06-01 stsp (cd $testroot/repo && git checkout -q -b newbranch)
30 234035bc 2019-06-01 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
31 234035bc 2019-06-01 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
32 234035bc 2019-06-01 stsp
33 234035bc 2019-06-01 stsp echo "modified alpha on branch" > $testroot/repo/alpha
34 234035bc 2019-06-01 stsp (cd $testroot/repo && git rm -q beta)
35 234035bc 2019-06-01 stsp echo "new file on branch" > $testroot/repo/epsilon/new
36 234035bc 2019-06-01 stsp (cd $testroot/repo && git add epsilon/new)
37 234035bc 2019-06-01 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
38 234035bc 2019-06-01 stsp
39 234035bc 2019-06-01 stsp local branch_rev=`git_show_head $testroot/repo`
40 234035bc 2019-06-01 stsp
41 234035bc 2019-06-01 stsp (cd $testroot/wt && got cherrypick $branch_rev > $testroot/stdout)
42 234035bc 2019-06-01 stsp
43 234035bc 2019-06-01 stsp echo "G alpha" > $testroot/stdout.expected
44 234035bc 2019-06-01 stsp echo "D beta" >> $testroot/stdout.expected
45 234035bc 2019-06-01 stsp echo "A epsilon/new" >> $testroot/stdout.expected
46 a7648d7a 2019-06-02 stsp echo "Merged commit $branch_rev" >> $testroot/stdout.expected
47 234035bc 2019-06-01 stsp
48 234035bc 2019-06-01 stsp cmp -s $testroot/stdout.expected $testroot/stdout
49 234035bc 2019-06-01 stsp ret="$?"
50 234035bc 2019-06-01 stsp if [ "$ret" != "0" ]; then
51 234035bc 2019-06-01 stsp diff -u $testroot/stdout.expected $testroot/stdout
52 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
53 234035bc 2019-06-01 stsp return 1
54 234035bc 2019-06-01 stsp fi
55 234035bc 2019-06-01 stsp
56 234035bc 2019-06-01 stsp echo "modified alpha on branch" > $testroot/content.expected
57 234035bc 2019-06-01 stsp cat $testroot/wt/alpha > $testroot/content
58 234035bc 2019-06-01 stsp cmp -s $testroot/content.expected $testroot/content
59 234035bc 2019-06-01 stsp ret="$?"
60 234035bc 2019-06-01 stsp if [ "$ret" != "0" ]; then
61 234035bc 2019-06-01 stsp diff -u $testroot/content.expected $testroot/content
62 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
63 234035bc 2019-06-01 stsp return 1
64 234035bc 2019-06-01 stsp fi
65 234035bc 2019-06-01 stsp
66 234035bc 2019-06-01 stsp if [ -e $testroot/wt/beta ]; then
67 234035bc 2019-06-01 stsp echo "removed file beta still exists on disk" >&2
68 234035bc 2019-06-01 stsp test_done "$testroot" "1"
69 234035bc 2019-06-01 stsp return 1
70 234035bc 2019-06-01 stsp fi
71 234035bc 2019-06-01 stsp
72 234035bc 2019-06-01 stsp echo "new file on branch" > $testroot/content.expected
73 234035bc 2019-06-01 stsp cat $testroot/wt/epsilon/new > $testroot/content
74 234035bc 2019-06-01 stsp cmp -s $testroot/content.expected $testroot/content
75 234035bc 2019-06-01 stsp ret="$?"
76 234035bc 2019-06-01 stsp if [ "$ret" != "0" ]; then
77 234035bc 2019-06-01 stsp diff -u $testroot/content.expected $testroot/content
78 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
79 234035bc 2019-06-01 stsp return 1
80 234035bc 2019-06-01 stsp fi
81 234035bc 2019-06-01 stsp
82 2b92fad7 2019-06-02 stsp echo 'M alpha' > $testroot/stdout.expected
83 2b92fad7 2019-06-02 stsp echo 'D beta' >> $testroot/stdout.expected
84 2b92fad7 2019-06-02 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
85 2b92fad7 2019-06-02 stsp
86 2b92fad7 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
87 2b92fad7 2019-06-02 stsp
88 2b92fad7 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
89 2b92fad7 2019-06-02 stsp ret="$?"
90 2b92fad7 2019-06-02 stsp if [ "$ret" != "0" ]; then
91 2b92fad7 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
92 2b92fad7 2019-06-02 stsp fi
93 234035bc 2019-06-01 stsp test_done "$testroot" "$ret"
94 234035bc 2019-06-01 stsp }
95 234035bc 2019-06-01 stsp
96 03415a1a 2019-06-02 stsp function test_cherrypick_root_commit {
97 03415a1a 2019-06-02 stsp local testroot=`test_init cherrypick_root_commit`
98 03415a1a 2019-06-02 stsp
99 03415a1a 2019-06-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
100 03415a1a 2019-06-02 stsp ret="$?"
101 03415a1a 2019-06-02 stsp if [ "$ret" != "0" ]; then
102 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
103 03415a1a 2019-06-02 stsp return 1
104 03415a1a 2019-06-02 stsp fi
105 03415a1a 2019-06-02 stsp
106 03415a1a 2019-06-02 stsp (cd $testroot/repo && git checkout -q -b newbranch)
107 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q alpha)
108 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q beta)
109 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
110 03415a1a 2019-06-02 stsp (cd $testroot/repo && git rm -q gamma/delta)
111 03415a1a 2019-06-02 stsp mkdir -p $testroot/repo/epsilon
112 03415a1a 2019-06-02 stsp echo "new file on branch" > $testroot/repo/epsilon/new
113 03415a1a 2019-06-02 stsp (cd $testroot/repo && git add epsilon/new)
114 03415a1a 2019-06-02 stsp git_commit $testroot/repo -m "committing on newbranch"
115 03415a1a 2019-06-02 stsp
116 03415a1a 2019-06-02 stsp echo "modified new file on branch" >> $testroot/repo/epsilon/new
117 03415a1a 2019-06-02 stsp git_commit $testroot/repo -m "committing on newbranch again"
118 03415a1a 2019-06-02 stsp
119 03415a1a 2019-06-02 stsp tree=`git_show_tree $testroot/repo`
120 03415a1a 2019-06-02 stsp root_commit=`git_commit_tree $testroot/repo "new root commit" $tree`
121 03415a1a 2019-06-02 stsp
122 03415a1a 2019-06-02 stsp (cd $testroot/wt && got cherrypick $root_commit > $testroot/stdout)
123 03415a1a 2019-06-02 stsp
124 03415a1a 2019-06-02 stsp echo "A epsilon/new" > $testroot/stdout.expected
125 a7648d7a 2019-06-02 stsp echo "Merged commit $root_commit" >> $testroot/stdout.expected
126 03415a1a 2019-06-02 stsp
127 03415a1a 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
128 03415a1a 2019-06-02 stsp ret="$?"
129 03415a1a 2019-06-02 stsp if [ "$ret" != "0" ]; then
130 03415a1a 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
131 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
132 03415a1a 2019-06-02 stsp return 1
133 03415a1a 2019-06-02 stsp fi
134 03415a1a 2019-06-02 stsp
135 03415a1a 2019-06-02 stsp echo "new file on branch" > $testroot/content.expected
136 03415a1a 2019-06-02 stsp echo "modified new file on branch" >> $testroot/content.expected
137 03415a1a 2019-06-02 stsp cat $testroot/wt/epsilon/new > $testroot/content
138 03415a1a 2019-06-02 stsp cmp -s $testroot/content.expected $testroot/content
139 03415a1a 2019-06-02 stsp ret="$?"
140 03415a1a 2019-06-02 stsp if [ "$ret" != "0" ]; then
141 03415a1a 2019-06-02 stsp diff -u $testroot/content.expected $testroot/content
142 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
143 03415a1a 2019-06-02 stsp return 1
144 03415a1a 2019-06-02 stsp fi
145 03415a1a 2019-06-02 stsp
146 03415a1a 2019-06-02 stsp echo 'A epsilon/new' > $testroot/stdout.expected
147 03415a1a 2019-06-02 stsp
148 03415a1a 2019-06-02 stsp (cd $testroot/wt && got status > $testroot/stdout)
149 03415a1a 2019-06-02 stsp
150 03415a1a 2019-06-02 stsp cmp -s $testroot/stdout.expected $testroot/stdout
151 03415a1a 2019-06-02 stsp ret="$?"
152 03415a1a 2019-06-02 stsp if [ "$ret" != "0" ]; then
153 03415a1a 2019-06-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
154 03415a1a 2019-06-02 stsp fi
155 03415a1a 2019-06-02 stsp test_done "$testroot" "$ret"
156 03415a1a 2019-06-02 stsp }
157 03415a1a 2019-06-02 stsp
158 ceb466a7 2020-04-18 stsp function test_cherrypick_into_work_tree_with_conflicts {
159 ceb466a7 2020-04-18 stsp local testroot=`test_init cherrypick_into_work_tree_with_conflicts`
160 ceb466a7 2020-04-18 stsp
161 ceb466a7 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
162 ceb466a7 2020-04-18 stsp ret="$?"
163 ceb466a7 2020-04-18 stsp if [ "$ret" != "0" ]; then
164 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
165 ceb466a7 2020-04-18 stsp return 1
166 ceb466a7 2020-04-18 stsp fi
167 ceb466a7 2020-04-18 stsp
168 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git checkout -q -b newbranch)
169 ceb466a7 2020-04-18 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
170 ceb466a7 2020-04-18 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
171 ceb466a7 2020-04-18 stsp
172 ceb466a7 2020-04-18 stsp echo "modified alpha on branch" > $testroot/repo/alpha
173 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git rm -q beta)
174 ceb466a7 2020-04-18 stsp echo "new file on branch" > $testroot/repo/epsilon/new
175 ceb466a7 2020-04-18 stsp (cd $testroot/repo && git add epsilon/new)
176 ceb466a7 2020-04-18 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
177 ceb466a7 2020-04-18 stsp
178 ceb466a7 2020-04-18 stsp local branch_rev=`git_show_head $testroot/repo`
179 ceb466a7 2020-04-18 stsp
180 ceb466a7 2020-04-18 stsp # fake a merge conflict
181 ceb466a7 2020-04-18 stsp echo '<<<<<<<' > $testroot/wt/alpha
182 ceb466a7 2020-04-18 stsp echo 'alpha' >> $testroot/wt/alpha
183 ceb466a7 2020-04-18 stsp echo '=======' >> $testroot/wt/alpha
184 ceb466a7 2020-04-18 stsp echo 'alpha, too' >> $testroot/wt/alpha
185 ceb466a7 2020-04-18 stsp echo '>>>>>>>' >> $testroot/wt/alpha
186 ceb466a7 2020-04-18 stsp cp $testroot/wt/alpha $testroot/content.expected
187 ceb466a7 2020-04-18 stsp
188 ceb466a7 2020-04-18 stsp echo "C alpha" > $testroot/stdout.expected
189 ceb466a7 2020-04-18 stsp (cd $testroot/wt && got status > $testroot/stdout)
190 ceb466a7 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
191 ceb466a7 2020-04-18 stsp ret="$?"
192 ceb466a7 2020-04-18 stsp if [ "$ret" != "0" ]; then
193 ceb466a7 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
194 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
195 ceb466a7 2020-04-18 stsp return 1
196 ceb466a7 2020-04-18 stsp fi
197 ceb466a7 2020-04-18 stsp
198 ceb466a7 2020-04-18 stsp (cd $testroot/wt && got cherrypick $branch_rev \
199 ceb466a7 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
200 ceb466a7 2020-04-18 stsp ret="$?"
201 ceb466a7 2020-04-18 stsp if [ "$ret" == "0" ]; then
202 ceb466a7 2020-04-18 stsp echo "cherrypick succeeded unexpectedly" >&2
203 ceb466a7 2020-04-18 stsp test_done "$testroot" "1"
204 ceb466a7 2020-04-18 stsp return 1
205 ceb466a7 2020-04-18 stsp fi
206 ceb466a7 2020-04-18 stsp
207 ceb466a7 2020-04-18 stsp echo -n > $testroot/stdout.expected
208 ceb466a7 2020-04-18 stsp echo -n "got: work tree contains conflicted files; " \
209 ceb466a7 2020-04-18 stsp > $testroot/stderr.expected
210 ceb466a7 2020-04-18 stsp echo "these conflicts must be resolved first" \
211 ceb466a7 2020-04-18 stsp >> $testroot/stderr.expected
212 ceb466a7 2020-04-18 stsp
213 ceb466a7 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
214 ceb466a7 2020-04-18 stsp ret="$?"
215 ceb466a7 2020-04-18 stsp if [ "$ret" != "0" ]; then
216 ceb466a7 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
217 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
218 ceb466a7 2020-04-18 stsp return 1
219 ceb466a7 2020-04-18 stsp fi
220 ceb466a7 2020-04-18 stsp
221 ceb466a7 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
222 ceb466a7 2020-04-18 stsp ret="$?"
223 ceb466a7 2020-04-18 stsp if [ "$ret" != "0" ]; then
224 ceb466a7 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
225 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
226 ceb466a7 2020-04-18 stsp return 1
227 ceb466a7 2020-04-18 stsp fi
228 ceb466a7 2020-04-18 stsp
229 ceb466a7 2020-04-18 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
230 ceb466a7 2020-04-18 stsp ret="$?"
231 ceb466a7 2020-04-18 stsp if [ "$ret" != "0" ]; then
232 ceb466a7 2020-04-18 stsp diff -u $testroot/content.expected $testroot/wt/alpha
233 e7303626 2020-05-14 stsp fi
234 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
235 e7303626 2020-05-14 stsp }
236 e7303626 2020-05-14 stsp
237 e7303626 2020-05-14 stsp function test_cherrypick_modified_submodule {
238 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_modified_submodules`
239 e7303626 2020-05-14 stsp
240 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
241 e7303626 2020-05-14 stsp
242 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
243 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
244 e7303626 2020-05-14 stsp
245 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
246 e7303626 2020-05-14 stsp
247 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
248 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
249 e7303626 2020-05-14 stsp
250 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
251 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link on newbranch
252 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
253 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
254 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "modified submodule link"
255 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
256 e7303626 2020-05-14 stsp
257 e7303626 2020-05-14 stsp # This cherrypick is a no-op because Got's file index
258 e7303626 2020-05-14 stsp # does not track submodules.
259 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
260 e7303626 2020-05-14 stsp
261 e7303626 2020-05-14 stsp echo -n > $testroot/stdout.expected
262 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 e7303626 2020-05-14 stsp ret="$?"
264 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
265 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 e7303626 2020-05-14 stsp fi
267 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
268 e7303626 2020-05-14 stsp }
269 e7303626 2020-05-14 stsp
270 e7303626 2020-05-14 stsp function test_cherrypick_added_submodule {
271 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_added_submodules`
272 e7303626 2020-05-14 stsp
273 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
274 e7303626 2020-05-14 stsp
275 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
276 e7303626 2020-05-14 stsp
277 e7303626 2020-05-14 stsp # Add the repo/repo2 submodule on newbranch
278 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
279 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
280 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
281 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
282 e7303626 2020-05-14 stsp
283 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
284 e7303626 2020-05-14 stsp
285 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
286 e7303626 2020-05-14 stsp echo "Merged commit $commit_id" >> $testroot/stdout.expected
287 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
288 e7303626 2020-05-14 stsp ret="$?"
289 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
290 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 ceb466a7 2020-04-18 stsp fi
292 ceb466a7 2020-04-18 stsp test_done "$testroot" "$ret"
293 ceb466a7 2020-04-18 stsp }
294 ceb466a7 2020-04-18 stsp
295 e7303626 2020-05-14 stsp function test_cherrypick_conflict_wt_file_vs_repo_submodule {
296 e7303626 2020-05-14 stsp local testroot=`test_init cherrypick_conflict_wt_file_vs_repo_submodule`
297 e7303626 2020-05-14 stsp
298 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
299 e7303626 2020-05-14 stsp
300 e7303626 2020-05-14 stsp # Add a file which will clash with the submodule
301 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
302 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
303 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
304 e7303626 2020-05-14 stsp ret="$?"
305 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
306 e7303626 2020-05-14 stsp echo "commit failed unexpectedly" >&2
307 e7303626 2020-05-14 stsp test_done "$testroot" "1"
308 e7303626 2020-05-14 stsp return 1
309 e7303626 2020-05-14 stsp fi
310 e7303626 2020-05-14 stsp
311 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
312 e7303626 2020-05-14 stsp
313 e7303626 2020-05-14 stsp # Add the repo/repo2 submodule on newbranch
314 e7303626 2020-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
315 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
316 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
317 e7303626 2020-05-14 stsp local commit_id=`git_show_head $testroot/repo`
318 e7303626 2020-05-14 stsp
319 e7303626 2020-05-14 stsp # Modify the clashing file such that any modifications brought
320 e7303626 2020-05-14 stsp # in by 'got cherrypick' would require a merge.
321 e7303626 2020-05-14 stsp echo "This file was changed" > $testroot/wt/repo2
322 e7303626 2020-05-14 stsp
323 e7303626 2020-05-14 stsp (cd $testroot/wt && got update >/dev/null)
324 e7303626 2020-05-14 stsp (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
325 e7303626 2020-05-14 stsp
326 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
327 e7303626 2020-05-14 stsp echo "Merged commit $commit_id" >> $testroot/stdout.expected
328 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
329 e7303626 2020-05-14 stsp ret="$?"
330 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
331 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
333 e7303626 2020-05-14 stsp return 1
334 e7303626 2020-05-14 stsp fi
335 e7303626 2020-05-14 stsp
336 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
337 e7303626 2020-05-14 stsp
338 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
339 e7303626 2020-05-14 stsp echo "M repo2" >> $testroot/stdout.expected
340 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
341 e7303626 2020-05-14 stsp ret="$?"
342 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
343 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
344 e7303626 2020-05-14 stsp fi
345 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
346 e7303626 2020-05-14 stsp }
347 e7303626 2020-05-14 stsp
348 234035bc 2019-06-01 stsp run_test test_cherrypick_basic
349 03415a1a 2019-06-02 stsp run_test test_cherrypick_root_commit
350 ceb466a7 2020-04-18 stsp run_test test_cherrypick_into_work_tree_with_conflicts
351 e7303626 2020-05-14 stsp run_test test_cherrypick_modified_submodule
352 e7303626 2020-05-14 stsp run_test test_cherrypick_added_submodule
353 e7303626 2020-05-14 stsp run_test test_cherrypick_conflict_wt_file_vs_repo_submodule