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 dc5351b4 2019-07-30 stsp function test_branch_create {
20 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_create`
21 dc5351b4 2019-07-30 stsp
22 dc5351b4 2019-07-30 stsp # Create a branch based on repository's HEAD reference
23 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo newbranch
24 dc5351b4 2019-07-30 stsp ret="$?"
25 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
26 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
27 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
28 dc5351b4 2019-07-30 stsp return 1
29 dc5351b4 2019-07-30 stsp fi
30 dc5351b4 2019-07-30 stsp
31 dc5351b4 2019-07-30 stsp # Ensure that Git recognizes the branch Got has created
32 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q newbranch)
33 dc5351b4 2019-07-30 stsp ret="$?"
34 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
35 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
36 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
37 dc5351b4 2019-07-30 stsp return 1
38 dc5351b4 2019-07-30 stsp fi
39 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
40 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
41 dc5351b4 2019-07-30 stsp
42 dc5351b4 2019-07-30 stsp got checkout -b newbranch $testroot/repo $testroot/wt >/dev/null
43 dc5351b4 2019-07-30 stsp ret="$?"
44 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
45 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
46 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
47 dc5351b4 2019-07-30 stsp return 1
48 dc5351b4 2019-07-30 stsp fi
49 dc5351b4 2019-07-30 stsp
50 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/content.expected
51 dc5351b4 2019-07-30 stsp cat $testroot/wt/gamma/delta > $testroot/content
52 dc5351b4 2019-07-30 stsp cmp -s $testroot/content.expected $testroot/content
53 dc5351b4 2019-07-30 stsp ret="$?"
54 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
55 dc5351b4 2019-07-30 stsp diff -u $testroot/content.expected $testroot/content
56 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
57 dc5351b4 2019-07-30 stsp return 1
58 dc5351b4 2019-07-30 stsp fi
59 dc5351b4 2019-07-30 stsp
60 dc5351b4 2019-07-30 stsp # Create a branch based on the work tree's branch
61 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch anotherbranch)
62 dc5351b4 2019-07-30 stsp ret="$?"
63 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
64 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
65 dc5351b4 2019-07-30 stsp return 1
66 dc5351b4 2019-07-30 stsp fi
67 dc5351b4 2019-07-30 stsp
68 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q anotherbranch)
69 dc5351b4 2019-07-30 stsp ret="$?"
70 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
71 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
72 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
73 dc5351b4 2019-07-30 stsp return 1
74 dc5351b4 2019-07-30 stsp fi
75 dc5351b4 2019-07-30 stsp
76 dc5351b4 2019-07-30 stsp # Create a branch based on another specific branch
77 a74f7e83 2019-11-10 stsp (cd $testroot/wt && got branch -c master yetanotherbranch)
78 dc5351b4 2019-07-30 stsp ret="$?"
79 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
80 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
81 dc5351b4 2019-07-30 stsp return 1
82 dc5351b4 2019-07-30 stsp fi
83 dc5351b4 2019-07-30 stsp
84 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q yetanotherbranch)
85 a4f89d48 2019-08-25 stsp ret="$?"
86 a4f89d48 2019-08-25 stsp if [ "$ret" != "0" ]; then
87 a4f89d48 2019-08-25 stsp echo "git checkout command failed unexpectedly"
88 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
89 a4f89d48 2019-08-25 stsp return 1
90 a4f89d48 2019-08-25 stsp fi
91 a4f89d48 2019-08-25 stsp
92 a4f89d48 2019-08-25 stsp # Create a branch based on a specific commit
93 a4f89d48 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
94 a74f7e83 2019-11-10 stsp got branch -r $testroot/repo -c $commit_id commitbranch
95 dc5351b4 2019-07-30 stsp ret="$?"
96 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
97 a4f89d48 2019-08-25 stsp echo "got branch command failed unexpectedly"
98 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
99 a4f89d48 2019-08-25 stsp return 1
100 a4f89d48 2019-08-25 stsp fi
101 a4f89d48 2019-08-25 stsp
102 a4f89d48 2019-08-25 stsp (cd $testroot/repo && git checkout -q commitbranch)
103 a4f89d48 2019-08-25 stsp ret="$?"
104 a4f89d48 2019-08-25 stsp if [ "$ret" != "0" ]; then
105 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
106 dc5351b4 2019-07-30 stsp fi
107 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
108 dc5351b4 2019-07-30 stsp }
109 dc5351b4 2019-07-30 stsp
110 dc5351b4 2019-07-30 stsp function test_branch_list {
111 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_list`
112 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
113 dc5351b4 2019-07-30 stsp
114 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
115 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
116 dc5351b4 2019-07-30 stsp ret="$?"
117 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
118 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
119 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
120 dc5351b4 2019-07-30 stsp return 1
121 dc5351b4 2019-07-30 stsp fi
122 dc5351b4 2019-07-30 stsp done
123 dc5351b4 2019-07-30 stsp
124 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
125 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
126 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
127 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
128 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
129 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
130 dc5351b4 2019-07-30 stsp ret="$?"
131 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
132 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
133 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
134 dc5351b4 2019-07-30 stsp return 1
135 dc5351b4 2019-07-30 stsp fi
136 dc5351b4 2019-07-30 stsp
137 dc5351b4 2019-07-30 stsp got checkout $testroot/repo $testroot/wt >/dev/null
138 dc5351b4 2019-07-30 stsp ret="$?"
139 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
140 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
141 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
142 dc5351b4 2019-07-30 stsp return 1
143 dc5351b4 2019-07-30 stsp fi
144 dc5351b4 2019-07-30 stsp
145 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
146 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
147 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
148 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
149 dc5351b4 2019-07-30 stsp echo "* master: $commit_id" >> $testroot/stdout.expected
150 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
151 dc5351b4 2019-07-30 stsp ret="$?"
152 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
153 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
154 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
155 dc5351b4 2019-07-30 stsp return 1
156 dc5351b4 2019-07-30 stsp fi
157 dc5351b4 2019-07-30 stsp
158 dc5351b4 2019-07-30 stsp echo "modified delta" > $testroot/repo/gamma/delta
159 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta"
160 dc5351b4 2019-07-30 stsp local commit_id2=`git_show_head $testroot/repo`
161 dc5351b4 2019-07-30 stsp
162 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
163 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
164 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
165 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
166 dc5351b4 2019-07-30 stsp echo "~ master: $commit_id2" >> $testroot/stdout.expected
167 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
168 dc5351b4 2019-07-30 stsp ret="$?"
169 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
170 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
171 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
172 dc5351b4 2019-07-30 stsp return 1
173 dc5351b4 2019-07-30 stsp fi
174 dc5351b4 2019-07-30 stsp
175 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update > /dev/null)
176 dc5351b4 2019-07-30 stsp ret="$?"
177 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
178 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
179 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
180 dc5351b4 2019-07-30 stsp return 1
181 dc5351b4 2019-07-30 stsp fi
182 dc5351b4 2019-07-30 stsp
183 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
184 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
185 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
186 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
187 dc5351b4 2019-07-30 stsp echo "* master: $commit_id2" >> $testroot/stdout.expected
188 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
189 dc5351b4 2019-07-30 stsp ret="$?"
190 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
191 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
192 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
193 dc5351b4 2019-07-30 stsp return 1
194 dc5351b4 2019-07-30 stsp fi
195 dc5351b4 2019-07-30 stsp
196 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
197 dc5351b4 2019-07-30 stsp ret="$?"
198 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
199 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
200 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
201 dc5351b4 2019-07-30 stsp return 1
202 dc5351b4 2019-07-30 stsp fi
203 dc5351b4 2019-07-30 stsp
204 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
205 dc5351b4 2019-07-30 stsp echo "* branch1: $commit_id" > $testroot/stdout.expected
206 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
207 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
208 dc5351b4 2019-07-30 stsp echo " master: $commit_id2" >> $testroot/stdout.expected
209 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
210 dc5351b4 2019-07-30 stsp ret="$?"
211 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
212 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
213 dc5351b4 2019-07-30 stsp fi
214 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
215 dc5351b4 2019-07-30 stsp }
216 dc5351b4 2019-07-30 stsp
217 dc5351b4 2019-07-30 stsp function test_branch_delete {
218 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_delete`
219 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
220 dc5351b4 2019-07-30 stsp
221 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
222 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
223 dc5351b4 2019-07-30 stsp ret="$?"
224 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
225 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
226 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
227 dc5351b4 2019-07-30 stsp return 1
228 dc5351b4 2019-07-30 stsp fi
229 dc5351b4 2019-07-30 stsp done
230 dc5351b4 2019-07-30 stsp
231 dc5351b4 2019-07-30 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
232 dc5351b4 2019-07-30 stsp ret="$?"
233 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
234 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
235 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
236 dc5351b4 2019-07-30 stsp return 1
237 dc5351b4 2019-07-30 stsp fi
238 dc5351b4 2019-07-30 stsp
239 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
240 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
241 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
242 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
243 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
244 6aeab596 2019-08-28 stsp ret="$?"
245 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
246 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
247 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
248 6aeab596 2019-08-28 stsp return 1
249 6aeab596 2019-08-28 stsp fi
250 6aeab596 2019-08-28 stsp
251 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
252 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
253 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
254 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
255 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
256 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
257 dc5351b4 2019-07-30 stsp ret="$?"
258 dc5351b4 2019-07-30 stsp if [ "$ret" != "0" ]; then
259 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
260 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
261 dc5351b4 2019-07-30 stsp return 1
262 dc5351b4 2019-07-30 stsp fi
263 dc5351b4 2019-07-30 stsp
264 dc5351b4 2019-07-30 stsp got branch -d bogus_branch_name -r $testroot/repo \
265 dc5351b4 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr
266 dc5351b4 2019-07-30 stsp ret="$?"
267 dc5351b4 2019-07-30 stsp if [ "$ret" == "0" ]; then
268 dc5351b4 2019-07-30 stsp echo "got update succeeded unexpectedly"
269 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
270 dc5351b4 2019-07-30 stsp return 1
271 dc5351b4 2019-07-30 stsp fi
272 dc5351b4 2019-07-30 stsp
273 dc5351b4 2019-07-30 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
274 dc5351b4 2019-07-30 stsp > $testroot/stderr.expected
275 dc5351b4 2019-07-30 stsp cmp -s $testroot/stderr $testroot/stderr.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/stderr.expected $testroot/stderr
279 dc5351b4 2019-07-30 stsp fi
280 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
281 dc5351b4 2019-07-30 stsp }
282 dc5351b4 2019-07-30 stsp
283 45cd4e47 2019-08-25 stsp function test_branch_delete_current_branch {
284 45cd4e47 2019-08-25 stsp local testroot=`test_init branch_delete_current_branch`
285 45cd4e47 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
286 45cd4e47 2019-08-25 stsp
287 45cd4e47 2019-08-25 stsp got checkout $testroot/repo $testroot/wt >/dev/null
288 45cd4e47 2019-08-25 stsp ret="$?"
289 45cd4e47 2019-08-25 stsp if [ "$ret" != "0" ]; then
290 45cd4e47 2019-08-25 stsp echo "got checkout command failed unexpectedly"
291 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
292 45cd4e47 2019-08-25 stsp return 1
293 45cd4e47 2019-08-25 stsp fi
294 dc5351b4 2019-07-30 stsp
295 45cd4e47 2019-08-25 stsp (cd $testroot/wt && got branch -d master > $testroot/stdout \
296 45cd4e47 2019-08-25 stsp 2> $testroot/stderr)
297 45cd4e47 2019-08-25 stsp
298 45cd4e47 2019-08-25 stsp echo "got: will not delete this work tree's current branch" \
299 6aeab596 2019-08-28 stsp > $testroot/stderr.expected
300 6aeab596 2019-08-28 stsp cmp -s $testroot/stderr $testroot/stderr.expected
301 6aeab596 2019-08-28 stsp ret="$?"
302 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
303 6aeab596 2019-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
304 6aeab596 2019-08-28 stsp fi
305 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
306 6aeab596 2019-08-28 stsp }
307 6aeab596 2019-08-28 stsp
308 6aeab596 2019-08-28 stsp function test_branch_delete_packed {
309 6aeab596 2019-08-28 stsp local testroot=`test_init branch_delete_packed`
310 6aeab596 2019-08-28 stsp local commit_id=`git_show_head $testroot/repo`
311 6aeab596 2019-08-28 stsp
312 6aeab596 2019-08-28 stsp for b in branch1 branch2 branch3; do
313 6aeab596 2019-08-28 stsp got branch -r $testroot/repo $b
314 6aeab596 2019-08-28 stsp ret="$?"
315 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
316 6aeab596 2019-08-28 stsp echo "got branch command failed unexpectedly"
317 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
318 6aeab596 2019-08-28 stsp return 1
319 6aeab596 2019-08-28 stsp fi
320 6aeab596 2019-08-28 stsp done
321 6aeab596 2019-08-28 stsp
322 6aeab596 2019-08-28 stsp (cd $testroot/repo && git pack-refs --all)
323 6aeab596 2019-08-28 stsp
324 6aeab596 2019-08-28 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
325 6aeab596 2019-08-28 stsp ret="$?"
326 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
327 6aeab596 2019-08-28 stsp echo "got update command failed unexpectedly"
328 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
329 6aeab596 2019-08-28 stsp return 1
330 6aeab596 2019-08-28 stsp fi
331 6aeab596 2019-08-28 stsp
332 6aeab596 2019-08-28 stsp got branch -l -r $testroot/repo > $testroot/stdout
333 6aeab596 2019-08-28 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
334 6aeab596 2019-08-28 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
335 6aeab596 2019-08-28 stsp echo " master: $commit_id" >> $testroot/stdout.expected
336 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
337 6aeab596 2019-08-28 stsp ret="$?"
338 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
339 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
341 6aeab596 2019-08-28 stsp return 1
342 6aeab596 2019-08-28 stsp fi
343 6aeab596 2019-08-28 stsp
344 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
345 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
346 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
347 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
348 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
349 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
350 6aeab596 2019-08-28 stsp ret="$?"
351 6aeab596 2019-08-28 stsp if [ "$ret" != "0" ]; then
352 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
353 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
354 6aeab596 2019-08-28 stsp return 1
355 6aeab596 2019-08-28 stsp fi
356 6aeab596 2019-08-28 stsp
357 6aeab596 2019-08-28 stsp got branch -d bogus_branch_name -r $testroot/repo \
358 6aeab596 2019-08-28 stsp > $testroot/stdout 2> $testroot/stderr
359 6aeab596 2019-08-28 stsp ret="$?"
360 6aeab596 2019-08-28 stsp if [ "$ret" == "0" ]; then
361 6aeab596 2019-08-28 stsp echo "got update succeeded unexpectedly"
362 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
363 6aeab596 2019-08-28 stsp return 1
364 6aeab596 2019-08-28 stsp fi
365 6aeab596 2019-08-28 stsp
366 6aeab596 2019-08-28 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
367 45cd4e47 2019-08-25 stsp > $testroot/stderr.expected
368 45cd4e47 2019-08-25 stsp cmp -s $testroot/stderr $testroot/stderr.expected
369 45cd4e47 2019-08-25 stsp ret="$?"
370 45cd4e47 2019-08-25 stsp if [ "$ret" != "0" ]; then
371 45cd4e47 2019-08-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
372 ad89fa31 2019-10-04 stsp fi
373 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
374 ad89fa31 2019-10-04 stsp }
375 ad89fa31 2019-10-04 stsp
376 ad89fa31 2019-10-04 stsp function test_branch_show {
377 ad89fa31 2019-10-04 stsp local testroot=`test_init branch_show`
378 ad89fa31 2019-10-04 stsp local commit_id=`git_show_head $testroot/repo`
379 ad89fa31 2019-10-04 stsp
380 ad89fa31 2019-10-04 stsp for b in branch1 branch2 branch3; do
381 ad89fa31 2019-10-04 stsp got branch -r $testroot/repo $b
382 ad89fa31 2019-10-04 stsp ret="$?"
383 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
384 ad89fa31 2019-10-04 stsp echo "got branch command failed unexpectedly"
385 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
386 ad89fa31 2019-10-04 stsp return 1
387 ad89fa31 2019-10-04 stsp fi
388 ad89fa31 2019-10-04 stsp done
389 ad89fa31 2019-10-04 stsp
390 ad89fa31 2019-10-04 stsp got checkout $testroot/repo $testroot/wt >/dev/null
391 ad89fa31 2019-10-04 stsp ret="$?"
392 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
393 ad89fa31 2019-10-04 stsp echo "got checkout command failed unexpectedly"
394 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
395 ad89fa31 2019-10-04 stsp return 1
396 ad89fa31 2019-10-04 stsp fi
397 ad89fa31 2019-10-04 stsp
398 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
399 ad89fa31 2019-10-04 stsp echo "master" > $testroot/stdout.expected
400 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
401 ad89fa31 2019-10-04 stsp ret="$?"
402 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
403 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
405 ad89fa31 2019-10-04 stsp return 1
406 45cd4e47 2019-08-25 stsp fi
407 ad89fa31 2019-10-04 stsp
408 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
409 ad89fa31 2019-10-04 stsp ret="$?"
410 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
411 ad89fa31 2019-10-04 stsp echo "got update command failed unexpectedly"
412 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
413 ad89fa31 2019-10-04 stsp return 1
414 ad89fa31 2019-10-04 stsp fi
415 ad89fa31 2019-10-04 stsp
416 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
417 ad89fa31 2019-10-04 stsp echo "branch1" > $testroot/stdout.expected
418 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
419 ad89fa31 2019-10-04 stsp ret="$?"
420 ad89fa31 2019-10-04 stsp if [ "$ret" != "0" ]; then
421 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
422 ad89fa31 2019-10-04 stsp fi
423 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
424 ad89fa31 2019-10-04 stsp
425 45cd4e47 2019-08-25 stsp }
426 45cd4e47 2019-08-25 stsp
427 dc5351b4 2019-07-30 stsp run_test test_branch_create
428 dc5351b4 2019-07-30 stsp run_test test_branch_list
429 dc5351b4 2019-07-30 stsp run_test test_branch_delete
430 45cd4e47 2019-08-25 stsp run_test test_branch_delete_current_branch
431 6aeab596 2019-08-28 stsp run_test test_branch_delete_packed
432 ad89fa31 2019-10-04 stsp run_test test_branch_show