git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Borowitz <dborowitz@google.com>
To: git@vger.kernel.org
Cc: jrn@google.com, Dave Borowitz <dborowitz@google.com>
Subject: [PATCH] config.txt: Document behavior of backslashes in subsections
Date: Thu, 21 Dec 2017 08:10:42 -0500	[thread overview]
Message-ID: <20171221131042.91107-1-dborowitz@google.com> (raw)

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


             reply	other threads:[~2017-12-21 13:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 13:10 Dave Borowitz [this message]
2017-12-22 20:49 ` [PATCH] config.txt: Document behavior of backslashes in subsections Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171221131042.91107-1-dborowitz@google.com \
    --to=dborowitz@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrn@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).