| 568 | } |
| 569 | |
| 570 | static int add_graph_to_chain(struct commit_graph *g, |
| 571 | struct commit_graph *chain, |
| 572 | struct object_id *oids, |
| 573 | int n) |
| 574 | { |
| 575 | struct commit_graph *cur_g = chain; |
| 576 | |
| 577 | if (n && !g->chunk_base_graphs) { |
| 578 | warning(_("commit-graph has no base graphs chunk")); |
| 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | if (g->chunk_base_graphs_size / g->hash_algo->rawsz < n) { |
| 583 | warning(_("commit-graph base graphs chunk is too small")); |
| 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | while (n) { |
| 588 | n--; |
| 589 | |
| 590 | if (!cur_g || |
| 591 | !oideq(&oids[n], &cur_g->oid) || |
| 592 | !hasheq(oids[n].hash, g->chunk_base_graphs + st_mult(g->hash_algo->rawsz, n), |
| 593 | g->hash_algo)) { |
| 594 | warning(_("commit-graph chain does not match")); |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | cur_g = cur_g->base_graph; |
| 599 | } |
| 600 | |
| 601 | if (chain) { |
| 602 | if (unsigned_add_overflows(chain->num_commits, |
| 603 | chain->num_commits_in_base)) { |
| 604 | warning(_("commit count in base graph too high: %"PRIuMAX), |
| 605 | (uintmax_t)chain->num_commits_in_base); |
| 606 | return 0; |
| 607 | } |
| 608 | g->num_commits_in_base = chain->num_commits + chain->num_commits_in_base; |
| 609 | } |
| 610 | |
| 611 | g->base_graph = chain; |
| 612 | |
| 613 | return 1; |
| 614 | } |
| 615 | |
| 616 | int open_commit_graph_chain(const char *chain_file, |
| 617 | int *fd, struct stat *st, |
no test coverage detected