From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, win@wincent.com
Subject: Re: [BUG] git-diff-* --color oddness
Date: Fri, 4 Jan 2008 04:45:31 -0500 [thread overview]
Message-ID: <20080104094531.GA30122@coredump.intra.peff.net> (raw)
In-Reply-To: <7vodc2kk2d.fsf@gitster.siamese.dyndns.org>
On Fri, Jan 04, 2008 at 01:37:46AM -0800, Junio C Hamano wrote:
> > And it looks like the second call is already OK. We don't try parsing
> > the config to get the external diff command unless ALLOW_EXTERNAL is
> > set, which the plumbing already disallows (though I am still confused
> > why it would need to be loaded lazily in the first place -- I wonder if
> > read_config_if_needed is needed at all).
>
> I think that was a premature optimization without benching. It
> is expected that most trees would not have attributes to define
> custom low-level diff types, and without them we do not need to
> parse the configuration to find out the external commands to be
> used.
Ah. But we were parsing them anyway in git_diff_ui_config at the
beginning of the program (and we need to, since you will always have
diff.default.*). So I think this is safe to do, and can replace my other
"only read config once" patch from a few minutes ago:
-- >8 --
diff: remove lazy config loading
There is no point to this. Either:
1. The program has already loaded git_diff_ui_config, in
which case this is a noop.
2. The program didn't, which means it is plumbing that
does not _want_ git_diff_ui_config to be loaded.
Signed-off-by: Jeff King <peff@peff.net>
---
diff.c | 12 ------------
1 files changed, 0 insertions(+), 12 deletions(-)
diff --git a/diff.c b/diff.c
index ecf2fd6..2c78d74 100644
--- a/diff.c
+++ b/diff.c
@@ -59,17 +59,6 @@ static struct ll_diff_driver {
char *cmd;
} *user_diff, **user_diff_tail;
-static void read_config_if_needed(void)
-{
- static int done = 0;
- if (done)
- return;
-
- user_diff_tail = &user_diff;
- git_config(git_diff_ui_config);
- done = 1;
-}
-
/*
* Currently there is only "diff.<drivername>.command" variable;
* because there are "diff.color.<slot>" variables, we are parsing
@@ -1825,7 +1814,6 @@ static const char *external_diff_attr(const char *name)
!ATTR_UNSET(value)) {
struct ll_diff_driver *drv;
- read_config_if_needed();
for (drv = user_diff; drv; drv = drv->next)
if (!strcmp(drv->name, value))
return drv->cmd;
--
1.5.4.rc2.1125.ga305e-dirty
prev parent reply other threads:[~2008-01-04 9:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-04 8:14 [BUG] git-diff-* --color oddness Jeff King
2008-01-04 8:24 ` Junio C Hamano
2008-01-04 8:28 ` Jeff King
2008-01-04 8:35 ` Junio C Hamano
2008-01-04 8:43 ` Jeff King
2008-01-04 8:26 ` Junio C Hamano
2008-01-04 8:32 ` Jeff King
2008-01-04 8:46 ` Junio C Hamano
2008-01-04 8:59 ` Jeff King
2008-01-04 9:25 ` Jeff King
2008-01-04 9:37 ` Junio C Hamano
2008-01-04 9:45 ` Jeff King [this message]
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=20080104094531.GA30122@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=win@wincent.com \
/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