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

Function parse_commit_graph

commit-graph.c:373–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373struct commit_graph *parse_commit_graph(struct repository *r,
374 void *graph_map, size_t graph_size)
375{
376 const unsigned char *data;
377 struct commit_graph *graph;
378 uint32_t graph_signature;
379 unsigned char graph_version, hash_version;
380 struct chunkfile *cf = NULL;
381
382 if (!graph_map)
383 return NULL;
384
385 if (graph_size < graph_min_size(r->hash_algo))
386 return NULL;
387
388 data = (const unsigned char *)graph_map;
389
390 graph_signature = get_be32(data);
391 if (graph_signature != GRAPH_SIGNATURE) {
392 error(_("commit-graph signature %X does not match signature %X"),
393 graph_signature, GRAPH_SIGNATURE);
394 return NULL;
395 }
396
397 graph_version = *(unsigned char*)(data + 4);
398 if (graph_version != GRAPH_VERSION) {
399 error(_("commit-graph version %X does not match version %X"),
400 graph_version, GRAPH_VERSION);
401 return NULL;
402 }
403
404 hash_version = *(unsigned char*)(data + 5);
405 if (hash_version != oid_version(r->hash_algo)) {
406 error(_("commit-graph hash version %X does not match version %X"),
407 hash_version, oid_version(r->hash_algo));
408 return NULL;
409 }
410
411 graph = alloc_commit_graph();
412
413 graph->hash_algo = r->hash_algo;
414 graph->num_chunks = *(unsigned char*)(data + 6);
415 graph->data = graph_map;
416 graph->data_len = graph_size;
417
418 if (graph_size < GRAPH_HEADER_SIZE +
419 (graph->num_chunks + 1) * CHUNK_TOC_ENTRY_SIZE +
420 GRAPH_FANOUT_SIZE + r->hash_algo->rawsz) {
421 error(_("commit-graph file is too small to hold %u chunks"),
422 graph->num_chunks);
423 free(graph);
424 return NULL;
425 }
426
427 cf = init_chunkfile(NULL);
428
429 if (read_table_of_contents(cf, graph->data, graph_size,
430 GRAPH_HEADER_SIZE, graph->num_chunks, 1))

Callers 2

LLVMFuzzerTestOneInputFunction · 0.85

Calls 13

graph_min_sizeFunction · 0.85
get_be32Function · 0.85
errorFunction · 0.85
oid_versionFunction · 0.85
alloc_commit_graphFunction · 0.85
init_chunkfileFunction · 0.85
read_table_of_contentsFunction · 0.85
read_chunkFunction · 0.85
pair_chunkFunction · 0.85
prepare_repo_settingsFunction · 0.85
init_bloom_filtersFunction · 0.85
oidreadFunction · 0.85

Tested by

no test coverage detected