From: Jeff King <peff@peff.net>
To: "Carlos Martín Nieto" <cmn@elego.de>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] Documentation: update [section.subsection] to reflect what git does
Date: Wed, 12 Oct 2011 12:29:39 -0400 [thread overview]
Message-ID: <20111012162939.GA3055@sigill.intra.peff.net> (raw)
In-Reply-To: <1318434726-5556-1-git-send-email-cmn@elego.de>
On Wed, Oct 12, 2011 at 05:52:06PM +0200, Carlos Martín Nieto wrote:
> -There is also a case insensitive alternative `[section.subsection]` syntax.
> -In this syntax, subsection names follow the same restrictions as for section
> -names.
> +There is also a deprecated `[section.subsection]` syntax. With this
> +syntax, the subsection name is converted to lower-case and is also
> +compared case sensitively. These subsection names follow the same
> +restrictions as section names.
Hmm. While technically more correct, I think it is a little more
confusing to read. The lower-case canonicalization thing is actually
used for the other case-insensitive parts, too. So maybe it makes sense
to describe that in detail, and then just note that
"[section.subsection]" uses the same mechanism.
The patch below does this, and then the original text in the section you
tweaked above hopefully makes more sense in the new context.
The explanation matches what we do now, but it did end up a bit longer
than I had hoped. We could make it a lot shorter by:
1. Canonicalizing the section and key names that the caller gives to
git-config.
2. Not mentioning the "section.foo" syntax. We can't canonicalize the
subsection in (1) because of this syntax. But we can at least gloss
over the detail, and then maybe just mention it much later in the
file format. Or even deprecate it.
-- >8 --
Subject: [PATCH] docs/config: explain case-insensitive matching
We generally think of key matching as case-insensitive, but
it's not exactly. It's about canonicalizing one side, and
comparing it byte-wise with the canonical key name given to
git-config.
Signed-off-by: Jeff King <peff@peff.net>
---
Documentation/git-config.txt | 50 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index e7ecf5d..e92aee9 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -28,7 +28,7 @@ DESCRIPTION
-----------
You can query/set/replace/unset options with this command. The name is
actually the section and the key separated by a dot, and the value will be
-escaped.
+escaped. See the section on name matching below.
Multiple lines can be added to an option by using the '--add' option.
If you want to update or unset an option which can occur on multiple
@@ -178,6 +178,54 @@ See also <<FILES>>.
Opens an editor to modify the specified config file; either
'--system', '--global', or repository (default).
+
+NAME MATCHING
+-------------
+
+Configuration key names are matched using an algorithm that allows for
+partial case sensitivity. Section and key names are read from the config
+files, canonicalized according to the rules below, and then compared
+case-sensitively with the input given to git-config. Therefore any
+callers to git-config should request the canonicalized version of the
+name. This typically means lowercasing the section and key names, and
+leaving the subsection (if any) intact. For example, ask for
+`git config core.eol`, not `git config CoRe.EOL`.
+
+The canonicalization rules are:
+
+1. Lowercase the section and key names.
+
+2. If a literal subsection (like `[section "foo"]`) is used, leave it
+ intact.
+
+3. If a non-literal subsection (like `[section.foo]`) is used, lowercase
+ the subsection.
+
+4. Concatenate the resulting section, subsection, and key, separated by
+ a dot ('.').
+
+For example, this configuration file:
+
+-----------------------------------------------
+[CORE]
+eol = true
+
+[branch "Foo"]
+REMOTE = origin
+
+[color.DIFF]
+new = blue
+-----------------------------------------------
+
+would yield the following three canonicalized names:
+
+-----------------------------------------------
+core.eol
+branch.Foo.remote
+color.diff.new
+-----------------------------------------------
+
+
[[FILES]]
FILES
-----
--
1.7.7.rc2.21.gb9948
next prev parent reply other threads:[~2011-10-12 16:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-12 15:52 [PATCH] Documentation: update [section.subsection] to reflect what git does Carlos Martín Nieto
2011-10-12 16:29 ` Jeff King [this message]
2011-10-12 17:46 ` Jeff King
2011-10-12 18:27 ` Jeff King
2011-10-12 18:29 ` [PATCH 1/2] t1300: put git invocations inside test function Jeff King
2011-10-19 6:41 ` Johannes Sixt
2011-10-19 7:04 ` Junio C Hamano
2011-10-19 7:37 ` [PATCH] t1300: attempting to remove a non-existent .git/config is not an error Johannes Sixt
2011-10-19 16:13 ` Jeff King
2011-10-12 18:30 ` [PATCH 2/2] t1300: test mixed-case variable retrieval Jeff King
2011-10-12 19:19 ` Junio C Hamano
2011-10-12 17:46 ` [PATCH] Documentation: update [section.subsection] to reflect what git does Junio C Hamano
2011-10-12 18:34 ` Jeff King
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=20111012162939.GA3055@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).