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

Function write_pseudo_merges

pack-bitmap-write.c:1162–1273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160}
1161
1162static void write_pseudo_merges(struct bitmap_writer *writer,
1163 struct hashfile *f)
1164{
1165 struct oid_array commits = OID_ARRAY_INIT;
1166 off_t *pseudo_merge_ofs = NULL;
1167 off_t start, table_start, next_ext;
1168
1169 uint32_t base = bitmap_writer_nr_selected_commits(writer);
1170 size_t i, j = 0;
1171
1172 CALLOC_ARRAY(pseudo_merge_ofs, writer->pseudo_merges_nr);
1173
1174 start = hashfile_total(f);
1175
1176 for (i = 0; i < writer->pseudo_merges_nr; i++) {
1177 struct bitmapped_commit *merge = &writer->selected[base + i];
1178
1179 if (!merge->pseudo_merge)
1180 BUG("found non-pseudo merge commit at %"PRIuMAX, (uintmax_t)i);
1181
1182 if (!merge->pseudo_merge_parents || !merge->bitmap)
1183 BUG("missing pseudo-merge bitmap for commit %s",
1184 oid_to_hex(&merge->commit->object.oid));
1185
1186 pseudo_merge_ofs[i] = hashfile_total(f);
1187 dump_bitmap(f, merge->pseudo_merge_parents);
1188 dump_bitmap(f, merge->bitmap);
1189 }
1190
1191 next_ext = st_add(hashfile_total(f),
1192 st_mult(kh_size(writer->pseudo_merge_commits),
1193 sizeof(uint32_t) + sizeof(uint64_t)));
1194
1195 table_start = hashfile_total(f);
1196
1197 commits.alloc = kh_size(writer->pseudo_merge_commits);
1198 CALLOC_ARRAY(commits.oid, commits.alloc);
1199
1200 for (i = kh_begin(writer->pseudo_merge_commits); i != kh_end(writer->pseudo_merge_commits); i++) {
1201 if (!kh_exist(writer->pseudo_merge_commits, i))
1202 continue;
1203 oid_array_append(&commits, &kh_key(writer->pseudo_merge_commits, i));
1204 }
1205
1206 /*
1207 * Sort the commits by their bit position so that the lookup
1208 * table can be binary searched by the reader (see
1209 * find_pseudo_merge()).
1210 */
1211 QSORT_S(commits.oid, commits.nr, pseudo_merge_commit_pos_cmp, writer);
1212
1213 /* write lookup table (non-extended) */
1214 for (i = 0; i < commits.nr; i++) {
1215 int hash_pos;
1216 struct pseudo_merge_commit_idx *c;
1217
1218 hash_pos = kh_get_oid_map(writer->pseudo_merge_commits,
1219 commits.oid[i]);

Callers 1

bitmap_writer_finishFunction · 0.85

Calls 12

hashfile_totalFunction · 0.85
oid_to_hexFunction · 0.85
dump_bitmapFunction · 0.85
st_addFunction · 0.85
st_multFunction · 0.85
oid_array_appendFunction · 0.85
hashwrite_be32Function · 0.85
find_object_posFunction · 0.85
hashwrite_be64Function · 0.85
oid_array_clearFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected