Re: [RFC] Git config file reader in Perl (WIP)
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 17, 2007, 10:44 UTC
- Message-ID
- <Pine.LNX.4.63.0701171138371.22628@wbgn013.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <200701171048.03686.jnareb@gmail.com>
Hi,
On Wed, 17 Jan 2007, Jakub Narebski wrote:
Show 18 quoted lines
> Johannes Schindelin wrote: > > > > On Wed, 17 Jan 2007, Jakub Narebski wrote: > > > >> Dnia wtorek 16. stycznia 2007 23:56, Johannes Schindelin napisa?: > > >>> So, how about a "git repo-config --dump" which outputs a stream of NUL > >>> separated keys and values? This should be really easy to "parse", and > >>> there are no ambiguities: No key or value can contain a NUL. > >> > >> Good idea, although "\n" would work as well as NUL. > > > > No it would not: > > > > [someSection] > > thisKey = has\na\nvalue\with\nseveral\nnewlines > > $ fatal: bad config file line <nn> in <config>
Yeah, sorry. But you got the point.
Show 8 quoted lines
> The same with quoted: > > [someSection] > qthisKey = "has\na\nvalue\with\nseveral\nnewlines" > > There is no escaping besides escaping " and escape character > i.e. escaping \ in git config. Se "\n" would work as well as NUL. > (It is said explicitely that subsection names cannot contain "\n").
So you want "git-repo-config --dump" to output something which has to be scanned for escaping sequences?
If you call
$ git repo-config -l
you will _no longer_ see "\n"s, but rather newlines.
I don't know why you insist on newlines, when a NUL makes perfect sense: Take everything until the next NUL. This is the key. Then take everything until the next NUL. This is the value. Repeat until EOF.
Show 20 quoted lines
> >> The only problem is with "key without value" case, i.e. something like > >> > >> [section] > >> noval > >> > >> which shows as > >> > >> section.noval > > > > but is equivalent to > > > > [section] > > noval = true > > > > Since it is by definition a boolean value. > > But only for "git repo-config --bool --get section.noval" output. > Semantically equivalent to "true". > > But without --bool it returns like it was "".
Yes, it returns "", but this is _wrong_. A single "[section] noval" _only_ makes sense as a boolean. The information lies in its _presence_, which is as good as saying "true".
Ciao, Dscho