Merge branch 'jc/denoise-rm-to-resolve'
[gitweb.git] / commit-graph.c
index c91e6f0fb821582706b3c9ee232da1335ea7427d..b3c4de79b6da4502726dbec5e21b11734d76e28e 100644 (file)
@@ -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;
 }
@@ -588,6 +590,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)
@@ -616,7 +623,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);
@@ -718,7 +725,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;
 }
@@ -1988,7 +1995,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));