t: add basic bitmap functionality tests
[git/jrn.git] / t / t5310-pack-bitmaps.sh
blobd2b0c45ccae162ce443afa2b9b288e652add5607
1 #!/bin/sh
3 test_description='exercise basic bitmap functionality'
4 . ./test-lib.sh
6 test_expect_success 'setup repo with moderate-sized history' '
7 for i in $(test_seq 1 10); do
8 test_commit $i
9 done &&
10 git checkout -b other HEAD~5 &&
11 for i in $(test_seq 1 10); do
12 test_commit side-$i
13 done &&
14 git checkout master &&
15 blob=$(echo tagged-blob | git hash-object -w --stdin) &&
16 git tag tagged-blob $blob &&
17 git config pack.writebitmaps true
20 test_expect_success 'full repack creates bitmaps' '
21 git repack -ad &&
22 ls .git/objects/pack/ | grep bitmap >output &&
23 test_line_count = 1 output
26 test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
27 git rev-list --test-bitmap HEAD
30 rev_list_tests() {
31 state=$1
33 test_expect_success "counting commits via bitmap ($state)" '
34 git rev-list --count HEAD >expect &&
35 git rev-list --use-bitmap-index --count HEAD >actual &&
36 test_cmp expect actual
39 test_expect_success "counting partial commits via bitmap ($state)" '
40 git rev-list --count HEAD~5..HEAD >expect &&
41 git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
42 test_cmp expect actual
45 test_expect_success "counting non-linear history ($state)" '
46 git rev-list --count other...master >expect &&
47 git rev-list --use-bitmap-index --count other...master >actual &&
48 test_cmp expect actual
51 test_expect_success "enumerate --objects ($state)" '
52 git rev-list --objects --use-bitmap-index HEAD >tmp &&
53 cut -d" " -f1 <tmp >tmp2 &&
54 sort <tmp2 >actual &&
55 git rev-list --objects HEAD >tmp &&
56 cut -d" " -f1 <tmp >tmp2 &&
57 sort <tmp2 >expect &&
58 test_cmp expect actual
61 test_expect_success "bitmap --objects handles non-commit objects ($state)" '
62 git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
63 grep $blob actual
67 rev_list_tests 'full bitmap'
69 test_expect_success 'clone from bitmapped repository' '
70 git clone --no-local --bare . clone.git &&
71 git rev-parse HEAD >expect &&
72 git --git-dir=clone.git rev-parse HEAD >actual &&
73 test_cmp expect actual
76 test_expect_success 'setup further non-bitmapped commits' '
77 for i in $(test_seq 1 10); do
78 test_commit further-$i
79 done
82 rev_list_tests 'partial bitmap'
84 test_expect_success 'fetch (partial bitmap)' '
85 git --git-dir=clone.git fetch origin master:master &&
86 git rev-parse HEAD >expect &&
87 git --git-dir=clone.git rev-parse HEAD >actual &&
88 test_cmp expect actual
91 test_expect_success 'incremental repack cannot create bitmaps' '
92 test_commit more-1 &&
93 test_must_fail git repack -d
96 test_expect_success 'incremental repack can disable bitmaps' '
97 test_commit more-2 &&
98 git repack -d --no-write-bitmap-index
101 test_expect_success 'full repack, reusing previous bitmaps' '
102 git repack -ad &&
103 ls .git/objects/pack/ | grep bitmap >output &&
104 test_line_count = 1 output
107 test_expect_success 'fetch (full bitmap)' '
108 git --git-dir=clone.git fetch origin master:master &&
109 git rev-parse HEAD >expect &&
110 git --git-dir=clone.git rev-parse HEAD >actual &&
111 test_cmp expect actual
114 test_lazy_prereq JGIT '
115 type jgit
118 test_expect_success JGIT 'we can read jgit bitmaps' '
119 git clone . compat-jgit &&
121 cd compat-jgit &&
122 rm -f .git/objects/pack/*.bitmap &&
123 jgit gc &&
124 git rev-list --test-bitmap HEAD
128 test_expect_success JGIT 'jgit can read our bitmaps' '
129 git clone . compat-us &&
131 cd compat-us &&
132 git repack -adb &&
133 # jgit gc will barf if it does not like our bitmaps
134 jgit gc
138 test_done