From: Phillip Wood <phillip.wood123@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, Dominik Maier <dmnk@google.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Jeff King <peff@peff.net>, Taylor Blau <me@ttaylorr.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
dmnk+artist@google.com
Subject: Re: [PATCH] config: skip continued lines when matching section
Date: Fri, 20 Nov 2026 14:33:31 +0000 [thread overview]
Message-ID: <67c5d781-bfe4-41b7-ae1d-0b0c473e9979@gmail.com> (raw)
In-Reply-To: <xmqqbj7ktjp7.fsf@gitster.g>
On 20/11/2026 00:44, Junio C Hamano wrote:
> Dominik Maier <dmnk@google.com> writes:
>
>> When a value in the target section spans multiple lines via a trailing
>> backslash and a continuation line begins with '[other]', removing or
>> renaming the section stops early at '[other]' and leaves the remainder
>> of the continued value behind as an unquoted '[other]' section.
>
> If the behaviour was to treat these as continued values from day
> one, I would have agreed that it would be a reasonably design, but
> offhand I do not know if this is a breaking change in behaviour that
> may negatively affect existing configuration files.
As I understand it, this patch changes the way we parse the config when
we're renaming or copying a section to match the way we parse it when we
read config values. It does not change how we read config settings so I
think it is simply a bug fix for an unlikely corner case when copying or
renaming a section. It's a pity we don't share a common code path for
the parsing and end up implementing it twice.
I had a quick look at the code in this patch and I'm not sure it handles
values and subsection names that contain carriage returns correctly. As
far as I can tell
printf '[a "b\rc"]\rkey=\rv\ralue' >/tmp/test.config
creates a valid config file. For example
git config get -f /tmp/test.config "$(printf 'a.b\rc.key')" |
tr '\r' Q
prints "vQal" but this patch treats '\r' like '\n'
Thanks
Phillip
>> @@ -3434,7 +3525,7 @@ static int repo_config_copy_or_rename_section_in_file(
>> const char *old_name,
>> const char *new_name, int copy)
>> {
>> - int ret = 0, remove = 0;
>> + int ret = 0, remove = 0, continued = 0, in_quote = 0;
>> char *filename_buf = NULL;
>> struct lock_file lock = LOCK_INIT;
>> int out_fd;
>> @@ -3496,9 +3587,12 @@ static int repo_config_copy_or_rename_section_in_file(
>> goto out;
>> }
>>
>> + int was_continued = continued;
>> +
>
> This triggers -Wdeclaration-after-statement doesn't it?
>
> (administrivia)
>
> I do not consider myself an area expert for the configuration file
> editing code. Please do not directly Cc: random people unless you
> know they are specifically familiar with the area or they are
> positively interested in the topic and they will regret if they miss
> your message if they fail to notice.
>
> Thanks.
prev parent reply other threads:[~2026-11-20 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:23 [PATCH] config: skip continued lines when matching section Dominik Maier
2026-11-20 0:44 ` Junio C Hamano
2026-11-20 14:33 ` Phillip Wood [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67c5d781-bfe4-41b7-ae1d-0b0c473e9979@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=dmnk+artist@google.com \
--cc=dmnk@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox