git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Documentation: update [section.subsection] to reflect what git does

From
Jeff King <peff@peff.net>
Date
Oct 12, 2011, 16:29 UTC
Message-ID
<20111012162939.GA3055@sigill.intra.peff.net>
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:
Show 7 quoted lines
> -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
Previous: Carlos Martín NietoNext: Jeff King
Message 2 of 13 in “Documentation: update [section.subsection] to reflect what git does”
  1. Documentation: update [section.subsection] to reflect what git doesCarlos Martín Nieto, Oct 12, 2011
  2. Jeff KingOct 12, 2011
  3. Jeff KingOct 12, 2011
  4. Jeff KingOct 12, 2011
  5. 1/2 t1300: put git invocations inside test functionJeff King, Oct 12, 2011
  6. Johannes SixtOct 19, 2011
  7. Junio C HamanoOct 19, 2011
  8. t1300: attempting to remove a non-existent .git/config is not an errorJohannes Sixt, Oct 19, 2011
  9. Jeff KingOct 19, 2011
  10. 2/2 t1300: test mixed-case variable retrievalJeff King, Oct 12, 2011
  11. Junio C HamanoOct 12, 2011
  12. Junio C HamanoOct 12, 2011
  13. Jeff KingOct 12, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.