config.txt: document behavior of backslashes in subsections

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Dave Borowitz 2017-12-21 08:10:42 -05:00 коммит произвёл Junio C Hamano
Родитель 3013dff866
Коммит 1feb061701
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -41,11 +41,13 @@ in the section header, like in the example below:
-------- --------
Subsection names are case sensitive and can contain any characters except Subsection names are case sensitive and can contain any characters except
newline (doublequote `"` and backslash can be included by escaping them newline and the null byte. Doublequote `"` and backslash can be included
as `\"` and `\\`, respectively). Section headers cannot span multiple by escaping them as `\"` and `\\`, respectively. Backslashes preceding
lines. Variables may belong directly to a section or to a given subsection. other characters are dropped when reading; for example, `\t` is read as
You can have `[section]` if you have `[section "subsection"]`, but you `t` and `\0` is read as `0` Section headers cannot span multiple lines.
don't need to. 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 There is also a deprecated `[section.subsection]` syntax. With this
syntax, the subsection name is converted to lower-case and is also syntax, the subsection name is converted to lower-case and is also