diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-06-27 09:24:36 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-27 10:27:05 -0700 |
commit | 96af91d410c70ab750a9a1ecdf858c9ec46be767 (patch) | |
tree | cd0d76aa65fbd90cfea6811dd6da5122c00146a8 /commit-graph.c | |
parent | commit-graph: verify corrupt OID fanout and lookup (diff) | |
download | tgif-96af91d410c70ab750a9a1ecdf858c9ec46be767.tar.xz |
commit-graph: verify objects exist
In the 'verify' subcommand, load commits directly from the object
database to ensure they exist. Parse by skipping the commit-graph.
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 | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/commit-graph.c b/commit-graph.c index b34f62f277..282cdb4aec 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -11,6 +11,7 @@ #include "sha1-lookup.h" #include "commit-graph.h" #include "object-store.h" +#include "alloc.h" #define GRAPH_SIGNATURE 0x43475048 /* "CGPH" */ #define GRAPH_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */ @@ -242,6 +243,7 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g, { struct commit *c; struct object_id oid; + hashcpy(oid.hash, g->chunk_oid_lookup + g->hash_len * pos); c = lookup_commit(&oid); if (!c) @@ -893,5 +895,21 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g) cur_fanout_pos++; } + if (verify_commit_graph_error) + return verify_commit_graph_error; + + for (i = 0; i < g->num_commits; i++) { + struct commit *odb_commit; + + hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); + + 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; + } + } + return verify_commit_graph_error; } |