Skip to content

Commit 01e9d12

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap: initialize bitmap_writer_init() with packing_data
In order to determine its object order, the pack-bitmap machinery keeps a 'struct packing_data' corresponding to the pack or pseudo-pack (when writing a MIDX bitmap) being written. The to_pack field is provided to the bitmap machinery by callers of bitmap_writer_build() and assigned to the bitmap_writer struct at that point. But a subsequent commit will want to have access to that data earlier on during commit selection. Prepare for that by adding a 'to_pack' argument to 'bitmap_writer_init()', and initializing the field during that function. Subsequent commits will clean up other functions which take now-redundant arguments (like nr_objects, which is equivalent to pdata->objects_nr, or pdata itself). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 39bf06a commit 01e9d12

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ static void write_pack_file(void)
13421342

13431343
if (write_bitmap_index) {
13441344
bitmap_writer_init(&bitmap_writer,
1345-
the_repository);
1345+
the_repository, &to_pack);
13461346
bitmap_writer_set_checksum(&bitmap_writer, hash);
13471347
bitmap_writer_build_type_index(&bitmap_writer,
13481348
&to_pack, written_list, nr_written);

midx-write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static int write_midx_bitmap(const char *midx_name,
825825
for (i = 0; i < pdata->nr_objects; i++)
826826
index[i] = &pdata->objects[i].idx;
827827

828-
bitmap_writer_init(&writer, the_repository);
828+
bitmap_writer_init(&writer, the_repository, pdata);
829829
bitmap_writer_show_progress(&writer, flags & MIDX_PROGRESS);
830830
bitmap_writer_build_type_index(&writer, pdata, index,
831831
pdata->nr_objects);

pack-bitmap-write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ static inline int bitmap_writer_nr_selected_commits(struct bitmap_writer *writer
4141
return writer->selected_nr - writer->pseudo_merges_nr;
4242
}
4343

44-
void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r)
44+
void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r,
45+
struct packing_data *pdata)
4546
{
4647
memset(writer, 0, sizeof(struct bitmap_writer));
4748
if (writer->bitmaps)
4849
BUG("bitmap writer already initialized");
4950
writer->bitmaps = kh_init_oid_map();
5051
writer->pseudo_merge_commits = kh_init_oid_map();
52+
writer->to_pack = pdata;
5153

5254
string_list_init_dup(&writer->pseudo_merge_groups);
5355

pack-bitmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ struct bitmap_writer {
123123
unsigned char pack_checksum[GIT_MAX_RAWSZ];
124124
};
125125

126-
void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r);
126+
void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r,
127+
struct packing_data *pdata);
127128
void bitmap_writer_show_progress(struct bitmap_writer *writer, int show);
128129
void bitmap_writer_set_checksum(struct bitmap_writer *writer,
129130
const unsigned char *sha1);

0 commit comments

Comments
 (0)