diff options
-rw-r--r-- | builtin/gc.c | 4 | ||||
-rwxr-xr-x | t/t7900-maintenance.sh | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/builtin/gc.c b/builtin/gc.c index 12ddb68bba..e80331c4e2 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -813,6 +813,10 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts) static int maintenance_task_commit_graph(struct maintenance_run_opts *opts) { + prepare_repo_settings(the_repository); + if (!the_repository->settings.core_commit_graph) + return 0; + close_object_store(the_repository->objects); if (run_write_commit_graph(opts)) { error(_("failed to write commit-graph")); diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index ee1f4a7ae4..9776154a2a 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -52,6 +52,14 @@ test_expect_success 'run --task=<task>' ' test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt ' +test_expect_success 'core.commitGraph=false prevents write process' ' + GIT_TRACE2_EVENT="$(pwd)/no-commit-graph.txt" \ + git -c core.commitGraph=false maintenance run \ + --task=commit-graph 2>/dev/null && + test_subcommand ! git commit-graph write --split --reachable --no-progress \ + <no-commit-graph.txt +' + test_expect_success 'commit-graph auto condition' ' COMMAND="maintenance run --task=commit-graph --auto --quiet" && |