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

Function write_graph_chunk_data

commit-graph.c:1219–1320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1217}
1218
1219static int write_graph_chunk_data(struct hashfile *f,
1220 void *data)
1221{
1222 struct write_commit_graph_context *ctx = data;
1223 struct commit **list = ctx->commits.items;
1224 struct commit **last = ctx->commits.items + ctx->commits.nr;
1225 uint32_t num_extra_edges = 0;
1226
1227 while (list < last) {
1228 struct commit_list *parent;
1229 struct object_id *tree;
1230 int edge_value;
1231 uint32_t packedDate[2];
1232 display_progress(ctx->progress, ++ctx->progress_cnt);
1233
1234 if (repo_parse_commit_no_graph(ctx->r, *list))
1235 die(_("unable to parse commit %s"),
1236 oid_to_hex(&(*list)->object.oid));
1237 tree = get_commit_tree_oid(*list);
1238 hashwrite(f, tree->hash, ctx->r->hash_algo->rawsz);
1239
1240 parent = (*list)->parents;
1241
1242 if (!parent)
1243 edge_value = GRAPH_PARENT_NONE;
1244 else {
1245 edge_value = oid_pos(&parent->item->object.oid,
1246 ctx->commits.items,
1247 ctx->commits.nr,
1248 commit_to_oid);
1249
1250 if (edge_value >= 0)
1251 edge_value += ctx->new_num_commits_in_base;
1252 else if (ctx->new_base_graph) {
1253 uint32_t pos;
1254 if (find_commit_pos_in_graph(parent->item,
1255 ctx->new_base_graph,
1256 &pos))
1257 edge_value = pos;
1258 }
1259
1260 if (edge_value < 0)
1261 BUG("missing parent %s for commit %s",
1262 oid_to_hex(&parent->item->object.oid),
1263 oid_to_hex(&(*list)->object.oid));
1264 }
1265
1266 hashwrite_be32(f, edge_value);
1267
1268 if (parent)
1269 parent = parent->next;
1270
1271 if (!parent)
1272 edge_value = GRAPH_PARENT_NONE;
1273 else if (parent->next)
1274 edge_value = GRAPH_EXTRA_EDGES_NEEDED | num_extra_edges;
1275 else {
1276 edge_value = oid_pos(&parent->item->object.oid,

Callers

nothing calls this directly

Calls 9

display_progressFunction · 0.85
oid_to_hexFunction · 0.85
get_commit_tree_oidFunction · 0.85
hashwriteFunction · 0.85
oid_posFunction · 0.85
find_commit_pos_in_graphFunction · 0.85
hashwrite_be32Function · 0.85
dieFunction · 0.70

Tested by

no test coverage detected