commit-graph: test octopus merges with --split
[gitweb.git] / commit-graph.c
index 315088d20531d4443ff3f26a31fac8e81f11ca74..3599ae664d70eaf666a8df9fc79fcd140f8771e5 100644 (file)
@@ -428,7 +428,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
        return graph_chain;
 }
 
-static struct commit_graph *read_commit_graph_one(struct repository *r, const char *obj_dir)
+struct commit_graph *read_commit_graph_one(struct repository *r, const char *obj_dir)
 {
        struct commit_graph *g = load_commit_graph_v1(r, obj_dir);
 
@@ -1687,6 +1687,12 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 
        if (ctx->split_opts && ctx->split_opts->expire_time)
                expire_time -= ctx->split_opts->expire_time;
+       if (!ctx->split) {
+               char *chain_file_name = get_chain_filename(ctx->obj_dir);
+               unlink(chain_file_name);
+               free(chain_file_name);
+               ctx->num_commit_graphs_after = 0;
+       }
 
        strbuf_addstr(&path, ctx->obj_dir);
        strbuf_addstr(&path, "/info/commit-graphs");
@@ -1841,10 +1847,10 @@ int write_commit_graph(const char *obj_dir,
 
        res = write_commit_graph_file(ctx);
 
-       if (ctx->split) {
+       if (ctx->split)
                mark_commit_graphs(ctx);
-               expire_commit_graphs(ctx);
-       }
+
+       expire_commit_graphs(ctx);
 
 cleanup:
        free(ctx->graph_name);
@@ -1887,7 +1893,7 @@ static void graph_report(const char *fmt, ...)
 #define GENERATION_ZERO_EXISTS 1
 #define GENERATION_NUMBER_EXISTS 2
 
-int verify_commit_graph(struct repository *r, struct commit_graph *g)
+int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
 {
        uint32_t i, cur_fanout_pos = 0;
        struct object_id prev_oid, cur_oid, checksum;
@@ -1895,6 +1901,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
        struct hashfile *f;
        int devnull;
        struct progress *progress = NULL;
+       int local_error = 0;
 
        if (!g) {
                graph_report("no commit-graph file loaded");
@@ -1989,6 +1996,9 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
                                break;
                        }
 
+                       /* parse parent in case it is in a base graph */
+                       parse_commit_in_graph_one(r, g, graph_parents->item);
+
                        if (!oideq(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
                                graph_report(_("commit-graph parent for %s is %s != %s"),
                                             oid_to_hex(&cur_oid),
@@ -2040,7 +2050,12 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
        }
        stop_progress(&progress);
 
-       return verify_commit_graph_error;
+       local_error = verify_commit_graph_error;
+
+       if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW) && g->base_graph)
+               local_error |= verify_commit_graph(r, g->base_graph, flags);
+
+       return local_error;
 }
 
 void free_commit_graph(struct commit_graph *g)