commit-graph: clean up chains after flattened write
If we write a commit-graph file without the split option, then we write to $OBJDIR/info/commit-graph and start to ignore the chains in $OBJDIR/info/commit-graphs/. Unlink the commit-graph-chain file and expire the graph-{hash}.graph files in $OBJDIR/info/commit-graphs/ during every write. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3da4b609bb
commit
ba41112a63
@ -1687,6 +1687,12 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
|
|||||||
|
|
||||||
if (ctx->split_opts && ctx->split_opts->expire_time)
|
if (ctx->split_opts && ctx->split_opts->expire_time)
|
||||||
expire_time -= 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, ctx->obj_dir);
|
||||||
strbuf_addstr(&path, "/info/commit-graphs");
|
strbuf_addstr(&path, "/info/commit-graphs");
|
||||||
@ -1841,10 +1847,10 @@ int write_commit_graph(const char *obj_dir,
|
|||||||
|
|
||||||
res = write_commit_graph_file(ctx);
|
res = write_commit_graph_file(ctx);
|
||||||
|
|
||||||
if (ctx->split) {
|
if (ctx->split)
|
||||||
mark_commit_graphs(ctx);
|
mark_commit_graphs(ctx);
|
||||||
expire_commit_graphs(ctx);
|
|
||||||
}
|
expire_commit_graphs(ctx);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
free(ctx->graph_name);
|
free(ctx->graph_name);
|
||||||
|
@ -216,6 +216,18 @@ test_expect_success 'test merge stragety constants' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'remove commit-graph-chain file after flattening' '
|
||||||
|
git clone . flatten &&
|
||||||
|
(
|
||||||
|
cd flatten &&
|
||||||
|
test_line_count = 2 $graphdir/commit-graph-chain &&
|
||||||
|
git commit-graph write --reachable &&
|
||||||
|
test_path_is_missing $graphdir/commit-graph-chain &&
|
||||||
|
ls $graphdir >graph-files &&
|
||||||
|
test_line_count = 0 graph-files
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
corrupt_file() {
|
corrupt_file() {
|
||||||
file=$1
|
file=$1
|
||||||
pos=$2
|
pos=$2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user