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

Function verify_one_commit_graph

commit-graph.c:2764–2914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2762}
2763
2764static int verify_one_commit_graph(struct commit_graph *g,
2765 struct progress *progress,
2766 uint64_t *seen)
2767{
2768 struct repository *r = g->odb_source->odb->repo;
2769 uint32_t i, cur_fanout_pos = 0;
2770 struct object_id prev_oid, cur_oid;
2771 struct commit *seen_gen_zero = NULL;
2772 struct commit *seen_gen_non_zero = NULL;
2773
2774 if (!commit_graph_checksum_valid(g)) {
2775 graph_report(_("the commit-graph file has incorrect checksum and is likely corrupt"));
2776 verify_commit_graph_error = VERIFY_COMMIT_GRAPH_ERROR_HASH;
2777 }
2778
2779 for (i = 0; i < g->num_commits; i++) {
2780 struct commit *graph_commit;
2781
2782 oidread(&cur_oid, g->chunk_oid_lookup + st_mult(g->hash_algo->rawsz, i),
2783 g->hash_algo);
2784
2785 if (i && oidcmp(&prev_oid, &cur_oid) >= 0)
2786 graph_report(_("commit-graph has incorrect OID order: %s then %s"),
2787 oid_to_hex(&prev_oid),
2788 oid_to_hex(&cur_oid));
2789
2790 oidcpy(&prev_oid, &cur_oid);
2791
2792 while (cur_oid.hash[0] > cur_fanout_pos) {
2793 uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
2794
2795 if (i != fanout_value)
2796 graph_report(_("commit-graph has incorrect fanout value: fanout[%d] = %u != %u"),
2797 cur_fanout_pos, fanout_value, i);
2798 cur_fanout_pos++;
2799 }
2800
2801 graph_commit = lookup_commit(r, &cur_oid);
2802 if (!parse_commit_in_graph_one(g, graph_commit))
2803 graph_report(_("failed to parse commit %s from commit-graph"),
2804 oid_to_hex(&cur_oid));
2805 }
2806
2807 while (cur_fanout_pos < 256) {
2808 uint32_t fanout_value = get_be32(g->chunk_oid_fanout + cur_fanout_pos);
2809
2810 if (g->num_commits != fanout_value)
2811 graph_report(_("commit-graph has incorrect fanout value: fanout[%d] = %u != %u"),
2812 cur_fanout_pos, fanout_value, i);
2813
2814 cur_fanout_pos++;
2815 }
2816
2817 if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
2818 return verify_commit_graph_error;
2819
2820 for (i = 0; i < g->num_commits; i++) {
2821 struct commit *graph_commit, *odb_commit;

Callers 1

verify_commit_graphFunction · 0.85

Calls 15

graph_reportFunction · 0.85
oidreadFunction · 0.85
st_multFunction · 0.85
oidcmpFunction · 0.85
oid_to_hexFunction · 0.85
oidcpyFunction · 0.85
get_be32Function · 0.85
lookup_commitFunction · 0.85
display_progressFunction · 0.85
create_objectFunction · 0.85

Tested by

no test coverage detected