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

Re: Minor bug: git config ignores empty sections

From
Jakub Narębski <jnareb@gmail.com>
Date
Aug 21, 2016, 17:09 UTC
Message-ID
<968003ae-4f62-ebe9-f7af-53b4e1bcf7fd@gmail.com>
In-Reply-To
<20160816123631.ckbvzustl2j37gdx@sigill.intra.peff.net>
W dniu 16.08.2016 o 14:36, Jeff King pisze:
> What I think would be much more sane in general is to parse the whole
> thing into a tree (or even a flat list of events),

List of events is cheaper on memory (though I don't think there is an issue with size of config file), and can be turned into tree and DOM easily.

Show 18 quoted lines
>                                                    marking each
> syntactically as a section header, a key, a comment, a run of
> whitespace, and so on. And then do manipulations on that tree (e.g.,
> walk down to the section of interest, add a new key at the end), and
> then reformat the tree back into a stream of bytes. That lets you
> separate the policy logic from the parsing, and do high-level operations
> that might involve multiple passes or backtracking in the tree (e.g.,
> walk to the section, walk past any existing keys, walk past any comments
> but _not_ past any blank lines, then add the new key).
> 
> There are other other upsides, too. For example, the current code cannot
> write multiple unrelated keys in a single pass.
> 
> The downsides is that it's a complete rewrite of the code. So it's a
> _lot_ more work, and it carries more risk of regression. So please don't
> take this as "no, your solution isn't OK; you have to do the rewrite".
> We've been living with band-aids on the config code for a decade, so I
> am OK with one more.
So how 'git config --show-origin --list' works?  

Ah, I guess it prints as it goes, instead of parsing config file(s) into stream of events, and printing from those.

-- 
Jakub Narębski
Previous: Jeff KingNext: Junio C Hamano
Message 11 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.