3 05118f5a 2021-06-22 stsp # Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
5 05118f5a 2021-06-22 stsp # Permission to use, copy, modify, and distribute this software for any
6 05118f5a 2021-06-22 stsp # purpose with or without fee is hereby granted, provided that the above
7 05118f5a 2021-06-22 stsp # copyright notice and this permission notice appear in all copies.
9 05118f5a 2021-06-22 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 05118f5a 2021-06-22 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 05118f5a 2021-06-22 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 05118f5a 2021-06-22 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 05118f5a 2021-06-22 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 05118f5a 2021-06-22 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 05118f5a 2021-06-22 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 05118f5a 2021-06-22 stsp . ./common.sh
19 05118f5a 2021-06-22 stsp # disable automatic packing for these tests
20 05118f5a 2021-06-22 stsp export GOT_TEST_PACK=""
22 05118f5a 2021-06-22 stsp test_pack_all_loose_objects() {
23 05118f5a 2021-06-22 stsp local testroot=`test_init pack_all_loose_objects`
25 05118f5a 2021-06-22 stsp # tags should also be packed
26 05118f5a 2021-06-22 stsp got tag -r $testroot/repo -m 1.0 1.0 >/dev/null
28 05118f5a 2021-06-22 stsp # no pack files should exist yet
29 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
31 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
32 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
35 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
36 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
38 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
39 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
40 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
44 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo > $testroot/stdout
46 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
47 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
48 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
51 05118f5a 2021-06-22 stsp packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
52 05118f5a 2021-06-22 stsp gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
53 05118f5a 2021-06-22 stsp > $testroot/stdout
55 05118f5a 2021-06-22 stsp for d in $testroot/repo/.git/objects/[0-9a-f][0-9a-f]; do
56 05118f5a 2021-06-22 stsp id0=`basename $d`
58 05118f5a 2021-06-22 stsp for e in `ls $d`; do
59 05118f5a 2021-06-22 stsp obj_id=${id0}${e}
60 05118f5a 2021-06-22 stsp if grep -q ^$obj_id $testroot/stdout; then
63 05118f5a 2021-06-22 stsp echo "loose object $obj_id was not packed" >&2
67 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
72 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
75 05118f5a 2021-06-22 stsp test_pack_exclude() {
76 05118f5a 2021-06-22 stsp local testroot=`test_init pack_exclude`
77 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
79 05118f5a 2021-06-22 stsp # no pack files should exist yet
80 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
82 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
83 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
86 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
87 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
89 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
90 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
91 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
95 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
97 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
98 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
102 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
104 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
105 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
109 05118f5a 2021-06-22 stsp echo a new line >> $testroot/wt/alpha
110 05118f5a 2021-06-22 stsp (cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
112 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo -x master > $testroot/stdout
114 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
115 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
116 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
119 05118f5a 2021-06-22 stsp packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
120 05118f5a 2021-06-22 stsp gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
121 05118f5a 2021-06-22 stsp > $testroot/stdout
123 05118f5a 2021-06-22 stsp tree0=`got cat -r $testroot/repo $commit0 | grep ^tree | \
124 05118f5a 2021-06-22 stsp cut -d ' ' -f2`
125 05118f5a 2021-06-22 stsp excluded_ids=`got tree -r $testroot/repo -c $commit0 -R -i | \
126 05118f5a 2021-06-22 stsp cut -d ' ' -f 1`
127 05118f5a 2021-06-22 stsp excluded_ids="$excluded_ids $commit0 $tree0"
128 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
130 05118f5a 2021-06-22 stsp if grep -q ^$id $testroot/stdout; then
131 05118f5a 2021-06-22 stsp echo "found excluded object $id in pack file" >&2
134 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
138 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
139 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
143 05118f5a 2021-06-22 stsp for d in $testroot/repo/.git/objects/[0-9a-f][0-9a-f]; do
144 05118f5a 2021-06-22 stsp id0=`basename $d`
146 05118f5a 2021-06-22 stsp for e in `ls $d`; do
147 05118f5a 2021-06-22 stsp obj_id=${id0}${e}
149 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
150 8775a682 2021-07-03 naddy if [ "$obj_id" = "$id" ]; then
155 8775a682 2021-07-03 naddy if [ "$excluded" = "1" ]; then
158 05118f5a 2021-06-22 stsp if grep -q ^$obj_id $testroot/stdout; then
161 05118f5a 2021-06-22 stsp echo "loose object $obj_id was not packed" >&2
165 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
170 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
173 05118f5a 2021-06-22 stsp test_pack_include() {
174 05118f5a 2021-06-22 stsp local testroot=`test_init pack_include`
175 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
177 05118f5a 2021-06-22 stsp # no pack files should exist yet
178 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
180 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
181 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
184 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
185 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
188 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
193 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
195 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
196 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
200 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
202 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
203 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
207 05118f5a 2021-06-22 stsp echo a new line >> $testroot/wt/alpha
208 05118f5a 2021-06-22 stsp (cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
209 05118f5a 2021-06-22 stsp local commit1=`git_show_branch_head $testroot/repo mybranch`
211 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo master > $testroot/stdout
213 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
214 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
215 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
218 05118f5a 2021-06-22 stsp packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
219 05118f5a 2021-06-22 stsp gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
220 05118f5a 2021-06-22 stsp > $testroot/stdout
222 05118f5a 2021-06-22 stsp tree1=`got cat -r $testroot/repo $commit1 | grep ^tree | \
223 05118f5a 2021-06-22 stsp cut -d ' ' -f2`
224 05118f5a 2021-06-22 stsp alpha1=`got tree -r $testroot/repo -i -c $commit1 | \
225 05118f5a 2021-06-22 stsp grep "[0-9a-f] alpha$" | cut -d' ' -f 1`
226 05118f5a 2021-06-22 stsp excluded_ids="$alpha1 $commit1 $tree1"
227 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
229 05118f5a 2021-06-22 stsp if grep -q ^$id $testroot/stdout; then
230 05118f5a 2021-06-22 stsp echo "found excluded object $id in pack file" >&2
233 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
237 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
238 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
242 05118f5a 2021-06-22 stsp tree0=`got cat -r $testroot/repo $commit0 | grep ^tree | \
243 05118f5a 2021-06-22 stsp cut -d ' ' -f2`
244 05118f5a 2021-06-22 stsp included_ids=`got tree -r $testroot/repo -c $commit0 -R -i | \
245 05118f5a 2021-06-22 stsp cut -d ' ' -f 1`
246 05118f5a 2021-06-22 stsp included_ids="$included_ids $commit0 $tree0"
247 05118f5a 2021-06-22 stsp for obj_id in $included_ids; do
248 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
249 8775a682 2021-07-03 naddy if [ "$obj_id" = "$id" ]; then
254 8775a682 2021-07-03 naddy if [ "$excluded" = "1" ]; then
257 05118f5a 2021-06-22 stsp if grep -q ^$obj_id $testroot/stdout; then
260 05118f5a 2021-06-22 stsp echo "included object $obj_id was not packed" >&2
265 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
268 05118f5a 2021-06-22 stsp test_pack_ambiguous_arg() {
269 05118f5a 2021-06-22 stsp local testroot=`test_init pack_ambiguous_arg`
270 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
272 05118f5a 2021-06-22 stsp # no pack files should exist yet
273 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
275 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
276 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
279 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
280 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
282 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
283 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
284 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
288 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
290 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
291 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
295 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
297 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
298 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
302 05118f5a 2021-06-22 stsp echo a new line >> $testroot/wt/alpha
303 05118f5a 2021-06-22 stsp (cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
304 05118f5a 2021-06-22 stsp local commit1=`git_show_branch_head $testroot/repo mybranch`
306 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo -x master master \
307 85220b0e 2022-03-22 thomas > /dev/null 2> $testroot/stderr
309 8775a682 2021-07-03 naddy if [ "$ret" = "0" ]; then
310 05118f5a 2021-06-22 stsp echo "gotadmin pack succeeded unexpectedly" >&2
311 05118f5a 2021-06-22 stsp test_done "$testroot" "1"
315 05118f5a 2021-06-22 stsp echo "gotadmin: not enough objects to pack" > $testroot/stderr.expected
316 05118f5a 2021-06-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
318 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
319 05118f5a 2021-06-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
321 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
324 05118f5a 2021-06-22 stsp test_pack_loose_only() {
325 05118f5a 2021-06-22 stsp local testroot=`test_init pack_loose_only`
326 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
328 05118f5a 2021-06-22 stsp # no pack files should exist yet
329 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
331 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
332 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
335 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
336 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
338 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
339 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
344 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
346 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
347 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
351 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
353 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
354 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
358 05118f5a 2021-06-22 stsp echo a new line >> $testroot/wt/alpha
359 05118f5a 2021-06-22 stsp (cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
361 05118f5a 2021-06-22 stsp # pack objects belonging to the 'master' branch; its objects
362 05118f5a 2021-06-22 stsp # should then be excluded while packing 'mybranch' since they
363 05118f5a 2021-06-22 stsp # are already packed
364 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo master > /dev/null
366 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
367 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
368 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
372 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo mybranch > $testroot/stdout
374 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
375 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
376 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
379 05118f5a 2021-06-22 stsp packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
380 05118f5a 2021-06-22 stsp gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
381 05118f5a 2021-06-22 stsp > $testroot/stdout
383 05118f5a 2021-06-22 stsp tree0=`got cat -r $testroot/repo $commit0 | grep ^tree | \
384 05118f5a 2021-06-22 stsp cut -d ' ' -f2`
385 05118f5a 2021-06-22 stsp excluded_ids=`got tree -r $testroot/repo -c $commit0 -R -i | \
386 05118f5a 2021-06-22 stsp cut -d ' ' -f 1`
387 05118f5a 2021-06-22 stsp excluded_ids="$excluded_ids $commit0 $tree0"
388 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
390 05118f5a 2021-06-22 stsp if grep -q ^$id $testroot/stdout; then
391 05118f5a 2021-06-22 stsp echo "found excluded object $id in pack file" >&2
394 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
398 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
399 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
403 05118f5a 2021-06-22 stsp for d in $testroot/repo/.git/objects/[0-9a-f][0-9a-f]; do
404 05118f5a 2021-06-22 stsp id0=`basename $d`
406 05118f5a 2021-06-22 stsp for e in `ls $d`; do
407 05118f5a 2021-06-22 stsp obj_id=${id0}${e}
409 05118f5a 2021-06-22 stsp for id in $excluded_ids; do
410 8775a682 2021-07-03 naddy if [ "$obj_id" = "$id" ]; then
415 8775a682 2021-07-03 naddy if [ "$excluded" = "1" ]; then
418 05118f5a 2021-06-22 stsp if grep -q ^$obj_id $testroot/stdout; then
421 05118f5a 2021-06-22 stsp echo "loose object $obj_id was not packed" >&2
425 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
430 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
433 05118f5a 2021-06-22 stsp test_pack_all_objects() {
434 05118f5a 2021-06-22 stsp local testroot=`test_init pack_all_objects`
435 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
437 05118f5a 2021-06-22 stsp # no pack files should exist yet
438 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
440 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
441 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
444 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
445 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
447 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
448 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
449 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
453 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
455 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
456 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
460 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
462 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
463 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
467 05118f5a 2021-06-22 stsp echo a new line >> $testroot/wt/alpha
468 05118f5a 2021-06-22 stsp (cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
470 05118f5a 2021-06-22 stsp # pack objects belonging to the 'master' branch
471 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo master > /dev/null
473 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
474 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
475 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
479 05118f5a 2021-06-22 stsp # pack mybranch, including already packed objects on the
480 05118f5a 2021-06-22 stsp # 'master' branch which are reachable from mybranch
481 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo -a mybranch > $testroot/stdout
483 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
484 05118f5a 2021-06-22 stsp echo "gotadmin pack failed unexpectedly" >&2
485 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
488 05118f5a 2021-06-22 stsp packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
489 05118f5a 2021-06-22 stsp gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
490 05118f5a 2021-06-22 stsp > $testroot/stdout
492 05118f5a 2021-06-22 stsp for d in $testroot/repo/.git/objects/[0-9a-f][0-9a-f]; do
493 05118f5a 2021-06-22 stsp id0=`basename $d`
495 05118f5a 2021-06-22 stsp for e in `ls $d`; do
496 05118f5a 2021-06-22 stsp obj_id=${id0}${e}
497 05118f5a 2021-06-22 stsp if grep -q ^$obj_id $testroot/stdout; then
500 05118f5a 2021-06-22 stsp echo "loose object $obj_id was not packed" >&2
504 8775a682 2021-07-03 naddy if [ "$ret" = "1" ]; then
509 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
512 05118f5a 2021-06-22 stsp test_pack_bad_ref() {
513 05118f5a 2021-06-22 stsp local testroot=`test_init pack_bad_ref`
514 05118f5a 2021-06-22 stsp local commit0=`git_show_head $testroot/repo`
516 05118f5a 2021-06-22 stsp # no pack files should exist yet
517 05118f5a 2021-06-22 stsp ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
519 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
520 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
523 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
524 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
526 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
527 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
528 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
532 05118f5a 2021-06-22 stsp got branch -r $testroot/repo mybranch
534 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
535 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
539 05118f5a 2021-06-22 stsp got checkout -b mybranch $testroot/repo $testroot/wt > /dev/null
541 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
542 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
546 05118f5a 2021-06-22 stsp gotadmin pack -r $testroot/repo refs/got/worktree/ \
547 05118f5a 2021-06-22 stsp > $testroot/stdout 2> $testroot/stderr
549 8775a682 2021-07-03 naddy if [ "$ret" = "0" ]; then
550 05118f5a 2021-06-22 stsp echo "gotadmin pack succeeded unexpectedly" >&2
551 05118f5a 2021-06-22 stsp test_done "$testroot" "1"
555 05118f5a 2021-06-22 stsp echo -n > $testroot/stdout.expected
556 05118f5a 2021-06-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
559 05118f5a 2021-06-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
564 05118f5a 2021-06-22 stsp echo "gotadmin: not enough objects to pack" > $testroot/stderr.expected
565 05118f5a 2021-06-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
567 05118f5a 2021-06-22 stsp if [ "$ret" != "0" ]; then
568 05118f5a 2021-06-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
570 05118f5a 2021-06-22 stsp test_done "$testroot" "$ret"
573 05118f5a 2021-06-22 stsp test_parseargs "$@"
574 05118f5a 2021-06-22 stsp run_test test_pack_all_loose_objects
575 05118f5a 2021-06-22 stsp run_test test_pack_exclude
576 05118f5a 2021-06-22 stsp run_test test_pack_include
577 05118f5a 2021-06-22 stsp run_test test_pack_ambiguous_arg
578 05118f5a 2021-06-22 stsp run_test test_pack_loose_only
579 05118f5a 2021-06-22 stsp run_test test_pack_all_objects
580 05118f5a 2021-06-22 stsp run_test test_pack_bad_ref