3 test_description
='basic tests of rev-list --disk-usage'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 # we want a mix of reachable and unreachable, as well as
9 # objects in the bitmapped pack and some outside of it
10 test_expect_success
'set up repository' '
11 test_commit --no-tag one &&
12 test_commit --no-tag two &&
14 git reset --hard HEAD^ &&
15 test_commit --no-tag three &&
16 test_commit --no-tag four &&
17 git reset --hard HEAD^
20 # We don't want to hardcode sizes, because they depend on the exact details of
21 # packing, zlib, etc. We'll assume that the regular rev-list and cat-file
22 # machinery works and compare the --disk-usage output to that.
24 git rev-list
--no-object-names "$@" |
25 git cat-file
--batch-check="%(objectsize:disk)" |
26 perl
-lne '$total += $_; END { print $total}'
29 # check behavior with given rev-list options; note that
30 # whitespace is not preserved in args
34 test_expect_success
"generate expected size ($args)" "
35 disk_usage_slow $args >expect
38 test_expect_success
"rev-list --disk-usage without bitmaps ($args)" "
39 git rev-list --disk-usage $args >actual &&
40 test_cmp expect actual
43 test_expect_success
"rev-list --disk-usage with bitmaps ($args)" "
44 git rev-list --disk-usage --use-bitmap-index $args >actual &&
45 test_cmp expect actual
50 check_du
--objects HEAD
51 check_du
--objects HEAD^..HEAD
53 test_expect_success
'setup for --unpacked tests' '
58 check_du
--all --objects --unpacked
60 # As mentioned above, don't use hardcode sizes as actual size, but use the
61 # output from git cat-file.
62 test_expect_success
'rev-list --disk-usage=human' '
63 git rev-list --objects HEAD --disk-usage=human >actual &&
64 disk_usage_slow --objects HEAD >actual_size &&
65 grep "$(cat actual_size) bytes" actual
68 test_expect_success
'rev-list --disk-usage=human with bitmaps' '
69 git rev-list --objects HEAD --use-bitmap-index --disk-usage=human >actual &&
70 disk_usage_slow --objects HEAD >actual_size &&
71 grep "$(cat actual_size) bytes" actual
74 test_expect_success
'rev-list use --disk-usage unproperly' '
75 test_must_fail git rev-list --objects HEAD --disk-usage=typo 2>err &&
76 cat >expect <<-\EOF &&
77 fatal: invalid value for '\''--disk-usage=<format>'\'': '\''typo'\'', the only allowed format is '\''human'\''