From: Jeff King <peff@peff.net>
To: Andrew Ardill <andrew.ardill@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Michael Haggerty <mhagger@alum.mit.edu>,
Jonathan Nieder <jrnieder@gmail.com>,
Thorsten Glaser <tg@mirbsd.de>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: Re: git should not use a default user.email config value
Date: Tue, 13 Aug 2013 11:53:46 -0400 [thread overview]
Message-ID: <20130813155345.GA23391@sigill.intra.peff.net> (raw)
In-Reply-To: <CAH5451nxgpa4Q-BpwhD7yD6V6_LWBP=+oEDR3u0eGErSWNEBbQ@mail.gmail.com>
On Tue, Aug 13, 2013 at 10:52:34PM +1000, Andrew Ardill wrote:
> > The only downside I can think of is that we might want to use the
> > subsection in "include.SUBSECTION.*" for some other limiting conditions
> > (e.g., "only include this config when running version >= X.Y", or even
> > "include only when environment variable FOO is true").
>
> It seems as though gitconfig doesn't have a standard way of dealing
> with 'sub-subsections', which is essentially what this is trying to
> implement.
Right. Syntactically, the config keys are:
SECTION.SUBSECTION.KEY
where SUBSECTION is optional. SECTION and KEY cannot contain spaces or
dots and are case insensitive, but SUBSECTION is handled literally. It
can contain whatever data is useful to the config parser (for example,
remote names, branch names, or even URLs), including spaces or dots.
We could introduce the notion of sub-subsections, but that would not
play well with existing uses of subsection, which assume that they can
put arbitrary data into it.
> It makes sense that there could be different 'modes' of includes.
> These could be the ones you mentioned already, such as repo and env,
> but could also be things like branch where the config changes
> depending on which branch you are on. Ideally, multiple entries per
> mode would be allowed.
>
> Implementing all that initially would be overkill however if this sort
> of functionality is desirable the ability to easily add new modes
> would be a great boon down the track.
Right. We don't have to decide on all of it now; we just have to leave
the door open syntactically for future growth.
> The four pieces of information we need to include are that this is an
> include, the path to the include, the mode, and the mode specific
> parameter. Your proposal is to allow the sub-subsection by
> concatenating with a ":" like this
>
> [include "<mode>:<mode-param>]
> path = <path>
Right. The config parser does not care about the sub-subsection; it is
up to the interpreter of the key to split the subsection if it chooses.
I arbitrarily chose ":" as the internal delimiter because I thought it
looked nice. You could make it dot or space, too.
> Alternatively, we could allow chaining of subsections (couldn't find
> any previous discussion on this) by adding whitespace between each
> subsection. Seems like lots of potentially unnecessary work, but maybe
> this has already been discussed or is the most appropriate way of
> doing it.
>
> $ git config --global include.repo./magic/.path ~/.gitconfig-magic
>
> [include repo "/magic/"]
> path = .gitconfig-magic
I don't think it has been discussed before. But as I mentioned above,
you would not want to apply this everywhere. For existing config
callbacks, they want to take the section literally. So it is going to be
up to the callback to parse the section into subsections anyway, at
which point it does not really matter what syntax you use.
We could teach the config parser to normalize:
[section with many spaces]
key
as "section.with.many.spaces.key" or "section.with many spaces.key" (I
do not think it is even valid in today's code, but I didn't check). But
personally I do not find that any easier to read or understand than the
colon syntax.
> This seems like the easiest and most flexible method, and doesn't
> require any 'special' considerations for the subsection. It would be
> harder for a user to configure, and the concept of a mode seems less
> intuitive.
>
> $ git config --global include.magicrepos.mode repo
> $ git config --global include.magicrepos.param /magic/
> $ git config --global include.magicrepos.path ~/.gitconfig-magic
>
> [include "magicrepos"]
> mode = repo
> param = "/magic/"
> path = ~/.gitconfig-magic
Yeah, that is the most flexible. You could introduce multiple conditions
or other options, as well (e.g., instead of mode and param, have
include.magic.repo, include.magic.env, etc). But it seems like
over-engineering. I do not mind making the code a little harder to
write, but it seems unnecessarily complicated for the user, too.
> Of the three I probably think the subsection chaining is the nicest
> overall, though your original "repo:" proposal seems to be the easiest
> to implement.
I think I favor the colon proposal because of its simplicity. And
because the sub-section chaining cannot be applied consistently across
config keys, I don't think there is much value in trying to introduce a
new general config syntax.
-Peff
next prev parent reply other threads:[~2013-08-13 15:53 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20130809134236.28143.75775.reportbug@tglase.lan.tarent.de>
2013-08-09 19:42 ` git should not use a default user.email config value Jonathan Nieder
2013-08-09 20:00 ` Thorsten Glaser
2013-08-09 20:30 ` Felipe Contreras
2013-08-13 8:29 ` Matthieu Moy
2013-08-09 22:37 ` Jeff King
2013-08-09 23:06 ` Junio C Hamano
2013-08-10 6:17 ` Jeff King
2013-08-10 6:40 ` Jonathan Nieder
2013-08-10 6:52 ` Jeff King
2013-08-10 7:03 ` Jonathan Nieder
2013-08-10 7:14 ` Jeff King
2013-08-09 23:19 ` Jonathan Nieder
2013-08-10 6:47 ` Jeff King
2013-08-10 9:59 ` Michael Haggerty
2013-08-10 10:28 ` Jeff King
2013-08-10 11:42 ` Michael Haggerty
2013-08-10 12:06 ` Thorsten Glaser
2013-08-10 12:34 ` Andreas Schwab
2013-08-12 12:51 ` Greg Troxel
2013-08-10 16:58 ` Junio C Hamano
2013-08-12 11:52 ` Andrew Ardill
2013-08-12 12:39 ` Jeff King
2013-08-12 12:54 ` Michael Haggerty
2013-08-12 15:49 ` Jeff King
2013-08-12 13:01 ` Andrew Ardill
2013-08-12 15:45 ` Jeff King
2013-08-13 11:05 ` Andrew Ardill
2013-08-13 11:46 ` Jeff King
2013-08-13 12:05 ` Jeff King
2013-08-13 12:52 ` Andrew Ardill
2013-08-13 15:53 ` Jeff King [this message]
2013-08-13 16:33 ` Junio C Hamano
2013-08-14 7:28 ` Matthieu Moy
2013-08-14 7:40 ` Jeff King
2013-08-14 8:37 ` Matthieu Moy
2013-08-14 14:00 ` Junio C Hamano
2013-08-14 14:07 ` Matthieu Moy
2013-08-14 14:08 ` conditional config syntax Jeff King
2013-08-14 15:41 ` Junio C Hamano
2013-08-14 7:09 ` git should not use a default user.email config value Michael Haggerty
2013-08-14 7:31 ` Jeff King
2013-08-13 16:31 ` Junio C Hamano
2013-08-13 8:08 ` Matthieu Moy
2013-08-11 0:06 ` Aaron Schrab
2013-08-13 8:24 ` Matthieu Moy
2013-08-13 8:39 ` Thorsten Glaser
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=20130813155345.GA23391@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@imag.fr \
--cc=andrew.ardill@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=mhagger@alum.mit.edu \
--cc=tg@mirbsd.de \
/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).