]> git.ipfire.org Git - thirdparty/git.git/commit
commit: print advice when core.commentString=auto
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Tue, 26 Aug 2025 13:35:28 +0000 (14:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Aug 2025 15:53:30 +0000 (08:53 -0700)
commitace1bb71503bc53b42ddfd68435c3af0adaf390f
tree97f2f13640367d96367665a1d85aad63fb7f716f
parenta0e6aaea7da5134bdc784c6d68d4cc2125865330
commit: print advice when core.commentString=auto

Add some advice on how to change the config settings when
"core.commentString=auto" or "core.commentChar=auto". The advice
includes instructions for clearing the config setting or setting a
fixed comment string. To try and be as specific as possible, the advice
is customized based on the user's config. If "core.commentString=auto"
is set in the system config and the user does not have write
access then the advice omits the instructions to clear the config
and recommends changing the global config instead. An alternative
approach would be to advise the user to run "git config --show-origin"
and leave them to figure out how to fix it themselves but that seems
rather unfriendly. As we're forcing them to update their config we
should try and make that as easy as possible.

In order to generate this advice we need to record each file where
either of the config keys is set and whether a key occurs more that
once in a given file. This lets us generate the list of commands to
remove all the keys and also tells us which key the "auto" setting
comes from.

As we want the user to update their config we do not provide a way
for this advice to be disabled other than changing the value of
"core.commentChar" or "core.commentString".

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
t/t3404-rebase-interactive.sh
t/t7502-commit-porcelain.sh