3 dc5351b4 2019-07-30 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 dc5351b4 2019-07-30 stsp . ./common.sh
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`
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
26 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
27 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
28 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
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)
35 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
36 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
37 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
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"
43 dc5351b4 2019-07-30 stsp got checkout -b newbranch $testroot/repo $testroot/wt >/dev/null
45 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
46 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
47 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
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
55 49c543a6 2022-03-31 naddy if [ $ret -ne 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"
61 dc5351b4 2019-07-30 stsp # Create a branch based on the work tree's branch
62 2f1457c6 2021-08-27 stsp (cd $testroot/wt && got branch -n refs/heads/anotherbranch)
64 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
65 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
69 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q anotherbranch)
71 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
72 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
73 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
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)
80 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
81 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
85 dc5351b4 2019-07-30 stsp (cd $testroot/repo && git checkout -q yetanotherbranch)
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
89 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
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
97 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
98 a4f89d48 2019-08-25 stsp echo "got branch command failed unexpectedly"
99 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
103 a4f89d48 2019-08-25 stsp (cd $testroot/repo && git checkout -q commitbranch)
105 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
106 a4f89d48 2019-08-25 stsp echo "git checkout command failed unexpectedly"
107 da76fce2 2020-02-24 stsp test_done "$testroot" "$ret"
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)
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 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/updatebranch: $commit_id0" \
120 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
122 da76fce2 2020-02-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
124 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
125 da76fce2 2020-02-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
130 f6cae3ed 2020-09-13 naddy test_branch_list() {
131 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_list`
132 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
134 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
135 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
137 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
138 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
139 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
144 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
145 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
146 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
147 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
148 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
149 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
151 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
152 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
157 dc5351b4 2019-07-30 stsp got checkout $testroot/repo $testroot/wt >/dev/null
159 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
160 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
161 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
165 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
166 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
167 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
168 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
169 dc5351b4 2019-07-30 stsp echo "* master: $commit_id" >> $testroot/stdout.expected
170 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
172 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
173 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
174 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
178 dc5351b4 2019-07-30 stsp echo "modified delta" > $testroot/repo/gamma/delta
179 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta"
180 dc5351b4 2019-07-30 stsp local commit_id2=`git_show_head $testroot/repo`
182 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
183 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
184 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
185 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
186 dc5351b4 2019-07-30 stsp echo "~ master: $commit_id2" >> $testroot/stdout.expected
187 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
191 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
195 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update > /dev/null)
197 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
198 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
199 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
203 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
204 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
205 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
206 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
207 dc5351b4 2019-07-30 stsp echo "* master: $commit_id2" >> $testroot/stdout.expected
208 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
211 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
216 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
219 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
220 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
224 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
225 dc5351b4 2019-07-30 stsp echo "* branch1: $commit_id" > $testroot/stdout.expected
226 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
227 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
228 dc5351b4 2019-07-30 stsp echo " master: $commit_id2" >> $testroot/stdout.expected
229 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
231 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
232 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
234 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
237 f6cae3ed 2020-09-13 naddy test_branch_delete() {
238 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_delete`
239 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
241 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
242 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
244 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
245 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
246 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
251 dc5351b4 2019-07-30 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
253 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
254 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
255 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
259 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
260 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
261 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
262 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
263 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
265 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
266 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
267 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
271 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
272 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
273 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
274 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
275 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
276 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
278 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
279 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
280 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
284 dc5351b4 2019-07-30 stsp got branch -d bogus_branch_name -r $testroot/repo \
285 dc5351b4 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr
287 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
288 2f1457c6 2021-08-27 stsp echo "got branch succeeded unexpectedly"
289 a19f439c 2022-06-03 op test_done "$testroot" "1"
293 dc5351b4 2019-07-30 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
294 dc5351b4 2019-07-30 stsp > $testroot/stderr.expected
295 dc5351b4 2019-07-30 stsp cmp -s $testroot/stderr $testroot/stderr.expected
297 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
298 dc5351b4 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
299 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
303 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
304 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c branch1 refs/remotes/origin/branch1
305 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c branch3 refs/remotes/origin/branch3
307 2f1457c6 2021-08-27 stsp got ref -l -r $testroot/repo > $testroot/stdout
308 2f1457c6 2021-08-27 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
309 2f1457c6 2021-08-27 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
310 2f1457c6 2021-08-27 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
311 2f1457c6 2021-08-27 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
312 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/branch1: $commit_id" \
313 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
314 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/branch3: $commit_id" \
315 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
316 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/master: $commit_id" \
317 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
318 2f1457c6 2021-08-27 stsp cmp -s $testroot/stdout $testroot/stdout.expected
320 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
321 2f1457c6 2021-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
322 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
326 2f1457c6 2021-08-27 stsp got branch -d origin/branch1 -r $testroot/repo > $testroot/stdout
328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
329 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
330 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
334 2f1457c6 2021-08-27 stsp got branch -d refs/remotes/origin/branch3 -r $testroot/repo \
335 2f1457c6 2021-08-27 stsp > $testroot/stdout
337 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
338 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
339 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
343 2f1457c6 2021-08-27 stsp got ref -l -r $testroot/repo > $testroot/stdout
344 2f1457c6 2021-08-27 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
345 2f1457c6 2021-08-27 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
346 2f1457c6 2021-08-27 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
347 2f1457c6 2021-08-27 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
348 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/master: $commit_id" \
349 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
350 2f1457c6 2021-08-27 stsp cmp -s $testroot/stdout $testroot/stdout.expected
352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
353 2f1457c6 2021-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
355 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
358 f6cae3ed 2020-09-13 naddy test_branch_delete_current_branch() {
359 45cd4e47 2019-08-25 stsp local testroot=`test_init branch_delete_current_branch`
360 45cd4e47 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
362 45cd4e47 2019-08-25 stsp got checkout $testroot/repo $testroot/wt >/dev/null
364 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
365 45cd4e47 2019-08-25 stsp echo "got checkout command failed unexpectedly"
366 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
370 45cd4e47 2019-08-25 stsp (cd $testroot/wt && got branch -d master > $testroot/stdout \
371 45cd4e47 2019-08-25 stsp 2> $testroot/stderr)
373 45cd4e47 2019-08-25 stsp echo "got: will not delete this work tree's current branch" \
374 45cd4e47 2019-08-25 stsp > $testroot/stderr.expected
375 45cd4e47 2019-08-25 stsp cmp -s $testroot/stderr $testroot/stderr.expected
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 45cd4e47 2019-08-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
380 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
383 f6cae3ed 2020-09-13 naddy test_branch_delete_packed() {
384 6aeab596 2019-08-28 stsp local testroot=`test_init branch_delete_packed`
385 6aeab596 2019-08-28 stsp local commit_id=`git_show_head $testroot/repo`
387 6aeab596 2019-08-28 stsp for b in branch1 branch2 branch3; do
388 6aeab596 2019-08-28 stsp got branch -r $testroot/repo $b
390 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
391 6aeab596 2019-08-28 stsp echo "got branch command failed unexpectedly"
392 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
397 6aeab596 2019-08-28 stsp (cd $testroot/repo && git pack-refs --all)
399 2f1457c6 2021-08-27 stsp got branch -d refs/heads/branch2 -r $testroot/repo > $testroot/stdout
401 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
402 6aeab596 2019-08-28 stsp echo "got update command failed unexpectedly"
403 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
407 6aeab596 2019-08-28 stsp got branch -l -r $testroot/repo > $testroot/stdout
408 6aeab596 2019-08-28 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
409 6aeab596 2019-08-28 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
410 6aeab596 2019-08-28 stsp echo " master: $commit_id" >> $testroot/stdout.expected
411 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
414 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
415 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
419 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
420 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
421 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
422 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
423 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
424 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
426 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
427 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
432 6aeab596 2019-08-28 stsp got branch -d bogus_branch_name -r $testroot/repo \
433 6aeab596 2019-08-28 stsp > $testroot/stdout 2> $testroot/stderr
435 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
436 6aeab596 2019-08-28 stsp echo "got update succeeded unexpectedly"
437 a19f439c 2022-06-03 op test_done "$testroot" "1"
441 6aeab596 2019-08-28 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
442 6aeab596 2019-08-28 stsp > $testroot/stderr.expected
443 6aeab596 2019-08-28 stsp cmp -s $testroot/stderr $testroot/stderr.expected
445 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
446 6aeab596 2019-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
448 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
451 f6cae3ed 2020-09-13 naddy test_branch_show() {
452 ad89fa31 2019-10-04 stsp local testroot=`test_init branch_show`
453 ad89fa31 2019-10-04 stsp local commit_id=`git_show_head $testroot/repo`
455 ad89fa31 2019-10-04 stsp for b in branch1 branch2 branch3; do
456 ad89fa31 2019-10-04 stsp got branch -r $testroot/repo $b
458 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
459 ad89fa31 2019-10-04 stsp echo "got branch command failed unexpectedly"
460 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
465 ad89fa31 2019-10-04 stsp got checkout $testroot/repo $testroot/wt >/dev/null
467 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
468 ad89fa31 2019-10-04 stsp echo "got checkout command failed unexpectedly"
469 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
473 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
474 ad89fa31 2019-10-04 stsp echo "master" > $testroot/stdout.expected
475 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
477 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
478 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
479 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
483 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
485 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
486 ad89fa31 2019-10-04 stsp echo "got update command failed unexpectedly"
487 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
491 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
492 ad89fa31 2019-10-04 stsp echo "branch1" > $testroot/stdout.expected
493 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
496 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
502 7db2b0dd 2022-09-05 stsp test_branch_packed_ref_collision() {
503 7db2b0dd 2022-09-05 stsp local testroot=`test_init branch_packed_ref_collision`
504 7db2b0dd 2022-09-05 stsp local commit_id=`git_show_head $testroot/repo`
506 7db2b0dd 2022-09-05 stsp got br -r $testroot/repo zoo > $testroot/stdout
507 7db2b0dd 2022-09-05 stsp got co -b zoo $testroot/repo $testroot/wt > /dev/null
508 7db2b0dd 2022-09-05 stsp echo "modified alpha" > $testroot/wt/alpha
510 7db2b0dd 2022-09-05 stsp # sleep in order to ensure that a significant fraction of time
511 7db2b0dd 2022-09-05 stsp # passes between commits; required for got branch -t option below
514 7db2b0dd 2022-09-05 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
515 7db2b0dd 2022-09-05 stsp local commit_id2=`git_show_branch_head $testroot/repo zoo`
517 7db2b0dd 2022-09-05 stsp # Fabricate a packed reference which points to an older commit
518 7db2b0dd 2022-09-05 stsp # and collides with the existing on-disk reference
519 7db2b0dd 2022-09-05 stsp echo '# pack-refs with: peeled fully-peeled sorted' > \
520 7db2b0dd 2022-09-05 stsp $testroot/repo/.git/packed-refs
521 7db2b0dd 2022-09-05 stsp echo "$commit_id refs/heads/zoo" >> $testroot/repo/.git/packed-refs
523 7db2b0dd 2022-09-05 stsp # Bug: This command used to show both packed and on-disk
524 7db2b0dd 2022-09-05 stsp # variants of ref/heads/zoo:
525 7db2b0dd 2022-09-05 stsp (cd $testroot/wt && got br -lt > $testroot/stdout)
527 7db2b0dd 2022-09-05 stsp echo "* zoo: $commit_id2" > $testroot/stdout.expected
528 7db2b0dd 2022-09-05 stsp echo " master: $commit_id" >> $testroot/stdout.expected
529 7db2b0dd 2022-09-05 stsp cmp -s $testroot/stdout $testroot/stdout.expected
531 7db2b0dd 2022-09-05 stsp if [ $ret -ne 0 ]; then
532 7db2b0dd 2022-09-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
533 7db2b0dd 2022-09-05 stsp test_done "$testroot" "$ret"
537 7db2b0dd 2022-09-05 stsp test_done "$testroot" "$ret"
540 7fb414ae 2020-08-08 stsp test_parseargs "$@"
541 dc5351b4 2019-07-30 stsp run_test test_branch_create
542 dc5351b4 2019-07-30 stsp run_test test_branch_list
543 dc5351b4 2019-07-30 stsp run_test test_branch_delete
544 45cd4e47 2019-08-25 stsp run_test test_branch_delete_current_branch
545 6aeab596 2019-08-28 stsp run_test test_branch_delete_packed
546 ad89fa31 2019-10-04 stsp run_test test_branch_show
547 7db2b0dd 2022-09-05 stsp run_test test_branch_packed_ref_collision