File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir)
37
37
uint32_t hash_version ;
38
38
char * midx_name = get_midx_filename (object_dir );
39
39
uint32_t i ;
40
+ const char * cur_pack_name ;
40
41
41
42
fd = git_open (midx_name );
42
43
@@ -115,6 +116,22 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir)
115
116
if (!m -> chunk_pack_names )
116
117
die (_ ("multi-pack-index missing required pack-name chunk" ));
117
118
119
+ m -> pack_names = xcalloc (m -> num_packs , sizeof (* m -> pack_names ));
120
+
121
+ cur_pack_name = (const char * )m -> chunk_pack_names ;
122
+ for (i = 0 ; i < m -> num_packs ; i ++ ) {
123
+ m -> pack_names [i ] = cur_pack_name ;
124
+
125
+ cur_pack_name += strlen (cur_pack_name ) + 1 ;
126
+
127
+ if (i && strcmp (m -> pack_names [i ], m -> pack_names [i - 1 ]) <= 0 ) {
128
+ error (_ ("multi-pack-index pack names out of order: '%s' before '%s'" ),
129
+ m -> pack_names [i - 1 ],
130
+ m -> pack_names [i ]);
131
+ goto cleanup_fail ;
132
+ }
133
+ }
134
+
118
135
return m ;
119
136
120
137
cleanup_fail :
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ struct multi_pack_index {
16
16
17
17
const unsigned char * chunk_pack_names ;
18
18
19
+ const char * * pack_names ;
19
20
char object_dir [FLEX_ARRAY ];
20
21
};
21
22
Original file line number Diff line number Diff line change 6
6
7
7
static int read_midx_file (const char * object_dir )
8
8
{
9
+ uint32_t i ;
9
10
struct multi_pack_index * m = load_multi_pack_index (object_dir );
10
11
11
12
if (!m )
@@ -24,6 +25,10 @@ static int read_midx_file(const char *object_dir)
24
25
25
26
printf ("\n" );
26
27
28
+ printf ("packs:\n" );
29
+ for (i = 0 ; i < m -> num_packs ; i ++ )
30
+ printf ("%s\n" , m -> pack_names [i ]);
31
+
27
32
printf ("object-dir: %s\n" , m -> object_dir );
28
33
29
34
return 0 ;
Original file line number Diff line number Diff line change @@ -5,11 +5,18 @@ test_description='multi-pack-indexes'
5
5
6
6
midx_read_expect () {
7
7
NUM_PACKS=$1
8
- cat > expect << -EOF
9
- header: 4d494458 1 1 $NUM_PACKS
10
- chunks: pack-names
11
- object-dir: .
12
- EOF
8
+ {
9
+ cat << -EOF &&
10
+ header: 4d494458 1 1 $NUM_PACKS
11
+ chunks: pack-names
12
+ packs:
13
+ EOF
14
+ if test $NUM_PACKS -ge 1
15
+ then
16
+ ls pack/ | grep idx | sort
17
+ fi &&
18
+ printf " object-dir: .\n"
19
+ } > expect &&
13
20
test-tool read-midx . > actual &&
14
21
test_cmp expect actual
15
22
}
You can’t perform that action at this time.
0 commit comments