As support for this setting was deprecated in the last commit print a
warning (or die when WITH_BREAKING_CHANGES is enabled) if it is set.
Avoid bombarding the user with warnings by only printing it (a) when
running commands that call "git commit" and (b) only once per command.
Some scaffolding is added to repo_read_config() to allow it to
detect deprecated config settings and warn about them. As both
"core.commentChar" and "core.commentString" set the comment
character we record which one of them is used and tailor the
warning message appropriately.
Note the odd combination of die_message() followed by die(NULL)
is to allow the next commit to insert a call to advise() in the middle.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committedAug 26, 2025 at 14:35 UTCa0e6aaea7da5134bdc784c6d68d4cc2125865330
index ecd691181f..8af73923d3 100644--- a/repository.c+++ b/repository.c@@ -57,6 +57,7 @@ void initialize_repository(struct repository *repo) repo->parsed_objects = parsed_object_pool_new(repo); ALLOC_ARRAY(repo->index, 1); index_state_init(repo->index, repo);+ repo->check_deprecated_config = true; /* * When a command runs inside a repository, it learns what
repository.h
+3
index 042dc93f0f..5808a5d610 100644--- a/repository.h+++ b/repository.h@@ -161,6 +161,9 @@ struct repository { /* Indicate if a repository has a different 'commondir' from 'gitdir' */ unsigned different_commondir:1;++ /* Should repo_config() check for deprecated settings */+ bool check_deprecated_config; }; #ifdef USE_THE_REPOSITORY_VARIABLE
t/t3404-rebase-interactive.sh
+6-1
index ce0aebb9a7..3b2a46c25c 100755--- a/t/t3404-rebase-interactive.sh+++ b/t/t3404-rebase-interactive.sh@@ -1184,8 +1184,13 @@ test_expect_success !WITH_BREAKING_CHANGES 'rebase -i respects core.commentchar= test_when_finished "git rebase --abort || :" && ( test_set_editor "$(pwd)/copy-edit-script.sh" &&- git rebase -i HEAD^+ git rebase -i HEAD^ 2>err ) &&+ sed -n "s/^warning: //p" err >actual &&+ cat >expect <<-EOF &&+ Support for ${SQ}core.commentChar=auto${SQ} is deprecated and will be removed in Git 3.0+ EOF+ test_cmp expect actual && test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)" '
t/t7502-commit-porcelain.sh
+16-1
index 65b4519a71..a9dc1e416d 100755--- a/t/t7502-commit-porcelain.sh+++ b/t/t7502-commit-porcelain.sh@@ -958,7 +958,12 @@ test_expect_success 'commit --status with custom comment character' ' test_expect_success !WITH_BREAKING_CHANGES 'switch core.commentchar' ' test_commit "#foo" foo &&- GIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend &&+ GIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend 2>err &&+ sed -n "s/^warning: //p" err >actual &&+ cat >expect <<-EOF &&+ Support for ${SQ}core.commentChar=auto${SQ} is deprecated and will be removed in Git 3.0+ EOF+ test_cmp expect actual && test_grep "^; Changes to be committed:" .git/COMMIT_EDITMSG '@@ -982,4 +987,14 @@ EOF ) '+test_expect_success WITH_BREAKING_CHANGES 'core.commentChar=auto is rejected' '+ test_config core.commentChar auto &&+ test_must_fail git rev-parse --git-dir 2>err &&+ sed -n "s/^fatal: //p" err >actual &&+ cat >expect <<-EOF &&+ Support for ${SQ}core.commentChar=auto${SQ} has been removed in Git 3.0+ EOF+ test_cmp expect actual+'+ test_done