]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
Merge branch 'js/azure-pipelines-msvc'
[thirdparty/git.git] / commit-graph.c
index 394908ba9b1d78624bb4a869a98d90777938e325..fc4a43b8d6eb112f1c845882b32411c37a402e3b 100644 (file)
@@ -846,12 +846,19 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
 
        while (list < last) {
                struct commit_list *parent;
+               struct object_id *tree;
                int edge_value;
                uint32_t packedDate[2];
                display_progress(ctx->progress, ++ctx->progress_cnt);
 
-               parse_commit_no_graph(*list);
-               hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
+               if (parse_commit_no_graph(*list))
+                       die(_("unable to parse commit %s"),
+                               oid_to_hex(&(*list)->object.oid));
+               tree = get_commit_tree_oid(*list);
+               if (!tree)
+                       die(_("unable to get tree for %s"),
+                               oid_to_hex(&(*list)->object.oid));
+               hashwrite(f, tree->hash, hash_len);
 
                parent = (*list)->parents;
 
@@ -1286,7 +1293,6 @@ static uint32_t count_distinct_commits(struct write_commit_graph_context *ctx)
 static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
 {
        uint32_t i;
-       struct commit_list *parent;
 
        ctx->num_extra_edges = 0;
        if (ctx->report_progress)
@@ -1294,7 +1300,8 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
                        _("Finding extra edges in commit graph"),
                        ctx->oids.nr);
        for (i = 0; i < ctx->oids.nr; i++) {
-               int num_parents = 0;
+               unsigned int num_parents;
+
                display_progress(ctx->progress, i + 1);
                if (i > 0 && oideq(&ctx->oids.list[i - 1], &ctx->oids.list[i]))
                        continue;
@@ -1308,10 +1315,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
 
                parse_commit_no_graph(ctx->commits.list[ctx->commits.nr]);
 
-               for (parent = ctx->commits.list[ctx->commits.nr]->parents;
-                    parent; parent = parent->next)
-                       num_parents++;
-
+               num_parents = commit_list_count(ctx->commits.list[ctx->commits.nr]->parents);
                if (num_parents > 2)
                        ctx->num_extra_edges += num_parents - 1;
 
@@ -1529,8 +1533,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
 
 static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
 {
-       struct commit_graph *g = ctx->r->objects->commit_graph;
-       uint32_t num_commits = ctx->commits.nr;
+       struct commit_graph *g;
+       uint32_t num_commits;
        uint32_t i;
 
        int max_commits = 0;
@@ -1542,6 +1546,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
        }
 
        g = ctx->r->objects->commit_graph;
+       num_commits = ctx->commits.nr;
        ctx->num_commit_graphs_after = ctx->num_commit_graphs_before + 1;
 
        while (g && (g->num_commits <= size_mult * num_commits ||
@@ -1623,8 +1628,7 @@ static int commit_compare(const void *_a, const void *_b)
 
 static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
 {
-       uint32_t i, num_parents;
-       struct commit_list *parent;
+       uint32_t i;
 
        if (ctx->report_progress)
                ctx->progress = start_delayed_progress(
@@ -1642,10 +1646,9 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
                        die(_("unexpected duplicate commit id %s"),
                            oid_to_hex(&ctx->commits.list[i]->object.oid));
                } else {
-                       num_parents = 0;
-                       for (parent = ctx->commits.list[i]->parents; parent; parent = parent->next)
-                               num_parents++;
+                       unsigned int num_parents;
 
+                       num_parents = commit_list_count(ctx->commits.list[i]->parents);
                        if (num_parents > 2)
                                ctx->num_extra_edges += num_parents - 1;
                }
@@ -1999,8 +2002,10 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
        if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
                return verify_commit_graph_error;
 
-       progress = start_progress(_("Verifying commits in commit graph"),
-                                 g->num_commits);
+       if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
+               progress = start_progress(_("Verifying commits in commit graph"),
+                                       g->num_commits);
+
        for (i = 0; i < g->num_commits; i++) {
                struct commit *graph_commit, *odb_commit;
                struct commit_list *graph_parents, *odb_parents;