git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Subject: Re: Add ".git/config" file parser
Date: Mon, 10 Oct 2005 15:12:30 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0510101456570.14597@g5.osdl.org> (raw)
In-Reply-To: <434AE209.60605@zytor.com>



On Mon, 10 Oct 2005, H. Peter Anvin wrote:
> 
> A suggestion: if you make your basic types (integer, string, boolean)
> recognizable by the parser, you can present them in that way.  This pretty
> much means strings will have to always be double-quoted, but that avoids a
> bunch of ambiguities.

Well, the parser is already pretty unambiguous, purely by virtue of being 
stupid as hell.

In particular, the only thing quoting does is to actually make whitespace 
meaningful, and as a way to allow comments inside strings (otherwise a "#" 
or ";" is always a "comment starts here" marker).

Outside of quotes, any whitespace will just collapse to a single space 
(and be removed from beginning and end).

And quite frankly, always keeping the things as strings just makes things 
so much easier and the interfaces very simple. And if/when you want to 
turn the string into a boolean or a regular integer, there are two helper 
functions that do exactly that, so it's not very hard.

I considered using some "smart" parser (ie using something like 
flex/bison), but the thing is, I didn't want smart. I personally think 
it's a lot more important for the file format to be _nice_, and there I 
think it's fine if

	[diff]
		external=/usr/local/bin/gnu-diff

doesn't need quotes, even if it's obviously a string. Simplicity is a 
virtue (both in parsing and in the "language" parsed).

In fact, even the example I had - with a space and an argument - doesn't 
need quotes (since the single space will be collapsed to a single space), 
I just put that as an example.

Side note: the design is meant to allow different programs to share the 
same config file without having to know about each others config 
variables. Anything they don't recognize is just ignored. The downside is 
that if you mistype an option name, nobody will recognize it, and nobody 
will complain either. 

That was one of the reasons for the "scoping". It not only allows grouping 
of variables, but it means that the "git-diff-xyz" family of programs 
might decide that they'll report anything that starts with "diff." but 
that they don't understand as a warning (but preferably not error, since 
it might be a newer option that an older version of git just doesn't 
understand).

		Linus

  reply	other threads:[~2005-10-10 22:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-08 18:00 Seeing various mode changes on cygwin Jonas Fonseca
2005-10-08 18:51 ` Junio C Hamano
2005-10-08 21:36   ` Alex Riesen
2005-10-08 23:36     ` Junio C Hamano
2005-10-09  2:19       ` Linus Torvalds
2005-10-09  6:46         ` Junio C Hamano
2005-10-10  6:48         ` Daniel Barkalow
2005-10-10  7:38           ` Junio C Hamano
2005-10-10 17:59             ` Daniel Barkalow
2005-10-10 18:22               ` Linus Torvalds
2005-10-10 21:35                 ` Add ".git/config" file parser Linus Torvalds
2005-10-10 21:47                   ` Linus Torvalds
2005-10-10 21:50                     ` H. Peter Anvin
2005-10-10 22:12                       ` Linus Torvalds [this message]
2005-10-12  0:25                   ` Junio C Hamano
2005-10-12  7:43                     ` [PATCH] Use core.filemode Junio C Hamano
2005-10-09  3:43       ` Seeing various mode changes on cygwin H. Peter Anvin
2005-10-09 13:02       ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0510101456570.14597@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=hpa@zytor.com \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).