From 135a7123755bfdde05da18012bebd2776f82b26c Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 18 Jun 2019 11:14:28 -0700 Subject: commit-graph: add --split option to builtin Add a new "--split" option to the 'git commit-graph write' subcommand. This option allows the optional behavior of writing a commit-graph chain. The current behavior will add a tip commit-graph containing any commits that are not in the existing commit-graph or commit-graph chain. Later changes will allow merging the chain and expiring out-dated files. Add a new test script (t5324-split-commit-graph.sh) that demonstrates this behavior. Helped-by: Johannes Schindelin Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- commit-graph.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'commit-graph.c') diff --git a/commit-graph.c b/commit-graph.c index f0698b0599..1224309e5f 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1472,12 +1472,16 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) } if (ctx->base_graph_name) { - result = rename(ctx->base_graph_name, - ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]); + const char *dest = ctx->commit_graph_filenames_after[ + ctx->num_commit_graphs_after - 2]; - if (result) { - error(_("failed to rename base commit-graph file")); - return -1; + if (strcmp(ctx->base_graph_name, dest)) { + result = rename(ctx->base_graph_name, dest); + + if (result) { + error(_("failed to rename base commit-graph file")); + return -1; + } } } else { char *graph_name = get_commit_graph_filename(ctx->obj_dir); -- cgit v1.2.3