mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
8de7eeb54b
There are three codepaths that use a variable whose name is pack_compression_level to affect how objects and deltas sent to a packfile is compressed. Unlike zlib_compression_level that controls the loose object compression, however, this variable was static to each of these codepaths. Two of them read the pack.compression configuration variable, using core.compression as the default, and one of them also allowed overriding it from the command line. The other codepath in bulk-checkin did not pay any attention to the configuration. Unify the configuration parsing to git_default_config(), where we implement the parsing of core.loosecompression and core.compression and make the former override the latter, by moving code to parse pack.compression and also allow core.compression to give default to this variable. Signed-off-by: Junio C Hamano <gitster@pobox.com>
68 lines
1.8 KiB
Bash
Executable File
68 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='compression setting of fast-import utility'
|
|
. ./test-lib.sh
|
|
|
|
# This should be moved to test-lib.sh together with the
|
|
# copy in t0021 after both topics have graduated to 'master'.
|
|
file_size () {
|
|
perl -e 'print -s $ARGV[0]' "$1"
|
|
}
|
|
|
|
import_large () {
|
|
(
|
|
echo blob
|
|
echo "data <<EOD"
|
|
printf "%2000000s\n" "$*"
|
|
echo EOD
|
|
) | git "$@" fast-import
|
|
}
|
|
|
|
while read expect config
|
|
do
|
|
test_expect_success "fast-import (packed) with $config" '
|
|
test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
|
|
test_when_finished "rm -rf .git/objects/??" &&
|
|
import_large -c fastimport.unpacklimit=0 $config &&
|
|
sz=$(file_size .git/objects/pack/pack-*.pack) &&
|
|
case "$expect" in
|
|
small) test "$sz" -le 100000 ;;
|
|
large) test "$sz" -ge 100000 ;;
|
|
esac
|
|
'
|
|
done <<\EOF
|
|
large -c core.compression=0
|
|
small -c core.compression=9
|
|
large -c core.compression=0 -c pack.compression=0
|
|
large -c core.compression=9 -c pack.compression=0
|
|
small -c core.compression=0 -c pack.compression=9
|
|
small -c core.compression=9 -c pack.compression=9
|
|
large -c pack.compression=0
|
|
small -c pack.compression=9
|
|
EOF
|
|
|
|
while read expect config
|
|
do
|
|
test_expect_success "fast-import (loose) with $config" '
|
|
test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
|
|
test_when_finished "rm -rf .git/objects/??" &&
|
|
import_large -c fastimport.unpacklimit=9 $config &&
|
|
sz=$(file_size .git/objects/??/????*) &&
|
|
case "$expect" in
|
|
small) test "$sz" -le 100000 ;;
|
|
large) test "$sz" -ge 100000 ;;
|
|
esac
|
|
'
|
|
done <<\EOF
|
|
large -c core.compression=0
|
|
small -c core.compression=9
|
|
large -c core.compression=0 -c core.loosecompression=0
|
|
large -c core.compression=9 -c core.loosecompression=0
|
|
small -c core.compression=0 -c core.loosecompression=9
|
|
small -c core.compression=9 -c core.loosecompression=9
|
|
large -c core.loosecompression=0
|
|
small -c core.loosecompression=9
|
|
EOF
|
|
|
|
test_done
|