Blame


1 dc5351b4 2019-07-30 stsp #!/bin/sh
2 dc5351b4 2019-07-30 stsp #
3 dc5351b4 2019-07-30 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 dc5351b4 2019-07-30 stsp #
5 dc5351b4 2019-07-30 stsp # Permission to use, copy, modify, and distribute this software for any
6 dc5351b4 2019-07-30 stsp # purpose with or without fee is hereby granted, provided that the above
7 dc5351b4 2019-07-30 stsp # copyright notice and this permission notice appear in all copies.
8 dc5351b4 2019-07-30 stsp #
9 dc5351b4 2019-07-30 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 dc5351b4 2019-07-30 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 dc5351b4 2019-07-30 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 dc5351b4 2019-07-30 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 dc5351b4 2019-07-30 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 dc5351b4 2019-07-30 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 dc5351b4 2019-07-30 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 dc5351b4 2019-07-30 stsp
17 dc5351b4 2019-07-30 stsp . ./common.sh
18 dc5351b4 2019-07-30 stsp
19 f6cae3ed 2020-09-13 naddy test_branch_create() {
20 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_create`
21 da76fce2 2020-02-24 stsp local commit_id0=`git_show_head $testroot/repo`
22 dc5351b4 2019-07-30 stsp
23 dc5351b4 2019-07-30 stsp # Create a branch based on repository's HEAD reference
24 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo newbranch
25 dc5351b4 2019-07-30 stsp ret="$?"
26 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
27 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
28 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
29 dc5351b4 2019-07-30 stsp return 1
30 dc5351b4 2019-07-30 stsp fi
31 dc5351b4 2019-07-30 stsp
32 dc5351b4 2019-07-30 stsp # Ensure that Git recognizes the branch Got has created
33 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q newbranch)
34 dc5351b4 2019-07-30 stsp ret="$?"
35 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
36 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
37 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
38 dc5351b4 2019-07-30 stsp return 1
39 dc5351b4 2019-07-30 stsp fi
40 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
41 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
42 dc5351b4 2019-07-30 stsp
43 dc5351b4 2019-07-30 stsp got checkout -b newbranch $testroot/repo $testroot/wt >/dev/null
44 dc5351b4 2019-07-30 stsp ret="$?"
45 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
46 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
47 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
48 dc5351b4 2019-07-30 stsp return 1
49 dc5351b4 2019-07-30 stsp fi
50 dc5351b4 2019-07-30 stsp
51 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/content.expected
52 dc5351b4 2019-07-30 stsp cat $testroot/wt/gamma/delta > $testroot/content
53 dc5351b4 2019-07-30 stsp cmp -s $testroot/content.expected $testroot/content
54 dc5351b4 2019-07-30 stsp ret="$?"
55 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
56 dc5351b4 2019-07-30 stsp diff -u $testroot/content.expected $testroot/content
57 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
58 dc5351b4 2019-07-30 stsp return 1
59 dc5351b4 2019-07-30 stsp fi
60 dc5351b4 2019-07-30 stsp
61 dc5351b4 2019-07-30 stsp # Create a branch based on the work tree's branch
62 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n anotherbranch)
63 dc5351b4 2019-07-30 stsp ret="$?"
64 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
65 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
66 dc5351b4 2019-07-30 stsp return 1
67 dc5351b4 2019-07-30 stsp fi
68 dc5351b4 2019-07-30 stsp
69 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q anotherbranch)
70 dc5351b4 2019-07-30 stsp ret="$?"
71 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
72 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
73 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
74 dc5351b4 2019-07-30 stsp return 1
75 dc5351b4 2019-07-30 stsp fi
76 dc5351b4 2019-07-30 stsp
77 dc5351b4 2019-07-30 stsp # Create a branch based on another specific branch
78 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n -c master yetanotherbranch)
79 dc5351b4 2019-07-30 stsp ret="$?"
80 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
81 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
82 dc5351b4 2019-07-30 stsp return 1
83 dc5351b4 2019-07-30 stsp fi
84 dc5351b4 2019-07-30 stsp
85 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q yetanotherbranch)
86 a4f89d48 2019-08-25 stsp ret="$?"
87 a4f89d48 2019-08-25 stsp if [ "$ret" != "0" ]; then
88 a4f89d48 2019-08-25 stsp echo "git checkout command failed unexpectedly"
89 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
90 a4f89d48 2019-08-25 stsp return 1
91 a4f89d48 2019-08-25 stsp fi
92 a4f89d48 2019-08-25 stsp
93 a4f89d48 2019-08-25 stsp # Create a branch based on a specific commit
94 a4f89d48 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
95 a74f7e83 2019-11-10 stsp got branch -r $testroot/repo -c $commit_id commitbranch
96 dc5351b4 2019-07-30 stsp ret="$?"
97 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
98 a4f89d48 2019-08-25 stsp echo "got branch command failed unexpectedly"
99 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
100 a4f89d48 2019-08-25 stsp return 1
101 a4f89d48 2019-08-25 stsp fi
102 a4f89d48 2019-08-25 stsp
103 a4f89d48 2019-08-25 stsp (cd $testroot/repo && git checkout -q commitbranch)
104 a4f89d48 2019-08-25 stsp ret="$?"
105 a4f89d48 2019-08-25 stsp if [ "$ret" != "0" ]; then
106 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
107 da76fce2 2020-02-24 stsp test_done "$testroot" "$ret"
108 da76fce2 2020-02-24 stsp return 1
109 dc5351b4 2019-07-30 stsp fi
110 da76fce2 2020-02-24 stsp
111 da76fce2 2020-02-24 stsp # Create a branch and let the work tree be updated to it
112 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -c $commit_id0 updatebranch \
113 da76fce2 2020-02-24 stsp > $testroot/stdout)
114 da76fce2 2020-02-24 stsp
115 da76fce2 2020-02-24 stsp echo -n "Switching work tree from refs/heads/newbranch to " \
116 da76fce2 2020-02-24 stsp > $testroot/stdout.expected
117 da76fce2 2020-02-24 stsp echo "refs/heads/updatebranch" >> $testroot/stdout.expected
118 da76fce2 2020-02-24 stsp echo "U gamma/delta" >> $testroot/stdout.expected
119 da76fce2 2020-02-24 stsp echo "Updated to commit $commit_id0" >> $testroot/stdout.expected
120 da76fce2 2020-02-24 stsp
121 da76fce2 2020-02-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 da76fce2 2020-02-24 stsp ret="$?"
123 da76fce2 2020-02-24 stsp if [ "$ret" != "0" ]; then
124 da76fce2 2020-02-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
125 da76fce2 2020-02-24 stsp fi
126 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
127 dc5351b4 2019-07-30 stsp }
128 dc5351b4 2019-07-30 stsp
129 f6cae3ed 2020-09-13 naddy test_branch_list() {
130 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_list`
131 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
132 dc5351b4 2019-07-30 stsp
133 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
134 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
135 dc5351b4 2019-07-30 stsp ret="$?"
136 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
137 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
138 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
139 dc5351b4 2019-07-30 stsp return 1
140 dc5351b4 2019-07-30 stsp fi
141 dc5351b4 2019-07-30 stsp done
142 dc5351b4 2019-07-30 stsp
143 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
144 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
145 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
146 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
147 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
148 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
149 dc5351b4 2019-07-30 stsp ret="$?"
150 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
151 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
152 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
153 dc5351b4 2019-07-30 stsp return 1
154 dc5351b4 2019-07-30 stsp fi
155 dc5351b4 2019-07-30 stsp
156 dc5351b4 2019-07-30 stsp got checkout $testroot/repo $testroot/wt >/dev/null
157 dc5351b4 2019-07-30 stsp ret="$?"
158 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
159 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
160 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
161 dc5351b4 2019-07-30 stsp return 1
162 dc5351b4 2019-07-30 stsp fi
163 dc5351b4 2019-07-30 stsp
164 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
165 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
166 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
167 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
168 dc5351b4 2019-07-30 stsp echo "* master: $commit_id" >> $testroot/stdout.expected
169 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
170 dc5351b4 2019-07-30 stsp ret="$?"
171 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
172 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
173 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
174 dc5351b4 2019-07-30 stsp return 1
175 dc5351b4 2019-07-30 stsp fi
176 dc5351b4 2019-07-30 stsp
177 dc5351b4 2019-07-30 stsp echo "modified delta" > $testroot/repo/gamma/delta
178 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta"
179 dc5351b4 2019-07-30 stsp local commit_id2=`git_show_head $testroot/repo`
180 dc5351b4 2019-07-30 stsp
181 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
182 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
183 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
184 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
185 dc5351b4 2019-07-30 stsp echo "~ master: $commit_id2" >> $testroot/stdout.expected
186 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
187 dc5351b4 2019-07-30 stsp ret="$?"
188 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
189 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
191 dc5351b4 2019-07-30 stsp return 1
192 dc5351b4 2019-07-30 stsp fi
193 dc5351b4 2019-07-30 stsp
194 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update > /dev/null)
195 dc5351b4 2019-07-30 stsp ret="$?"
196 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
197 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
198 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
199 dc5351b4 2019-07-30 stsp return 1
200 dc5351b4 2019-07-30 stsp fi
201 dc5351b4 2019-07-30 stsp
202 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
203 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
204 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
205 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
206 dc5351b4 2019-07-30 stsp echo "* master: $commit_id2" >> $testroot/stdout.expected
207 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
208 dc5351b4 2019-07-30 stsp ret="$?"
209 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
210 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
211 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
212 dc5351b4 2019-07-30 stsp return 1
213 dc5351b4 2019-07-30 stsp fi
214 dc5351b4 2019-07-30 stsp
215 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
216 dc5351b4 2019-07-30 stsp ret="$?"
217 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
218 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
219 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
220 dc5351b4 2019-07-30 stsp return 1
221 dc5351b4 2019-07-30 stsp fi
222 dc5351b4 2019-07-30 stsp
223 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
224 dc5351b4 2019-07-30 stsp echo "* branch1: $commit_id" > $testroot/stdout.expected
225 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
226 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
227 dc5351b4 2019-07-30 stsp echo " master: $commit_id2" >> $testroot/stdout.expected
228 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
229 dc5351b4 2019-07-30 stsp ret="$?"
230 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
231 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
232 dc5351b4 2019-07-30 stsp fi
233 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
234 dc5351b4 2019-07-30 stsp }
235 dc5351b4 2019-07-30 stsp
236 f6cae3ed 2020-09-13 naddy test_branch_delete() {
237 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_delete`
238 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
239 dc5351b4 2019-07-30 stsp
240 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
241 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
242 dc5351b4 2019-07-30 stsp ret="$?"
243 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
244 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
245 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
246 dc5351b4 2019-07-30 stsp return 1
247 dc5351b4 2019-07-30 stsp fi
248 dc5351b4 2019-07-30 stsp done
249 dc5351b4 2019-07-30 stsp
250 dc5351b4 2019-07-30 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
251 dc5351b4 2019-07-30 stsp ret="$?"
252 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
253 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
254 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
255 dc5351b4 2019-07-30 stsp return 1
256 dc5351b4 2019-07-30 stsp fi
257 dc5351b4 2019-07-30 stsp
258 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
259 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
260 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
261 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
262 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
263 6aeab596 2019-08-28 stsp ret="$?"
264 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
265 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
267 6aeab596 2019-08-28 stsp return 1
268 6aeab596 2019-08-28 stsp fi
269 6aeab596 2019-08-28 stsp
270 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
271 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
272 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
273 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
274 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
275 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
276 dc5351b4 2019-07-30 stsp ret="$?"
277 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
278 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
280 dc5351b4 2019-07-30 stsp return 1
281 dc5351b4 2019-07-30 stsp fi
282 dc5351b4 2019-07-30 stsp
283 dc5351b4 2019-07-30 stsp got branch -d bogus_branch_name -r $testroot/repo \
284 dc5351b4 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr
285 dc5351b4 2019-07-30 stsp ret="$?"
286 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
287 dc5351b4 2019-07-30 stsp echo "got update succeeded unexpectedly"
288 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
289 dc5351b4 2019-07-30 stsp return 1
290 dc5351b4 2019-07-30 stsp fi
291 dc5351b4 2019-07-30 stsp
292 dc5351b4 2019-07-30 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
293 dc5351b4 2019-07-30 stsp > $testroot/stderr.expected
294 dc5351b4 2019-07-30 stsp cmp -s $testroot/stderr $testroot/stderr.expected
295 dc5351b4 2019-07-30 stsp ret="$?"
296 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
297 dc5351b4 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
298 dc5351b4 2019-07-30 stsp fi
299 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
300 dc5351b4 2019-07-30 stsp }
301 dc5351b4 2019-07-30 stsp
302 f6cae3ed 2020-09-13 naddy test_branch_delete_current_branch() {
303 45cd4e47 2019-08-25 stsp local testroot=`test_init branch_delete_current_branch`
304 45cd4e47 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
305 45cd4e47 2019-08-25 stsp
306 45cd4e47 2019-08-25 stsp got checkout $testroot/repo $testroot/wt >/dev/null
307 45cd4e47 2019-08-25 stsp ret="$?"
308 45cd4e47 2019-08-25 stsp if [ "$ret" != "0" ]; then
309 45cd4e47 2019-08-25 stsp echo "got checkout command failed unexpectedly"
310 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
311 45cd4e47 2019-08-25 stsp return 1
312 45cd4e47 2019-08-25 stsp fi
313 dc5351b4 2019-07-30 stsp
314 45cd4e47 2019-08-25 stsp (cd $testroot/wt && got branch -d master > $testroot/stdout \
315 45cd4e47 2019-08-25 stsp 2> $testroot/stderr)
316 45cd4e47 2019-08-25 stsp
317 45cd4e47 2019-08-25 stsp echo "got: will not delete this work tree's current branch" \
318 6aeab596 2019-08-28 stsp > $testroot/stderr.expected
319 6aeab596 2019-08-28 stsp cmp -s $testroot/stderr $testroot/stderr.expected
320 6aeab596 2019-08-28 stsp ret="$?"
321 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
322 6aeab596 2019-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
323 6aeab596 2019-08-28 stsp fi
324 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
325 6aeab596 2019-08-28 stsp }
326 6aeab596 2019-08-28 stsp
327 f6cae3ed 2020-09-13 naddy test_branch_delete_packed() {
328 6aeab596 2019-08-28 stsp local testroot=`test_init branch_delete_packed`
329 6aeab596 2019-08-28 stsp local commit_id=`git_show_head $testroot/repo`
330 6aeab596 2019-08-28 stsp
331 6aeab596 2019-08-28 stsp for b in branch1 branch2 branch3; do
332 6aeab596 2019-08-28 stsp got branch -r $testroot/repo $b
333 6aeab596 2019-08-28 stsp ret="$?"
334 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
335 6aeab596 2019-08-28 stsp echo "got branch command failed unexpectedly"
336 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
337 6aeab596 2019-08-28 stsp return 1
338 6aeab596 2019-08-28 stsp fi
339 6aeab596 2019-08-28 stsp done
340 6aeab596 2019-08-28 stsp
341 6aeab596 2019-08-28 stsp (cd $testroot/repo && git pack-refs --all)
342 6aeab596 2019-08-28 stsp
343 6aeab596 2019-08-28 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
344 6aeab596 2019-08-28 stsp ret="$?"
345 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
346 6aeab596 2019-08-28 stsp echo "got update command failed unexpectedly"
347 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
348 6aeab596 2019-08-28 stsp return 1
349 6aeab596 2019-08-28 stsp fi
350 6aeab596 2019-08-28 stsp
351 6aeab596 2019-08-28 stsp got branch -l -r $testroot/repo > $testroot/stdout
352 6aeab596 2019-08-28 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
353 6aeab596 2019-08-28 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
354 6aeab596 2019-08-28 stsp echo " master: $commit_id" >> $testroot/stdout.expected
355 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
356 6aeab596 2019-08-28 stsp ret="$?"
357 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
358 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
359 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
360 6aeab596 2019-08-28 stsp return 1
361 6aeab596 2019-08-28 stsp fi
362 6aeab596 2019-08-28 stsp
363 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
364 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
365 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
366 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
367 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
368 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
369 6aeab596 2019-08-28 stsp ret="$?"
370 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
371 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
372 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
373 6aeab596 2019-08-28 stsp return 1
374 6aeab596 2019-08-28 stsp fi
375 6aeab596 2019-08-28 stsp
376 6aeab596 2019-08-28 stsp got branch -d bogus_branch_name -r $testroot/repo \
377 6aeab596 2019-08-28 stsp > $testroot/stdout 2> $testroot/stderr
378 6aeab596 2019-08-28 stsp ret="$?"
379 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
380 6aeab596 2019-08-28 stsp echo "got update succeeded unexpectedly"
381 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
382 6aeab596 2019-08-28 stsp return 1
383 6aeab596 2019-08-28 stsp fi
384 6aeab596 2019-08-28 stsp
385 6aeab596 2019-08-28 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
386 45cd4e47 2019-08-25 stsp > $testroot/stderr.expected
387 45cd4e47 2019-08-25 stsp cmp -s $testroot/stderr $testroot/stderr.expected
388 45cd4e47 2019-08-25 stsp ret="$?"
389 45cd4e47 2019-08-25 stsp if [ "$ret" != "0" ]; then
390 45cd4e47 2019-08-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
391 ad89fa31 2019-10-04 stsp fi
392 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
393 ad89fa31 2019-10-04 stsp }
394 ad89fa31 2019-10-04 stsp
395 f6cae3ed 2020-09-13 naddy test_branch_show() {
396 ad89fa31 2019-10-04 stsp local testroot=`test_init branch_show`
397 ad89fa31 2019-10-04 stsp local commit_id=`git_show_head $testroot/repo`
398 ad89fa31 2019-10-04 stsp
399 ad89fa31 2019-10-04 stsp for b in branch1 branch2 branch3; do
400 ad89fa31 2019-10-04 stsp got branch -r $testroot/repo $b
401 ad89fa31 2019-10-04 stsp ret="$?"
402 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
403 ad89fa31 2019-10-04 stsp echo "got branch command failed unexpectedly"
404 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
405 ad89fa31 2019-10-04 stsp return 1
406 ad89fa31 2019-10-04 stsp fi
407 ad89fa31 2019-10-04 stsp done
408 ad89fa31 2019-10-04 stsp
409 ad89fa31 2019-10-04 stsp got checkout $testroot/repo $testroot/wt >/dev/null
410 ad89fa31 2019-10-04 stsp ret="$?"
411 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
412 ad89fa31 2019-10-04 stsp echo "got checkout command failed unexpectedly"
413 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
414 ad89fa31 2019-10-04 stsp return 1
415 ad89fa31 2019-10-04 stsp fi
416 ad89fa31 2019-10-04 stsp
417 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
418 ad89fa31 2019-10-04 stsp echo "master" > $testroot/stdout.expected
419 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
420 ad89fa31 2019-10-04 stsp ret="$?"
421 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
422 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
423 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
424 ad89fa31 2019-10-04 stsp return 1
425 45cd4e47 2019-08-25 stsp fi
426 ad89fa31 2019-10-04 stsp
427 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
428 ad89fa31 2019-10-04 stsp ret="$?"
429 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
430 ad89fa31 2019-10-04 stsp echo "got update command failed unexpectedly"
431 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
432 ad89fa31 2019-10-04 stsp return 1
433 ad89fa31 2019-10-04 stsp fi
434 ad89fa31 2019-10-04 stsp
435 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
436 ad89fa31 2019-10-04 stsp echo "branch1" > $testroot/stdout.expected
437 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
438 ad89fa31 2019-10-04 stsp ret="$?"
439 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
440 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
441 ad89fa31 2019-10-04 stsp fi
442 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
443 ad89fa31 2019-10-04 stsp
444 45cd4e47 2019-08-25 stsp }
445 45cd4e47 2019-08-25 stsp
446 7fb414ae 2020-08-08 stsp test_parseargs "$@"
447 dc5351b4 2019-07-30 stsp run_test test_branch_create
448 dc5351b4 2019-07-30 stsp run_test test_branch_list
449 dc5351b4 2019-07-30 stsp run_test test_branch_delete
450 45cd4e47 2019-08-25 stsp run_test test_branch_delete_current_branch
451 6aeab596 2019-08-28 stsp run_test test_branch_delete_packed
452 ad89fa31 2019-10-04 stsp run_test test_branch_show