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>
This commit is contained in:
committed by
Junio C Hamano
parent
9bda846789
commit
96af91d410
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user