t5319: expand test data

As we build the multi-pack-index file format, we want to test the format on real repositories. Add tests that create repository data including multiple packfiles with both version 1 and version 2 formats. The current 'git multi-pack-index write' command will always write the same file with no "real" data. This will be expanded in future commits, along with the test expectations. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jul 12, 2018 at 15:39 UTC 2c3813354b2c02221f8496d8f8671f5b33d878ad
1 file changed +84
t/t5319-multi-pack-index.sh
+84
@@ -18,4 +18,88 @@ test_expect_success 'write midx with no packs' '
18 midx_read_expect
19 '
20
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 +
105 test_done