]>
Commit | Line | Data |
---|---|---|
a3407730 DS |
1 | #!/bin/sh |
2 | ||
3 | test_description='multi-pack-indexes' | |
4 | . ./test-lib.sh | |
5 | ||
4d80560c DS |
6 | midx_read_expect () { |
7 | cat >expect <<-EOF | |
8 | header: 4d494458 1 0 0 | |
9 | object-dir: . | |
10 | EOF | |
11 | test-tool read-midx . >actual && | |
12 | test_cmp expect actual | |
13 | } | |
14 | ||
a3407730 | 15 | test_expect_success 'write midx with no packs' ' |
fc59e748 DS |
16 | test_when_finished rm -f pack/multi-pack-index && |
17 | git multi-pack-index --object-dir=. write && | |
4d80560c | 18 | midx_read_expect |
a3407730 DS |
19 | ' |
20 | ||
2c381335 DS |
21 | generate_objects () { |
22 | i=$1 | |
23 | iii=$(printf '%03i' $i) | |
24 | { | |
25 | test-tool genrandom "bar" 200 && | |
26 | test-tool genrandom "baz $iii" 50 | |
27 | } >wide_delta_$iii && | |
28 | { | |
29 | test-tool genrandom "foo"$i 100 && | |
30 | test-tool genrandom "foo"$(( $i + 1 )) 100 && | |
31 | test-tool genrandom "foo"$(( $i + 2 )) 100 | |
32 | } >deep_delta_$iii && | |
33 | { | |
34 | echo $iii && | |
35 | test-tool genrandom "$iii" 8192 | |
36 | } >file_$iii && | |
37 | git update-index --add file_$iii deep_delta_$iii wide_delta_$iii | |
38 | } | |
39 | ||
40 | commit_and_list_objects () { | |
41 | { | |
42 | echo 101 && | |
43 | test-tool genrandom 100 8192; | |
44 | } >file_101 && | |
45 | git update-index --add file_101 && | |
46 | tree=$(git write-tree) && | |
47 | commit=$(git commit-tree $tree -p HEAD</dev/null) && | |
48 | { | |
49 | echo $tree && | |
50 | git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" | |
51 | } >obj-list && | |
52 | git reset --hard $commit | |
53 | } | |
54 | ||
55 | test_expect_success 'create objects' ' | |
56 | test_commit initial && | |
57 | for i in $(test_seq 1 5) | |
58 | do | |
59 | generate_objects $i | |
60 | done && | |
61 | commit_and_list_objects | |
62 | ' | |
63 | ||
64 | test_expect_success 'write midx with one v1 pack' ' | |
65 | pack=$(git pack-objects --index-version=1 pack/test <obj-list) && | |
66 | test_when_finished rm pack/test-$pack.pack pack/test-$pack.idx pack/multi-pack-index && | |
67 | git multi-pack-index --object-dir=. write && | |
68 | midx_read_expect | |
69 | ' | |
70 | ||
71 | test_expect_success 'write midx with one v2 pack' ' | |
72 | git pack-objects --index-version=2,0x40 pack/test <obj-list && | |
73 | git multi-pack-index --object-dir=. write && | |
74 | midx_read_expect | |
75 | ' | |
76 | ||
77 | test_expect_success 'add more objects' ' | |
78 | for i in $(test_seq 6 10) | |
79 | do | |
80 | generate_objects $i | |
81 | done && | |
82 | commit_and_list_objects | |
83 | ' | |
84 | ||
85 | test_expect_success 'write midx with two packs' ' | |
86 | git pack-objects --index-version=1 pack/test-2 <obj-list && | |
87 | git multi-pack-index --object-dir=. write && | |
88 | midx_read_expect | |
89 | ' | |
90 | ||
91 | test_expect_success 'add more packs' ' | |
92 | for j in $(test_seq 11 20) | |
93 | do | |
94 | generate_objects $j && | |
95 | commit_and_list_objects && | |
96 | git pack-objects --index-version=2 test-pack <obj-list | |
97 | done | |
98 | ' | |
99 | ||
100 | test_expect_success 'write midx with twelve packs' ' | |
101 | git multi-pack-index --object-dir=. write && | |
102 | midx_read_expect | |
103 | ' | |
104 | ||
a3407730 | 105 | test_done |