Merge branch 'ab/doc-no-option-notation-fix' into maint
[git] / t / t9303-fast-import-compression.sh
1 #!/bin/sh
2
3 test_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'.
8 file_size () {
9         perl -e 'print -s $ARGV[0]' "$1"
10 }
11
12 import_large () {
13         (
14                 echo blob
15                 echo "data <<EOD"
16                 printf "%2000000s\n" "$*"
17                 echo EOD
18         ) | git "$@" fast-import
19 }
20
21 while read expect config
22 do
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         '
33 done <<\EOF
34 large -c core.compression=0
35 small -c core.compression=9
36 large -c core.compression=0 -c pack.compression=0
37 large -c core.compression=9 -c pack.compression=0
38 small -c core.compression=0 -c pack.compression=9
39 small -c core.compression=9 -c pack.compression=9
40 large -c pack.compression=0
41 small -c pack.compression=9
42 EOF
43
44 while read expect config
45 do
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         '
56 done <<\EOF
57 large -c core.compression=0
58 small -c core.compression=9
59 large -c core.compression=0 -c core.loosecompression=0
60 large -c core.compression=9 -c core.loosecompression=0
61 small -c core.compression=0 -c core.loosecompression=9
62 small -c core.compression=9 -c core.loosecompression=9
63 large -c core.loosecompression=0
64 small -c core.loosecompression=9
65 EOF
66
67 test_done