Merge branch 'es/sh-i18n-envsubst'
[git/debian.git] / t / t5310-pack-bitmaps.sh
blobd3a3afaba821f8b70c5f365f1046ba7a707e5085
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 &&
18 git config pack.writebitmaphashcache true
21 test_expect_success 'full repack creates bitmaps' '
22 git repack -ad &&
23 ls .git/objects/pack/ | grep bitmap >output &&
24 test_line_count = 1 output
27 test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
28 git rev-list --test-bitmap HEAD
31 rev_list_tests() {
32 state=$1
34 test_expect_success "counting commits via bitmap ($state)" '
35 git rev-list --count HEAD >expect &&
36 git rev-list --use-bitmap-index --count HEAD >actual &&
37 test_cmp expect actual
40 test_expect_success "counting partial commits via bitmap ($state)" '
41 git rev-list --count HEAD~5..HEAD >expect &&
42 git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
43 test_cmp expect actual
46 test_expect_success "counting non-linear history ($state)" '
47 git rev-list --count other...master >expect &&
48 git rev-list --use-bitmap-index --count other...master >actual &&
49 test_cmp expect actual
52 test_expect_success "enumerate --objects ($state)" '
53 git rev-list --objects --use-bitmap-index HEAD >tmp &&
54 cut -d" " -f1 <tmp >tmp2 &&
55 sort <tmp2 >actual &&
56 git rev-list --objects HEAD >tmp &&
57 cut -d" " -f1 <tmp >tmp2 &&
58 sort <tmp2 >expect &&
59 test_cmp expect actual
62 test_expect_success "bitmap --objects handles non-commit objects ($state)" '
63 git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
64 grep $blob actual
68 rev_list_tests 'full bitmap'
70 test_expect_success 'clone from bitmapped repository' '
71 git clone --no-local --bare . clone.git &&
72 git rev-parse HEAD >expect &&
73 git --git-dir=clone.git rev-parse HEAD >actual &&
74 test_cmp expect actual
77 test_expect_success 'setup further non-bitmapped commits' '
78 for i in $(test_seq 1 10); do
79 test_commit further-$i
80 done
83 rev_list_tests 'partial bitmap'
85 test_expect_success 'fetch (partial bitmap)' '
86 git --git-dir=clone.git fetch origin master:master &&
87 git rev-parse HEAD >expect &&
88 git --git-dir=clone.git rev-parse HEAD >actual &&
89 test_cmp expect actual
92 test_expect_success 'incremental repack cannot create bitmaps' '
93 test_commit more-1 &&
94 test_must_fail git repack -d
97 test_expect_success 'incremental repack can disable bitmaps' '
98 test_commit more-2 &&
99 git repack -d --no-write-bitmap-index
102 test_expect_success 'full repack, reusing previous bitmaps' '
103 git repack -ad &&
104 ls .git/objects/pack/ | grep bitmap >output &&
105 test_line_count = 1 output
108 test_expect_success 'fetch (full bitmap)' '
109 git --git-dir=clone.git fetch origin master:master &&
110 git rev-parse HEAD >expect &&
111 git --git-dir=clone.git rev-parse HEAD >actual &&
112 test_cmp expect actual
115 test_lazy_prereq JGIT '
116 type jgit
119 test_expect_success JGIT 'we can read jgit bitmaps' '
120 git clone . compat-jgit &&
122 cd compat-jgit &&
123 rm -f .git/objects/pack/*.bitmap &&
124 jgit gc &&
125 git rev-list --test-bitmap HEAD
129 test_expect_success JGIT 'jgit can read our bitmaps' '
130 git clone . compat-us &&
132 cd compat-us &&
133 git repack -adb &&
134 # jgit gc will barf if it does not like our bitmaps
135 jgit gc
139 test_done