diff options
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/commit-graph.c b/commit-graph.c index fa0760c430..fe954ab5f8 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -297,8 +297,10 @@ struct commit_graph *parse_commit_graph(void *graph_map, int fd, hashcpy(graph->oid.hash, graph->data + graph->data_len - graph->hash_len); - if (verify_commit_graph_lite(graph)) + if (verify_commit_graph_lite(graph)) { + free(graph); return NULL; + } return graph; } @@ -589,6 +591,11 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g, item->generation = get_be32(commit_data + g->hash_len + 8) >> 2; } +static inline void set_commit_tree(struct commit *c, struct tree *t) +{ + c->maybe_tree = t; +} + static int fill_commit_in_graph(struct repository *r, struct commit *item, struct commit_graph *g, uint32_t pos) @@ -617,7 +624,7 @@ static int fill_commit_in_graph(struct repository *r, item->object.parsed = 1; - item->maybe_tree = NULL; + set_commit_tree(item, NULL); date_high = get_be32(commit_data + g->hash_len + 8) & 0x3; date_low = get_be32(commit_data + g->hash_len + 12); @@ -719,7 +726,7 @@ static struct tree *load_tree_for_commit(struct repository *r, GRAPH_DATA_WIDTH * (c->graph_pos - g->num_commits_in_base); hashcpy(oid.hash, commit_data); - c->maybe_tree = lookup_tree(r, &oid); + set_commit_tree(c, lookup_tree(r, &oid)); return c->maybe_tree; } @@ -1630,7 +1637,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx) num_parents++; if (num_parents > 2) - ctx->num_extra_edges += num_parents - 2; + ctx->num_extra_edges += num_parents - 1; } } @@ -1990,7 +1997,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags) hashcpy(cur_oid.hash, g->chunk_oid_lookup + g->hash_len * i); graph_commit = lookup_commit(r, &cur_oid); - odb_commit = (struct commit *)create_object(r, cur_oid.hash, alloc_commit_node(r)); + odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r)); if (parse_commit_internal(odb_commit, 0, 0)) { graph_report(_("failed to parse commit %s from object database for commit-graph"), oid_to_hex(&cur_oid)); |