]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5310-pack-bitmaps.sh
pack-objects: compute local/ignore_pack_keep early
[thirdparty/git.git] / t / t5310-pack-bitmaps.sh
CommitLineData
212f2ffb
JK
1#!/bin/sh
2
3test_description='exercise basic bitmap functionality'
4. ./test-lib.sh
5
2db1a43f
VM
6objpath () {
7 echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
8}
9
212f2ffb
JK
10test_expect_success 'setup repo with moderate-sized history' '
11 for i in $(test_seq 1 10); do
12 test_commit $i
13 done &&
14 git checkout -b other HEAD~5 &&
15 for i in $(test_seq 1 10); do
16 test_commit side-$i
17 done &&
18 git checkout master &&
19 blob=$(echo tagged-blob | git hash-object -w --stdin) &&
20 git tag tagged-blob $blob &&
71d76cb4 21 git config repack.writebitmaps true &&
ae4f07fb 22 git config pack.writebitmaphashcache true
212f2ffb
JK
23'
24
25test_expect_success 'full repack creates bitmaps' '
26 git repack -ad &&
27 ls .git/objects/pack/ | grep bitmap >output &&
28 test_line_count = 1 output
29'
30
31test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
32 git rev-list --test-bitmap HEAD
33'
34
35rev_list_tests() {
36 state=$1
37
38 test_expect_success "counting commits via bitmap ($state)" '
39 git rev-list --count HEAD >expect &&
40 git rev-list --use-bitmap-index --count HEAD >actual &&
41 test_cmp expect actual
42 '
43
44 test_expect_success "counting partial commits via bitmap ($state)" '
45 git rev-list --count HEAD~5..HEAD >expect &&
46 git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
47 test_cmp expect actual
48 '
49
5c9f9bf3
JK
50 test_expect_success "counting commits with limit ($state)" '
51 git rev-list --count -n 1 HEAD >expect &&
52 git rev-list --use-bitmap-index --count -n 1 HEAD >actual &&
53 test_cmp expect actual
54 '
55
212f2ffb
JK
56 test_expect_success "counting non-linear history ($state)" '
57 git rev-list --count other...master >expect &&
58 git rev-list --use-bitmap-index --count other...master >actual &&
59 test_cmp expect actual
60 '
61
c8a70d35
JK
62 test_expect_success "counting commits with limiting ($state)" '
63 git rev-list --count HEAD -- 1.t >expect &&
64 git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
65 test_cmp expect actual
66 '
67
212f2ffb
JK
68 test_expect_success "enumerate --objects ($state)" '
69 git rev-list --objects --use-bitmap-index HEAD >tmp &&
70 cut -d" " -f1 <tmp >tmp2 &&
71 sort <tmp2 >actual &&
72 git rev-list --objects HEAD >tmp &&
73 cut -d" " -f1 <tmp >tmp2 &&
74 sort <tmp2 >expect &&
75 test_cmp expect actual
76 '
77
78 test_expect_success "bitmap --objects handles non-commit objects ($state)" '
79 git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
80 grep $blob actual
81 '
82}
83
84rev_list_tests 'full bitmap'
85
86test_expect_success 'clone from bitmapped repository' '
87 git clone --no-local --bare . clone.git &&
88 git rev-parse HEAD >expect &&
89 git --git-dir=clone.git rev-parse HEAD >actual &&
90 test_cmp expect actual
91'
92
93test_expect_success 'setup further non-bitmapped commits' '
94 for i in $(test_seq 1 10); do
95 test_commit further-$i
96 done
97'
98
99rev_list_tests 'partial bitmap'
100
101test_expect_success 'fetch (partial bitmap)' '
102 git --git-dir=clone.git fetch origin master:master &&
103 git rev-parse HEAD >expect &&
104 git --git-dir=clone.git rev-parse HEAD >actual &&
105 test_cmp expect actual
106'
107
108test_expect_success 'incremental repack cannot create bitmaps' '
109 test_commit more-1 &&
373c67da
JK
110 find .git/objects/pack -name "*.bitmap" >expect &&
111 git repack -d &&
112 find .git/objects/pack -name "*.bitmap" >actual &&
113 test_cmp expect actual
212f2ffb
JK
114'
115
116test_expect_success 'incremental repack can disable bitmaps' '
117 test_commit more-2 &&
118 git repack -d --no-write-bitmap-index
119'
120
121test_expect_success 'full repack, reusing previous bitmaps' '
122 git repack -ad &&
123 ls .git/objects/pack/ | grep bitmap >output &&
124 test_line_count = 1 output
125'
126
127test_expect_success 'fetch (full bitmap)' '
128 git --git-dir=clone.git fetch origin master:master &&
129 git rev-parse HEAD >expect &&
130 git --git-dir=clone.git rev-parse HEAD >actual &&
131 test_cmp expect actual
132'
133
2db1a43f
VM
134test_expect_success 'create objects for missing-HAVE tests' '
135 blob=$(echo "missing have" | git hash-object -w --stdin) &&
136 tree=$(printf "100644 blob $blob\tfile\n" | git mktree) &&
137 parent=$(echo parent | git commit-tree $tree) &&
138 commit=$(echo commit | git commit-tree $tree -p $parent) &&
139 cat >revs <<-EOF
140 HEAD
141 ^HEAD^
142 ^$commit
143 EOF
144'
145
146test_expect_success 'pack with missing blob' '
147 rm $(objpath $blob) &&
148 git pack-objects --stdout --revs <revs >/dev/null
149'
150
151test_expect_success 'pack with missing tree' '
152 rm $(objpath $tree) &&
153 git pack-objects --stdout --revs <revs >/dev/null
154'
155
156test_expect_success 'pack with missing parent' '
157 rm $(objpath $parent) &&
158 git pack-objects --stdout --revs <revs >/dev/null
159'
160
212f2ffb
JK
161test_lazy_prereq JGIT '
162 type jgit
163'
164
165test_expect_success JGIT 'we can read jgit bitmaps' '
166 git clone . compat-jgit &&
167 (
168 cd compat-jgit &&
169 rm -f .git/objects/pack/*.bitmap &&
170 jgit gc &&
171 git rev-list --test-bitmap HEAD
172 )
173'
174
175test_expect_success JGIT 'jgit can read our bitmaps' '
176 git clone . compat-us &&
177 (
178 cd compat-us &&
179 git repack -adb &&
180 # jgit gc will barf if it does not like our bitmaps
181 jgit gc
182 )
183'
184
21134714
JK
185test_expect_success 'splitting packs does not generate bogus bitmaps' '
186 test-genrandom foo $((1024 * 1024)) >rand &&
187 git add rand &&
188 git commit -m "commit with big file" &&
189 git -c pack.packSizeLimit=500k repack -adb &&
190 git init --bare no-bitmaps.git &&
191 git -C no-bitmaps.git fetch .. HEAD
192'
193
212f2ffb 194test_done