When an obsolete link in the commit graph chain is deleted, and trace2 is enabled, trace a message that it is deleted, along with the list of links before and after the current chain refresh. The messages are emitted using trace2_data_string() and not trace2_printf() because the latter is not implemented for some trace targets. Signed-off-by: Jonathan Tan <jonathantanmy@xxxxxxxxxx> --- This patch is just for informational purposes for people who have the same problem and/or want to help diagnose. I've tested that this produces the expected trace2 messages using: git commit-graph write --reachable --split=replace > It is _possible_ that something like a case switch or a symlink > could be causing a problem here. That's where I would look on > the affected systems. Indeed a symlink is present - the affected repositories are using the git-repo [1] local mirror feature, which causes .git/objects (among other things) to be a symlink - but I couldn't figure out how this symlink would cause problems. In particular, looking at the code, all relevant filenames seem to be constructed from ctx->odb->path, so no matter which names were used to get to the object directory, all names are built from those names, and this seems to be true in practice as well. So I've added some trace2 messages (in this patch), and let's see if I can figure out what's going on. I'll write back if I find something. [1] https://gerrit.googlesource.com/git-repo --- commit-graph.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/commit-graph.c b/commit-graph.c index 328ab06fd4..b5bd2ac6de 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -2009,6 +2009,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx) struct dirent *de; size_t dirnamelen; timestamp_t expire_time = time(NULL); + int commit_graph_deleted = 0; if (ctx->split_opts && ctx->split_opts->expire_time) expire_time = ctx->split_opts->expire_time; @@ -2050,8 +2051,38 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx) } } - if (!found) + if (!found) { + if (trace2_is_enabled()) { + struct strbuf message = STRBUF_INIT; + + strbuf_addf(&message, "Deleting '%s' because it is not in [", path.buf); + for (i = 0; i < ctx->num_commit_graphs_after; i++) { + if (i != 0) + strbuf_addstr(&message, ", "); + strbuf_addf(&message, "'%s'", ctx->commit_graph_filenames_after[i]); + } + strbuf_addstr(&message, "]"); + trace2_data_string("commit-graph", the_repository, "graph-deletion", message.buf); + strbuf_release(&message); + commit_graph_deleted = 1; + } unlink(path.buf); + } + } + + if (commit_graph_deleted) { + struct strbuf message = STRBUF_INIT; + uint32_t i; + + strbuf_addstr(&message, "The commit graphs before were ["); + for (i = 0; i < ctx->num_commit_graphs_before; i++) { + if (i != 0) + strbuf_addstr(&message, ", "); + strbuf_addf(&message, "'%s'", ctx->commit_graph_filenames_before[i]); + } + strbuf_addstr(&message, "]"); + trace2_data_string("commit-graph", the_repository, "graph-before", message.buf); + strbuf_release(&message); } out: -- 2.28.0.rc0.105.gf9edc3c819-goog