summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-10-09 20:53:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-09 21:16:32 (GMT)
commit85102ac71b98466eaa2b9b5a568c3a1de736202d (patch)
treed08e8527f9d4693432b997613f55693ae7bcbce5 /commit-graph.c
parent150f11574bcb53a6880a03593ff46d6b25fa03a1 (diff)
downloadgit-85102ac71b98466eaa2b9b5a568c3a1de736202d.zip
git-85102ac71b98466eaa2b9b5a568c3a1de736202d.tar.gz
git-85102ac71b98466eaa2b9b5a568c3a1de736202d.tar.bz2
commit-graph: don't write commit-graph when disabled
The core.commitGraph config setting can be set to 'false' to prevent parsing commits from the commit-graph file(s). This causes an issue when trying to write with "--split" which needs to distinguish between commits that are in the existing commit-graph layers and commits that are not. The existing mechanism uses parse_commit() and follows by checking if there is a 'graph_pos' that shows the commit was parsed from the commit-graph file. When core.commitGraph=false, we do not parse the commits from the commit-graph and 'graph_pos' indicates that no commits are in the existing file. The --split logic moves forward creating a new layer on top that holds all reachable commits, then possibly merges down into those layers, resulting in duplicate commits. The previous change makes that merging process more robust to such a situation in case it happens in the written commit-graph data. The easy answer here is to avoid writing a commit-graph if reading the commit-graph is disabled. Since the resulting commit-graph will would not be read by subsequent Git processes. This is more natural than forcing core.commitGraph to be true for the 'write' process. Reported-by: Thomas Braun <thomas.braun@virtuell-zuhause.de> Helped-by: Jeff King <peff@peff.net> Helped-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/commit-graph.c b/commit-graph.c
index d3e2ee4..33b3a20 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2062,6 +2062,11 @@ int write_commit_graph(struct object_directory *odb,
int res = 0;
int replace = 0;
+ prepare_repo_settings(the_repository);
+ if (!the_repository->settings.core_commit_graph) {
+ warning(_("attempting to write a commit-graph, but 'core.commitGraph' is disabled"));
+ return 0;
+ }
if (!commit_graph_compatible(the_repository))
return 0;