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

Function bitmap_write

t/helper/test-bitmap.c:72–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static int bitmap_write(const char *basename)
73{
74 struct packed_git *p = NULL;
75 struct packing_data packed = { 0 };
76 struct bitmap_writer writer;
77 struct pack_idx_entry **index;
78 struct strbuf buf = STRBUF_INIT;
79 uint32_t i;
80
81 prepare_repo_settings(the_repository);
82 repo_for_each_pack(the_repository, p) {
83 if (!strcmp(pack_basename(p), basename))
84 break;
85 }
86
87 if (!p)
88 die("could not find pack '%s'", basename);
89
90 if (open_pack_index(p))
91 die("cannot open pack index for '%s'", p->pack_name);
92
93 prepare_packing_data(the_repository, &packed);
94
95 for_each_object_in_pack(p, add_packed_object, &packed,
96 ODB_FOR_EACH_OBJECT_PACK_ORDER);
97
98 /*
99 * Build the index array now that data.packed.objects[] is
100 * fully allocated (packlist_alloc() may have reallocated it
101 * during the loop above).
102 */
103 ALLOC_ARRAY(index, p->num_objects);
104 for (i = 0; i < p->num_objects; i++)
105 index[i] = &packed.objects[i].idx;
106
107 bitmap_writer_init(&writer, the_repository, &packed, NULL);
108 bitmap_writer_build_type_index(&writer, index);
109
110 while (strbuf_getline_lf(&buf, stdin) != EOF) {
111 struct object_id oid;
112 struct commit *c;
113
114 if (get_oid_hex(buf.buf, &oid))
115 die("invalid OID: %s", buf.buf);
116
117 c = lookup_commit(the_repository, &oid);
118 if (!c || repo_parse_commit(the_repository, c))
119 die("could not parse commit %s", buf.buf);
120
121 bitmap_writer_push_commit(&writer, c, 0);
122 }
123
124 select_pseudo_merges(&writer);
125 if (bitmap_writer_build(&writer) < 0)
126 die("failed to build bitmaps");
127
128 bitmap_writer_set_checksum(&writer, p->hash);
129

Callers 1

cmd__bitmapFunction · 0.85

Calls 15

prepare_repo_settingsFunction · 0.85
pack_basenameFunction · 0.85
open_pack_indexFunction · 0.85
prepare_packing_dataFunction · 0.85
for_each_object_in_packFunction · 0.85
bitmap_writer_initFunction · 0.85
strbuf_getline_lfFunction · 0.85
get_oid_hexFunction · 0.85
lookup_commitFunction · 0.85
repo_parse_commitFunction · 0.85

Tested by

no test coverage detected