3 test_description
='exercise basic multi-pack bitmap functionality'
5 .
"${TEST_DIRECTORY}/lib-bitmap.sh"
7 # We'll be writing our own midx and bitmaps, so avoid getting confused by the
9 GIT_TEST_MULTI_PACK_INDEX
=0
10 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
=0
13 midx
=$objdir/pack
/multi-pack-index
15 # midx_pack_source <obj>
17 test-tool read-midx
--show-objects .git
/objects |
grep "^$1 " | cut
-f2
22 test_expect_success
'enable core.multiPackIndex' '
23 git config core.multiPackIndex true
26 test_expect_success
'create single-pack midx with bitmaps' '
28 git multi-pack-index write --bitmap &&
29 test_path_is_file $midx &&
30 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
31 test_path_is_file $midx-$(midx_checksum $objdir).rev
36 test_expect_success
'create new additional packs' '
37 for i in $(test_seq 1 16)
40 git repack -d || return 1
43 git checkout -b other2 HEAD~8 &&
44 for i in $(test_seq 1 8)
46 test_commit "side-$i" &&
47 git repack -d || return 1
52 test_expect_success
'create multi-pack midx with bitmaps' '
53 git multi-pack-index write --bitmap &&
55 ls $objdir/pack/pack-*.pack >packs &&
56 test_line_count = 25 packs &&
58 test_path_is_file $midx &&
59 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
60 test_path_is_file $midx-$(midx_checksum $objdir).rev
65 test_expect_success
'--no-bitmap is respected when bitmaps exist' '
66 git multi-pack-index write --bitmap &&
68 test_commit respect--no-bitmap &&
71 test_path_is_file $midx &&
72 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
73 test_path_is_file $midx-$(midx_checksum $objdir).rev &&
75 git multi-pack-index write --no-bitmap &&
77 test_path_is_file $midx &&
78 test_path_is_missing $midx-$(midx_checksum $objdir).bitmap &&
79 test_path_is_missing $midx-$(midx_checksum $objdir).rev
82 test_expect_success
'setup midx with base from later pack' '
83 # Write a and b so that "a" is a delta on top of base "b", since Git
84 # prefers to delete contents out of a base rather than add to a shorter
90 git commit -m "initial commit" &&
92 a=$(git rev-parse HEAD:a) &&
93 b=$(git rev-parse HEAD:b) &&
95 # In the first pack, "a" is stored as a delta to "b".
96 p1=$(git pack-objects .git/objects/pack/pack <<-EOF
102 # In the second pack, "a" is missing, and "b" is not a delta nor base to
104 p2=$(git pack-objects .git/objects/pack/pack <<-EOF
106 $(git rev-parse HEAD)
107 $(git rev-parse HEAD^{tree})
112 # Use the second pack as the preferred source, so that "b" occurs
113 # earlier in the MIDX object order, rendering "a" unusable for pack
115 git multi-pack-index write --bitmap --preferred-pack=pack-$p2.idx &&
118 test $(midx_pack_source $a) != $(midx_pack_source $b)
121 rev_list_tests
'full bitmap with backwards delta'
123 test_expect_success
'clone with bitmaps enabled' '
124 git clone --no-local --bare . clone-reverse-delta.git &&
125 test_when_finished "rm -fr clone-reverse-delta.git" &&
127 git rev-parse HEAD >expect &&
128 git --git-dir=clone-reverse-delta.git rev-parse HEAD >actual &&
129 test_cmp expect actual
132 bitmap_reuse_tests
() {
136 test_expect_success
"setup pack reuse tests ($from -> $to)" '
141 test_commit_bulk 16 &&
144 git config core.multiPackIndex true &&
145 if test "MIDX" = "$from"
148 git multi-pack-index write --bitmap
155 test_expect_success
"build bitmap from existing ($from -> $to)" '
158 test_commit_bulk --id=further 16 &&
161 if test "MIDX" = "$to"
164 git multi-pack-index write --bitmap
171 test_expect_success
"verify resulting bitmaps ($from -> $to)" '
175 git rev-list --test-bitmap refs/tags/old-tip &&
176 git rev-list --test-bitmap refs/tags/new-tip
181 bitmap_reuse_tests
'pack' 'MIDX'
182 bitmap_reuse_tests
'MIDX' 'pack'
183 bitmap_reuse_tests
'MIDX' 'MIDX'
185 test_expect_success
'missing object closure fails gracefully' '
188 test_when_finished "rm -fr repo" &&
193 test_commit packed &&
195 # Do not pass "--revs"; we want a pack without the "loose"
197 git pack-objects $objdir/pack/pack <<-EOF &&
198 $(git rev-parse packed)
201 test_must_fail git multi-pack-index write --bitmap 2>err &&
202 grep "doesn.t have full closure" err &&
203 test_path_is_missing $midx
207 test_expect_success
'setup partial bitmaps' '
208 test_commit packed &&
211 git multi-pack-index write --bitmap 2>err &&
212 test_path_is_file $midx &&
213 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
214 test_path_is_file $midx-$(midx_checksum $objdir).rev
217 basic_bitmap_tests HEAD~
219 test_expect_success
'removing a MIDX clears stale bitmaps' '
222 test_when_finished "rm -fr repo" &&
227 git multi-pack-index write --bitmap &&
229 # Write a MIDX and bitmap; remove the MIDX but leave the bitmap.
230 stale_bitmap=$midx-$(midx_checksum $objdir).bitmap &&
231 stale_rev=$midx-$(midx_checksum $objdir).rev &&
234 # Then write a new MIDX.
237 git multi-pack-index write --bitmap &&
239 test_path_is_file $midx &&
240 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
241 test_path_is_file $midx-$(midx_checksum $objdir).rev &&
242 test_path_is_missing $stale_bitmap &&
243 test_path_is_missing $stale_rev
247 test_expect_success
'pack.preferBitmapTips' '
249 test_when_finished "rm -fr repo" &&
253 test_commit_bulk --message="%s" 103 &&
255 git log --format="%H" >commits.raw &&
256 sort <commits.raw >commits &&
258 git log --format="create refs/tags/%s %H" HEAD >refs &&
259 git update-ref --stdin <refs &&
261 git multi-pack-index write --bitmap &&
262 test_path_is_file $midx &&
263 test_path_is_file $midx-$(midx_checksum $objdir).bitmap &&
264 test_path_is_file $midx-$(midx_checksum $objdir).rev &&
266 test-tool bitmap list-commits | sort >bitmaps &&
267 comm -13 bitmaps commits >before &&
268 test_line_count = 1 before &&
270 perl -ne "printf(\"create refs/tags/include/%d \", $.); print" \
271 <before | git update-ref --stdin &&
273 rm -fr $midx-$(midx_checksum $objdir).bitmap &&
274 rm -fr $midx-$(midx_checksum $objdir).rev &&
277 git -c pack.preferBitmapTips=refs/tags/include \
278 multi-pack-index write --bitmap &&
279 test-tool bitmap list-commits | sort >bitmaps &&
280 comm -13 bitmaps commits >after &&
282 ! test_cmp before after