git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] config.txt: Document behavior of backslashes in subsections

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 22, 2017, 20:49 UTC
Message-ID
<xmqq8tduqyhk.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171221131042.91107-1-dborowitz@google.com>
Dave Borowitz <dborowitz@google.com> writes:
Show 26 quoted lines
> Unrecognized escape sequences are invalid in values:
>
>   $ git config -f - --list <<EOF
>   [foo]
>     bar = "\t\\\y\"\u"
>   EOF
>   fatal: bad config line 2 in standard input
>
> But in subsection names, the backslash is simply dropped if the
> following character does not produce a recognized escape sequence:
>
>   $ git config -f - --list <<EOF
>   [foo "\t\\\y\"\u"]
>     bar = baz
>   EOF
>   foo.t\y"u.bar=baz
>
> Although it would be nice for subsection names and values to have
> consistent behavior, changing the behavior for subsection names is a
> nonstarter since it would cause existing, valid config files to
> suddenly be interpreted differently.
>
> Signed-off-by: Dave Borowitz <dborowitz@google.com>
> ---
>  Documentation/config.txt | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
Thanks.
Show 24 quoted lines
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index b18c0f97fe..f772186c44 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -41,11 +41,13 @@ in the section header, like in the example below:
>  --------
>  
>  Subsection names are case sensitive and can contain any characters except
> -newline (doublequote `"` and backslash can be included by escaping them
> -as `\"` and `\\`, respectively).  Section headers cannot span multiple
> -lines.  Variables may belong directly to a section or to a given subsection.
> -You can have `[section]` if you have `[section "subsection"]`, but you
> -don't need to.
> +newline and the null byte. Doublequote `"` and backslash can be included
> +by escaping them as `\"` and `\\`, respectively. Backslashes preceding
> +other characters are dropped when reading; for example, `\t` is read as
> +`t` and `\0` is read as `0` Section headers cannot span multiple lines.
> +Variables may belong directly to a section or to a given subsection. You
> +can have `[section]` if you have `[section "subsection"]`, but you don't
> +need to.
>  
>  There is also a deprecated `[section.subsection]` syntax. With this
>  syntax, the subsection name is converted to lower-case and is also
Previous: Dave Borowitz
Message 2 of 2 in “config.txt: Document behavior of backslashes in subsections”
  1. config.txt: Document behavior of backslashes in subsectionsDave Borowitz, Dec 21, 2017
  2. Junio C HamanoDec 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.