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

Re: [PATCH 1/2] Complain in the tests about git config not failing with, keys without a section

From
Jeff King <peff@peff.net>
Date
Mar 5, 2012, 10:37 UTC
Message-ID
<20120305103714.GA30463@sigill.intra.peff.net>
In-Reply-To
<4F547261.7000506@philosof.dk>
On Mon, Mar 05, 2012 at 08:59:29AM +0100, Rune Philosof wrote:
Show 9 quoted lines
> On 02-03-2012 19:40, Junio C Hamano wrote:
> >>git is supposed to fail when having a key without a section, but does not.
> >I do not think anybody said it is supposed to fail in this case.
> >
> >the behaviour for a single level name is just "undefined", which is very different from "must fail".
> 
> Quoting from `git help config`:
> This command will fail if:
>  3. no section was provided,

The text you are quoting is not about what is in the config file, but rather the config name given on the command line (which we would be trying to look up). And we do correctly complain about that:

  $ git config foo
  error: key does not contain a section: foo
But:
> under SYNTAX
>  Each variable must belong to some section, which means that there
> must be a section header before the first
>        setting of a variable.

Yes, everything is supposed to be in a section. Historically we have not complained, but instead just treated it as a single-level variable. For internal git use this never mattered, as git only looked at variables with section names. For "git config foo", it also does not matter, since we will notice the lack of section before even doing a lookup.

For "git config --list", as you noticed, we include it in the output. I suspect we should simply omit it as cruft. But we could also issue a warning, and/or die.

-Peff
Previous: Rune PhilosofNext: Junio C Hamano
Message 4 of 6 in “Complain in the tests about git config not failing with, keys without a section”
  1. 1/2 Complain in the tests about git config not failing with, keys without a sectionRune Schjellerup Philosof, Mar 2, 2012
  2. Junio C HamanoMar 2, 2012
  3. Rune PhilosofMar 5, 2012
  4. Jeff KingMar 5, 2012
  5. Junio C HamanoMar 5, 2012
  6. Jeff KingMar 6, 2012

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.