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

Empty config sections are neither deleted nor reused

From
Jonas Bernoulli <jonas@bernoul.li>
Date
May 13, 2016, 14:55 UTC
Message-ID
<87r3d6knwo.fsf@bernoul.li>
After running
  git init .
  git config foo.bar baz
  git config --unset foo.bar    # 1
  git config foo.bar baz        # 2
.git/config contains
  [core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
  [foo]
  [foo]
          bar = baz

(1) did not remove the "foo" section when the last contained variable was unset and (2) did not reuse the empty "foo" section when "foo.bar" was set again.

I would prefer if unsetting the last variable in a section would cause the heading of the now empty section would be removed.

But it might also make sense to not remove an empty section and to instead reuse an empty section. That would prevent a section from being moved to eof because it became temporarily empty. Maybe that was the intention and Git at some point stopped re-using an empty section?

It could even be argued that it would make sense for empty sections to be removed *and* reused (in order to "cleanup" old empty sections).

The only possible combination which doesn't make sense is to not remove an empty section and to also not reuse an empty section - unfortunately that's what Git currently does.

  Best regards,
  Jonas
Next: Junio C Hamano
Message 1 of 6 in “Empty config sections are neither deleted nor reused”
  1. Jonas BernoulliMay 13, 2016
  2. Junio C HamanoMay 13, 2016
  3. Jonas BernoulliMay 14, 2016
  4. Matthieu MoyMay 14, 2016
  5. Junio C HamanoMay 14, 2016
  6. Jonas BernoulliMay 14, 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.