1#!/bin/sh
2
3test_description='compression setting of fast-import utility'
4. ./test-lib.sh
5
6# This should be moved to test-lib.sh together with the
7# copy in t0021 after both topics have graduated to 'master'.
8file_size () {
9 perl -e 'print -s $ARGV[0]' "$1"
10}
11
12import_large () {
13 (
14 echo blob
15 echo "data <<EOD"
16 printf "%2000000s\n" "$*"
17 echo EOD
18 ) | git "$@" fast-import
19}
20
21while read expect config
22do
23 test_expect_success "fast-import (packed) with $config" '
24 test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
25 test_when_finished "rm -rf .git/objects/??" &&
26 import_large -c fastimport.unpacklimit=0 $config &&
27 sz=$(file_size .git/objects/pack/pack-*.pack) &&
28 case "$expect" in
29 small) test "$sz" -le 100000 ;;
30 large) test "$sz" -ge 100000 ;;
31 esac
32 '
33done <<\EOF
34large -c core.compression=0
35small -c core.compression=9
36large -c core.compression=0 -c pack.compression=0
37large -c core.compression=9 -c pack.compression=0
38small -c core.compression=0 -c pack.compression=9
39small -c core.compression=9 -c pack.compression=9
40large -c pack.compression=0
41small -c pack.compression=9
42EOF
43
44while read expect config
45do
46 test_expect_success "fast-import (loose) with $config" '
47 test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
48 test_when_finished "rm -rf .git/objects/??" &&
49 import_large -c fastimport.unpacklimit=9 $config &&
50 sz=$(file_size .git/objects/??/????*) &&
51 case "$expect" in
52 small) test "$sz" -le 100000 ;;
53 large) test "$sz" -ge 100000 ;;
54 esac
55 '
56done <<\EOF
57large -c core.compression=0
58small -c core.compression=9
59large -c core.compression=0 -c core.loosecompression=0
60large -c core.compression=9 -c core.loosecompression=0
61small -c core.compression=0 -c core.loosecompression=9
62small -c core.compression=9 -c core.loosecompression=9
63large -c core.loosecompression=0
64small -c core.loosecompression=9
65EOF
66
67test_done