packv4: nth_packed_object_sha1() packv4 support
[git/packv4.git] / packv4 / packv4-test
blob977b7e6311912a6ec30beace0216323229903320
1 #!/bin/sh
3 # packv4-test: Basic test script for packv4
5 # NOTE: it's assumed that you have git with packv4 support plus
6 # dump-sha1-list and dump-test installed
9 REPO=$1
10 TMPDIR=""
11 REPO_TEST=repo-test
13 die_on_error()
15 retcode=$1
16 errmsg=$2
18 if [ $retcode -ne 0 ]; then
19 printf 'ERROR: %s\n' "$errmsg" >> /dev/stderr
20 exit 1
24 create_tmp()
26 dirname=$1
28 TMPDIR=$(mktemp -d "$dirname") || exit 1
29 pushd $TMPDIR 1> /dev/null
30 die_on_error $? "could not enter $TMPDIR"
33 unpack_objects()
35 pack=""
36 dot="$REPO".git
38 pack=$(ls $dot/objects/pack/*.pack)
39 git-unpack-objects < $pack
40 die_on_error $? "could not unpack objects"
42 cp $dot/refs/heads/master .git/refs/heads/master
43 die_on_error $? "could not copy master file"
46 list_test()
48 dump-sha1-list .git/objects/pack/pack-* > list.txt
49 die_on_error $? "could not dump list"
51 dump-test list.txt $PWD
52 die_on_error $? "dump-test failed"
55 repack_objects()
57 git-repack -a -d --pack-version=4
58 die_on_error $? "could not repack objects"
60 git-prune
61 die_on_error $? "could not prune objects"
64 if [ -z "$REPO" ]; then
65 echo -e "packv4-test < repo >"
66 exit 1
69 create_tmp "/tmp/packv4-test.XXXXXXXXXX"
71 git-init
72 die_on_error $? "git-init failed"
74 # needed steps and basic tests
75 unpack_objects
76 repack_objects
78 # the actual test
79 list_test
81 popd 1> /dev/null
82 rm -rf $TMPDIR