commit-graph: clean up chains after flattened write
[gitweb.git] / commit-graph.c
index f33f4fe0091bf831d6044a2d5394f335542e3e08..3599ae664d70eaf666a8df9fc79fcd140f8771e5 100644 (file)
@@ -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);