Merge branch 'tb/pack-bitmap-write-cleanups'

The pack bitmap code saw some clean-up to prepare for a follow-up topic.

* tb/pack-bitmap-write-cleanups:
  pack-bitmap: introduce `bitmap_writer_free()`
  pack-bitmap-write.c: avoid uninitialized 'write_as' field
  pack-bitmap: drop unused `max_bitmaps` parameter
  pack-bitmap: avoid use of static `bitmap_writer`
  pack-bitmap-write.c: move commit_positions into commit_pos fields
  object.h: add flags allocated by pack-bitmap.h
This commit is contained in:
Junio C Hamano
2024-05-28 11:17:07 -07:00
5 changed files with 190 additions and 143 deletions

View File

@ -1315,6 +1315,7 @@ static void write_pack_file(void)
if (!pack_to_stdout) {
struct stat st;
struct strbuf tmpname = STRBUF_INIT;
struct bitmap_writer bitmap_writer;
char *idx_tmp_name = NULL;
/*
@ -1340,8 +1341,9 @@ static void write_pack_file(void)
hash_to_hex(hash));
if (write_bitmap_index) {
bitmap_writer_set_checksum(hash);
bitmap_writer_build_type_index(
bitmap_writer_init(&bitmap_writer);
bitmap_writer_set_checksum(&bitmap_writer, hash);
bitmap_writer_build_type_index(&bitmap_writer,
&to_pack, written_list, nr_written);
}
@ -1359,12 +1361,17 @@ static void write_pack_file(void)
strbuf_addstr(&tmpname, "bitmap");
stop_progress(&progress_state);
bitmap_writer_show_progress(progress);
bitmap_writer_select_commits(indexed_commits, indexed_commits_nr, -1);
if (bitmap_writer_build(&to_pack) < 0)
bitmap_writer_show_progress(&bitmap_writer,
progress);
bitmap_writer_select_commits(&bitmap_writer,
indexed_commits,
indexed_commits_nr);
if (bitmap_writer_build(&bitmap_writer, &to_pack) < 0)
die(_("failed to write bitmap index"));
bitmap_writer_finish(written_list, nr_written,
bitmap_writer_finish(&bitmap_writer,
written_list, nr_written,
tmpname.buf, write_bitmap_options);
bitmap_writer_free(&bitmap_writer);
write_bitmap_index = 0;
strbuf_setlen(&tmpname, tmpname_len);
}