git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] config.txt: Document behavior of backslashes in subsections
@ 2017-12-21 13:10 Dave Borowitz
  2017-12-22 20:49 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Borowitz @ 2017-12-21 13:10 UTC (permalink / raw)
  To: git; +Cc: jrn, Dave Borowitz

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(-)

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
-- 
2.15.1.620.gb9897f4670-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] config.txt: Document behavior of backslashes in subsections
  2017-12-21 13:10 [PATCH] config.txt: Document behavior of backslashes in subsections Dave Borowitz
@ 2017-12-22 20:49 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2017-12-22 20:49 UTC (permalink / raw)
  To: Dave Borowitz; +Cc: git, jrn

Dave Borowitz <dborowitz@google.com> writes:

> 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.

>
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-22 20:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 13:10 [PATCH] config.txt: Document behavior of backslashes in subsections Dave Borowitz
2017-12-22 20:49 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).