MCPcopy Index your code
hub / github.com/git/git / write_midx_bitmap

Function write_midx_bitmap

midx-write.c:881–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

879}
880
881static int write_midx_bitmap(struct write_midx_context *ctx,
882 const unsigned char *midx_hash,
883 struct packing_data *pdata,
884 struct commit **commits,
885 uint32_t commits_nr,
886 unsigned flags)
887{
888 int ret;
889 uint16_t options = 0;
890 struct bitmap_writer writer;
891 struct pack_idx_entry **index;
892 struct strbuf bitmap_name = STRBUF_INIT;
893
894 trace2_region_enter("midx", "write_midx_bitmap", ctx->repo);
895
896 if (ctx->incremental)
897 get_split_midx_filename_ext(ctx->source, &bitmap_name,
898 midx_hash, MIDX_EXT_BITMAP);
899 else
900 get_midx_filename_ext(ctx->source, &bitmap_name,
901 midx_hash, MIDX_EXT_BITMAP);
902
903 if (flags & MIDX_WRITE_BITMAP_HASH_CACHE)
904 options |= BITMAP_OPT_HASH_CACHE;
905
906 if (flags & MIDX_WRITE_BITMAP_LOOKUP_TABLE)
907 options |= BITMAP_OPT_LOOKUP_TABLE;
908
909 /*
910 * Build the MIDX-order index based on pdata.objects (which is already
911 * in MIDX order; c.f., 'midx_pack_order_cmp()' for the definition of
912 * this order).
913 */
914 ALLOC_ARRAY(index, pdata->nr_objects);
915 for (uint32_t i = 0; i < pdata->nr_objects; i++)
916 index[i] = &pdata->objects[i].idx;
917
918 bitmap_writer_init(&writer, ctx->repo, pdata,
919 ctx->incremental ? ctx->base_midx : NULL);
920 bitmap_writer_show_progress(&writer, flags & MIDX_PROGRESS);
921 bitmap_writer_build_type_index(&writer, index);
922
923 /*
924 * bitmap_writer_finish expects objects in lex order, but pack_order
925 * gives us exactly that. use it directly instead of re-sorting the
926 * array.
927 *
928 * This changes the order of objects in 'index' between
929 * bitmap_writer_build_type_index and bitmap_writer_finish.
930 *
931 * The same re-ordering takes place in the single-pack bitmap code via
932 * write_idx_file(), which is called by finish_tmp_packfile(), which
933 * happens between bitmap_writer_build_type_index() and
934 * bitmap_writer_finish().
935 */
936 for (uint32_t i = 0; i < pdata->nr_objects; i++)
937 index[ctx->pack_order[i]] = &pdata->objects[i].idx;
938

Callers 1

write_midx_internalFunction · 0.85

Calls 11

get_midx_filename_extFunction · 0.85
bitmap_writer_initFunction · 0.85
bitmap_writer_buildFunction · 0.85
bitmap_writer_finishFunction · 0.85
strbuf_releaseFunction · 0.85
bitmap_writer_freeFunction · 0.85

Tested by

no test coverage detected