3 test_description='multi-pack-indexes'
14 header: 4d494458 1 $NUM_CHUNKS $NUM_PACKS
15 chunks: pack-names oid-fanout oid-lookup object-offsets$EXTRA_CHUNKS
16 num_objects: $NUM_OBJECTS
19 if test $NUM_PACKS -ge 1
21 ls $OBJECT_DIR/pack/ | grep idx | sort
23 printf "object-dir: $OBJECT_DIR\n"
25 test-tool read-midx $OBJECT_DIR >actual &&
26 test_cmp expect actual
29 test_expect_success 'write midx with no packs' '
30 test_when_finished rm -f pack/multi-pack-index &&
31 git multi-pack-index --object-dir=. write &&
32 midx_read_expect 0 0 4 .
37 iii=$(printf '%03i' $i)
39 test-tool genrandom "bar" 200 &&
40 test-tool genrandom "baz $iii" 50
43 test-tool genrandom "foo"$i 100 &&
44 test-tool genrandom "foo"$(( $i + 1 )) 100 &&
45 test-tool genrandom "foo"$(( $i + 2 )) 100
49 test-tool genrandom "$iii" 8192
51 git update-index --add file_$iii deep_delta_$iii wide_delta_$iii
54 commit_and_list_objects () {
57 test-tool genrandom 100 8192;
59 git update-index --add file_101 &&
60 tree=$(git write-tree) &&
61 commit=$(git commit-tree $tree -p HEAD</dev/null) &&
64 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
66 git reset --hard $commit
69 test_expect_success 'create objects' '
70 test_commit initial &&
71 for i in $(test_seq 1 5)
75 commit_and_list_objects
78 test_expect_success 'write midx with one v1 pack' '
79 pack=$(git pack-objects --index-version=1 pack/test <obj-list) &&
80 test_when_finished rm pack/test-$pack.pack pack/test-$pack.idx pack/multi-pack-index &&
81 git multi-pack-index --object-dir=. write &&
82 midx_read_expect 1 18 4 .
85 test_expect_success 'write midx with one v2 pack' '
86 git pack-objects --index-version=2,0x40 pack/test <obj-list &&
87 git multi-pack-index --object-dir=. write &&
88 midx_read_expect 1 18 4 .
91 test_expect_success 'add more objects' '
92 for i in $(test_seq 6 10)
96 commit_and_list_objects
99 test_expect_success 'write midx with two packs' '
100 git pack-objects --index-version=1 pack/test-2 <obj-list &&
101 git multi-pack-index --object-dir=. write &&
102 midx_read_expect 2 34 4 .
105 test_expect_success 'add more packs' '
106 for j in $(test_seq 11 20)
108 generate_objects $j &&
109 commit_and_list_objects &&
110 git pack-objects --index-version=2 pack/test-pack <obj-list
114 test_expect_success 'write midx with twelve packs' '
115 git multi-pack-index --object-dir=. write &&
116 midx_read_expect 12 74 4 .
119 # usage: corrupt_data <file> <pos> [<data>]
124 printf "$data" | dd of="$file" bs=1 seek="$pos" conv=notrunc
127 # Force 64-bit offsets by manipulating the idx file.
128 # This makes the IDX file _incorrect_ so be careful to clean up after!
129 test_expect_success 'force some 64-bit offsets with pack-objects' '
131 mkdir objects64/pack &&
132 for i in $(test_seq 1 11)
136 commit_and_list_objects &&
137 pack64=$(git pack-objects --index-version=2,0x40 objects64/pack/test-64 <obj-list) &&
138 idx64=objects64/pack/test-64-$pack64.idx &&
140 corrupt_data $idx64 2999 "\02" &&
141 midx64=$(git multi-pack-index --object-dir=objects64 write) &&
142 midx_read_expect 1 63 5 objects64 " large-offsets"