git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>,
	Denis Bueno <dbueno@gmail.com>
Subject: Re: [PATCH 1/4] Split up default "core" config parsing into helper routine
Date: Wed, 18 Jun 2008 18:49:19 -0400	[thread overview]
Message-ID: <20080618224919.GA22599@sigill.intra.peff.net> (raw)
In-Reply-To: <alpine.LFD.1.10.0806181529570.2907@woody.linux-foundation.org>

On Wed, Jun 18, 2008 at 03:30:35PM -0700, Linus Torvalds wrote:

> It makes the code a bit easier to read, and in theory a bit faster too
> (no need to compare all the different "core.*" strings against non-core
> config options).

Maybe it would be easier still to read (and unmeasurably more efficient)
to actually do it like:

        if (!prefixcmp(var, "core."))
                return git_default_core_config(var+5, value);
...
int git_default_core_config(const char *var, const char *value)
{
        if (!strcmp(var, "pager"))
                ...

> The config system really should get something of a complete overhaul,
> but in the absense of that, this at least improves on it a tiny bit.

I was curious a while ago and instrumented git_config to write the PID
to a tempfile each time it was called. Most git programs parse the
config files (.git/config, ~/.gitconfig, /etc/gitconfig) three times
each, with some doing it as many as five times.

Most of the config functions are simply "if this key, then set this
value". I wonder if it would be simpler to just load the whole thing at
once, using a table similar to parseopt.

Then we could do useful things like say "you specified core.foobar, but
there is no such variable." I know we can't know all values, since some
non-git programs put values in the config, but I don't think it's
unreasonable for us to claim all of core.*, especially if it helps us
catch simple configuration errors.

-Peff

  parent reply	other threads:[~2008-06-18 22:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18 22:29 [PATCH 0/4] Add 'core.fsyncobjectfiles' config option Linus Torvalds
2008-06-18 22:30 ` [PATCH 1/4] Split up default "core" config parsing into helper routine Linus Torvalds
2008-06-18 22:31   ` [PATCH 2/4] Split up default "user" " Linus Torvalds
2008-06-18 22:31     ` [PATCH 3/4] Split up default "i18n" and "branch" config parsing into helper routines Linus Torvalds
2008-06-18 22:32       ` [PATCH 4/4] Add config option to enable 'fsync()' of object files Linus Torvalds
2008-06-18 22:49   ` Jeff King [this message]
2008-06-18 22:58     ` [PATCH 1/4] Split up default "core" config parsing into helper routine Linus Torvalds
2008-06-18 23:13       ` Jeff King
2008-06-18 23:34         ` Linus Torvalds
2008-06-19  0:08           ` Jeff King
2008-06-19  0:23             ` Linus Torvalds
2008-06-19  0:28               ` Linus Torvalds
2008-06-19  2:10                 ` Daniel Barkalow
2008-06-19  0:32               ` Junio C Hamano
2008-06-19  1:23               ` Jeff King
2008-06-19  0:18           ` Eric Raible

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=20080618224919.GA22599@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=dbueno@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=torvalds@linux-foundation.org \
    /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).