]> git.ipfire.org Git - thirdparty/git.git/commitdiff
maintenance: core.commitGraph=false prevents writes
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 12 Oct 2020 13:28:34 +0000 (13:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Oct 2020 19:13:21 +0000 (12:13 -0700)
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>
builtin/gc.c
t/t7900-maintenance.sh

index 12ddb68bba9ada6ec828c61b862668bd7947f6ff..e80331c4e2862d35cc3f1045edba78bdbd5b6b4d 100644 (file)
@@ -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"));
index ee1f4a7ae440c9aa13c9e00893198971f0e3852b..9776154a2a586bc9d4e55edd3afb46fd51e3c5b3 100755 (executable)
@@ -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" &&