Merge branch 'nd/log-show-linear-break'
[git.git] / t / t5310-pack-bitmaps.sh
blobf13525caa309e48ab32f89066a3e9661dfc25e09
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 find .git/objects/pack -name "*.bitmap" >expect &&
95 git repack -d &&
96 find .git/objects/pack -name "*.bitmap" >actual &&
97 test_cmp expect actual
100 test_expect_success 'incremental repack can disable bitmaps' '
101 test_commit more-2 &&
102 git repack -d --no-write-bitmap-index
105 test_expect_success 'full repack, reusing previous bitmaps' '
106 git repack -ad &&
107 ls .git/objects/pack/ | grep bitmap >output &&
108 test_line_count = 1 output
111 test_expect_success 'fetch (full bitmap)' '
112 git --git-dir=clone.git fetch origin master:master &&
113 git rev-parse HEAD >expect &&
114 git --git-dir=clone.git rev-parse HEAD >actual &&
115 test_cmp expect actual
118 test_lazy_prereq JGIT '
119 type jgit
122 test_expect_success JGIT 'we can read jgit bitmaps' '
123 git clone . compat-jgit &&
125 cd compat-jgit &&
126 rm -f .git/objects/pack/*.bitmap &&
127 jgit gc &&
128 git rev-list --test-bitmap HEAD
132 test_expect_success JGIT 'jgit can read our bitmaps' '
133 git clone . compat-us &&
135 cd compat-us &&
136 git repack -adb &&
137 # jgit gc will barf if it does not like our bitmaps
138 jgit gc
142 test_done