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

Re: Minor bug: git config ignores empty sections

From
Jeff King <peff@peff.net>
Date
Aug 15, 2016, 12:09 UTC
Message-ID
<20160815120916.6iobqirqbg76exms@sigill.intra.peff.net>
In-Reply-To
<CALO-gutdz5VMgoRmbqEa9UiaTC+L2Sy2n-3AF+zfPr-X8+1U4A@mail.gmail.com>
On Sun, Aug 14, 2016 at 09:29:27PM -0400, Eli Barzilay wrote:
Show 17 quoted lines
> Looks like there's a problem with setting a config with an empty
> section, making it create a new section.  The result is:
> 
>     $ git --version
>     git version 2.9.2
>     $ git init
>     Initialized empty Git repository in /home/eli/t/.git/
>     $ t() { git config x.y x; git config --unset x.y; }
>     $ t;t;t
>     $ grep -c '\[x\]' .git/config
>     3
>     $ git config x.z x
>     $ t;t;t
>     $ git config x.z x     # adds another [x], but leaves it populated
>     $ t;t;t;t;t;t;t;t
>     $ grep -c '\[x\]' .git/config
>     4

Yep. This is a very old and well-known bug. IIRC, the problem is that config updates use the regular callback-parser, so they see only the config keys themselves. Empty section headers never trigger them. Fixing it would require rewriting the config-update code.

And implicit in your test is the other bug, which is that deleting the last key in a section leaves the empty header. I think it's related to the same issue.

Patches welcome, of course.
-Peff
Previous: Eli BarzilayNext: Andreas Schwab
Message 2 of 12 in “Minor bug: git config ignores empty sections”
  1. Eli BarzilayAug 15, 2016
  2. Jeff KingAug 15, 2016
  3. Andreas SchwabAug 15, 2016
  4. Jeff KingAug 15, 2016
  5. Junio C HamanoAug 15, 2016
  6. Andreas SchwabAug 15, 2016
  7. Jeff KingAug 15, 2016
  8. Junio C HamanoAug 15, 2016
  9. Eli BarzilayAug 16, 2016
  10. Jeff KingAug 16, 2016
  11. Jakub NarębskiAug 21, 2016
  12. Junio C HamanoAug 15, 2016

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.