summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-commit-graph.txt4
-rw-r--r--commit-graph.c5
-rwxr-xr-xt/t5324-split-commit-graph.sh3
3 files changed, 10 insertions, 2 deletions
diff --git a/Documentation/git-commit-graph.txt b/Documentation/git-commit-graph.txt
index 8ca1764d3d..456df73539 100644
--- a/Documentation/git-commit-graph.txt
+++ b/Documentation/git-commit-graph.txt
@@ -39,7 +39,9 @@ COMMANDS
--------
'write'::
-Write a commit-graph file based on the commits found in packfiles.
+Write a commit-graph file based on the commits found in packfiles. If
+the config option `core.commitGraph` is disabled, then this command will
+output a warning, then return success without writing a commit-graph file.
+
With the `--stdin-packs` option, generate the new commit graph by
walking objects only in the specified pack-indexes. (Cannot be combined
diff --git a/commit-graph.c b/commit-graph.c
index d3e2ee4bf2..33b3a2086c 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;
diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh
index 82f22c8c44..08adb418d0 100755
--- a/t/t5324-split-commit-graph.sh
+++ b/t/t5324-split-commit-graph.sh
@@ -440,8 +440,9 @@ test_expect_success '--split=replace with partial Bloom data' '
test_expect_success 'prevent regression for duplicate commits across layers' '
git init dup &&
- git -C dup config core.commitGraph false &&
git -C dup commit --allow-empty -m one &&
+ git -C dup -c core.commitGraph=false commit-graph write --split=no-merge --reachable 2>err &&
+ test_i18ngrep "attempting to write a commit-graph" err &&
git -C dup commit-graph write --split=no-merge --reachable &&
git -C dup commit --allow-empty -m two &&
git -C dup commit-graph write --split=no-merge --reachable &&