]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
Merge branch 'dl/apply-3way-diff3'
[thirdparty/git.git] / commit-graph.c
index c3ba79fe4e11f5b47cf05e29c68a868d29ade1f9..0aea7b2ae5263899b2b93e5acbcd1f391814e0f3 100644 (file)
@@ -41,6 +41,9 @@
 #define GRAPH_MIN_SIZE (GRAPH_HEADER_SIZE + 4 * GRAPH_CHUNKLOOKUP_WIDTH \
                        + GRAPH_FANOUT_SIZE + the_hash_algo->rawsz)
 
+/* Remember to update object flag allocation in object.h */
+#define REACHABLE       (1u<<15)
+
 char *get_commit_graph_filename(const char *obj_dir)
 {
        char *filename = xstrfmt("%s/info/commit-graph", obj_dir);
@@ -846,12 +849,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;
 
@@ -1023,11 +1033,11 @@ static void add_missing_parents(struct write_commit_graph_context *ctx, struct c
 {
        struct commit_list *parent;
        for (parent = commit->parents; parent; parent = parent->next) {
-               if (!(parent->item->object.flags & UNINTERESTING)) {
+               if (!(parent->item->object.flags & REACHABLE)) {
                        ALLOC_GROW(ctx->oids.list, ctx->oids.nr + 1, ctx->oids.alloc);
                        oidcpy(&ctx->oids.list[ctx->oids.nr], &(parent->item->object.oid));
                        ctx->oids.nr++;
-                       parent->item->object.flags |= UNINTERESTING;
+                       parent->item->object.flags |= REACHABLE;
                }
        }
 }
@@ -1045,7 +1055,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
                display_progress(ctx->progress, i + 1);
                commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
                if (commit)
-                       commit->object.flags |= UNINTERESTING;
+                       commit->object.flags |= REACHABLE;
        }
        stop_progress(&ctx->progress);
 
@@ -1082,7 +1092,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
                commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
 
                if (commit)
-                       commit->object.flags &= ~UNINTERESTING;
+                       commit->object.flags &= ~REACHABLE;
        }
        stop_progress(&ctx->progress);
 }
@@ -1526,8 +1536,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;
@@ -1539,6 +1549,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 ||