Skip to content

Commit d334107

Browse files
derrickstoleegitster
authored andcommitted
maintenance: core.commitGraph=false prevents writes
Recently, a user had an issue due to combining fetch.writeCommitGraph=true with core.commitGraph=false. The root bug has been resolved by preventing commit-graph writes when core.commitGraph is disabled. This happens inside the 'git commit-graph write' command, but we can be more aware of this situation and prevent that process from ever starting in the 'commit-graph' maintenance task. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8f80180 commit d334107

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

builtin/gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,10 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts)
813813

814814
static int maintenance_task_commit_graph(struct maintenance_run_opts *opts)
815815
{
816+
prepare_repo_settings(the_repository);
817+
if (!the_repository->settings.core_commit_graph)
818+
return 0;
819+
816820
close_object_store(the_repository->objects);
817821
if (run_write_commit_graph(opts)) {
818822
error(_("failed to write commit-graph"));

t/t7900-maintenance.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ test_expect_success 'run --task=<task>' '
5252
test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt
5353
'
5454

55+
test_expect_success 'core.commitGraph=false prevents write process' '
56+
GIT_TRACE2_EVENT="$(pwd)/no-commit-graph.txt" \
57+
git -c core.commitGraph=false maintenance run \
58+
--task=commit-graph 2>/dev/null &&
59+
test_subcommand ! git commit-graph write --split --reachable --no-progress \
60+
<no-commit-graph.txt
61+
'
62+
5563
test_expect_success 'commit-graph auto condition' '
5664
COMMAND="maintenance run --task=commit-graph --auto --quiet" &&
5765

0 commit comments

Comments
 (0)