Thread View: linux.kernel.git
2 messages
2 total messages
Started by Junio C Hamano
Fri, 20 Nov 2026 00:44
Re: [PATCH] config: skip continued lines when matching section
Author: Junio C Hamano
Date: Fri, 20 Nov 2026 00:44
Date: Fri, 20 Nov 2026 00:44
40 lines
14043 bytes
14043 bytes
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.
> @@ -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.
Re: [PATCH] config: skip continued lines when matching section
Author: Phillip Wood
Date: Fri, 20 Nov 2026 14:33
Date: Fri, 20 Nov 2026 14:33
65 lines
13470 bytes
13470 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads