{"thread":{"id":"47477","subject":"[PATCH] config.txt: Document behavior of backslashes in subsections","startedAt":"2017-12-21T13:10:56Z","lastAt":"2017-12-22T20:49:50Z","messageCount":2,"participants":["Dave Borowitz","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"335123","messageId":"20171221131042.91107-1-dborowitz@google.com","threadId":"47477","inReplyTo":null,"subject":"[PATCH] config.txt: Document behavior of backslashes in subsections","fromName":"Dave Borowitz","fromEmail":"dborowitz@google.com","sentAt":"2017-12-21T13:10:42Z","receivedAt":"2017-12-21T13:10:56Z","isPatch":true,"sender":{"key":"dborowitz@google.com","avatar":"https://avatars.githubusercontent.com/u/194927?v=4"},"body":"Unrecognized escape sequences are invalid in values:\n\n  $ git config -f - --list <<EOF\n  [foo]\n    bar = \"\\t\\\\\\y\\\"\\u\"\n  EOF\n  fatal: bad config line 2 in standard input\n\nBut in subsection names, the backslash is simply dropped if the\nfollowing character does not produce a recognized escape sequence:\n\n  $ git config -f - --list <<EOF\n  [foo \"\\t\\\\\\y\\\"\\u\"]\n    bar = baz\n  EOF\n  foo.t\\y\"u.bar=baz\n\nAlthough it would be nice for subsection names and values to have\nconsistent behavior, changing the behavior for subsection names is a\nnonstarter since it would cause existing, valid config files to\nsuddenly be interpreted differently.\n\nSigned-off-by: Dave Borowitz <dborowitz@google.com>\n---\n Documentation/config.txt | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex b18c0f97fe..f772186c44 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -41,11 +41,13 @@ in the section header, like in the example below:\n --------\n \n Subsection names are case sensitive and can contain any characters except\n-newline (doublequote `\"` and backslash can be included by escaping them\n-as `\\\"` and `\\\\`, respectively).  Section headers cannot span multiple\n-lines.  Variables may belong directly to a section or to a given subsection.\n-You can have `[section]` if you have `[section \"subsection\"]`, but you\n-don't need to.\n+newline and the null byte. Doublequote `\"` and backslash can be included\n+by escaping them as `\\\"` and `\\\\`, respectively. Backslashes preceding\n+other characters are dropped when reading; for example, `\\t` is read as\n+`t` and `\\0` is read as `0` Section headers cannot span multiple lines.\n+Variables may belong directly to a section or to a given subsection. You\n+can have `[section]` if you have `[section \"subsection\"]`, but you don't\n+need to.\n \n There is also a deprecated `[section.subsection]` syntax. With this\n syntax, the subsection name is converted to lower-case and is also\n-- \n2.15.1.620.gb9897f4670-goog\n\n"},{"id":"335194","messageId":"xmqq8tduqyhk.fsf@gitster.mtv.corp.google.com","threadId":"47477","inReplyTo":"20171221131042.91107-1-dborowitz@google.com","subject":"Re: [PATCH] config.txt: Document behavior of backslashes in subsections","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-22T20:49:43Z","receivedAt":"2017-12-22T20:49:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dave Borowitz <dborowitz@google.com> writes:\n\n> Unrecognized escape sequences are invalid in values:\n>\n>   $ git config -f - --list <<EOF\n>   [foo]\n>     bar = \"\\t\\\\\\y\\\"\\u\"\n>   EOF\n>   fatal: bad config line 2 in standard input\n>\n> But in subsection names, the backslash is simply dropped if the\n> following character does not produce a recognized escape sequence:\n>\n>   $ git config -f - --list <<EOF\n>   [foo \"\\t\\\\\\y\\\"\\u\"]\n>     bar = baz\n>   EOF\n>   foo.t\\y\"u.bar=baz\n>\n> Although it would be nice for subsection names and values to have\n> consistent behavior, changing the behavior for subsection names is a\n> nonstarter since it would cause existing, valid config files to\n> suddenly be interpreted differently.\n>\n> Signed-off-by: Dave Borowitz <dborowitz@google.com>\n> ---\n>  Documentation/config.txt | 12 +++++++-----\n>  1 file changed, 7 insertions(+), 5 deletions(-)\n\nThanks.\n\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index b18c0f97fe..f772186c44 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -41,11 +41,13 @@ in the section header, like in the example below:\n>  --------\n>  \n>  Subsection names are case sensitive and can contain any characters except\n> -newline (doublequote `\"` and backslash can be included by escaping them\n> -as `\\\"` and `\\\\`, respectively).  Section headers cannot span multiple\n> -lines.  Variables may belong directly to a section or to a given subsection.\n> -You can have `[section]` if you have `[section \"subsection\"]`, but you\n> -don't need to.\n> +newline and the null byte. Doublequote `\"` and backslash can be included\n> +by escaping them as `\\\"` and `\\\\`, respectively. Backslashes preceding\n> +other characters are dropped when reading; for example, `\\t` is read as\n> +`t` and `\\0` is read as `0` Section headers cannot span multiple lines.\n> +Variables may belong directly to a section or to a given subsection. You\n> +can have `[section]` if you have `[section \"subsection\"]`, but you don't\n> +need to.\n>  \n>  There is also a deprecated `[section.subsection]` syntax. With this\n>  syntax, the subsection name is converted to lower-case and is also\n"}]}