diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-06-27 16:24:37 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-27 20:29:10 +0300 |
commit | 2e3c07378f9b777a708e1078a474666a00a8be05 (patch) | |
tree | 80f5cfb68320d014465caf01ba8a2523c2480c28 /commit-graph.c | |
parent | 96af91d410c70ab750a9a1ecdf858c9ec46be767 (diff) |
commit-graph: verify root tree OIDs
The 'verify' subcommand must compare the commit content parsed from the
commit-graph against the content in the object database. Use
lookup_commit() and parse_commit_in_graph_one() to parse the commits
from the graph and compare against a commit that is loaded separately
and parsed directly from the object database.
Add checks for the root tree OID.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/commit-graph.c b/commit-graph.c index 282cdb4aec..17624b90d7 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -866,6 +866,8 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) return verify_commit_graph_error; for (i = 0; i < g->num_commits; i++) { + struct commit *graph_commit; + hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); if (i && oidcmp(&prev_oid, &cur_oid) >= 0) @@ -883,6 +885,11 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) cur_fanout_pos, fanout_value, i); cur_fanout_pos++; } + + graph_commit = lookup_commit(&cur_oid); + if (!parse_commit_in_graph_one(g, graph_commit)) + graph_report("failed to parse %s from commit-graph", + oid_to_hex(&cur_oid)); } while (cur_fanout_pos < 256) { @@ -899,16 +906,24 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) return verify_commit_graph_error; for (i = 0; i < g->num_commits; i++) { - struct commit *odb_commit; + struct commit *graph_commit, *odb_commit; hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); + graph_commit = lookup_commit(&cur_oid); odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r)); if (parse_commit_internal(odb_commit, 0, 0)) { graph_report("failed to parse %s from object database", oid_to_hex(&cur_oid)); continue; } + + if (oidcmp(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid, + get_commit_tree_oid(odb_commit))) + graph_report("root tree OID for commit %s in commit-graph is %s != %s", + oid_to_hex(&cur_oid), + oid_to_hex(get_commit_tree_oid(graph_commit)), + oid_to_hex(get_commit_tree_oid(odb_commit))); } return verify_commit_graph_error; |