From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, win@wincent.com
Subject: [BUG] git-diff-* --color oddness
Date: Fri, 4 Jan 2008 03:14:29 -0500 [thread overview]
Message-ID: <20080104081429.GA30635@coredump.intra.peff.net> (raw)
I encountered some weirdness today with git-diff-{files,tree,index} and
--color. They parse the --color command line option, but do _not_ call
git_config(git_diff_ui_config), so if the user has colors specified in
the config, they are not used.
Ordinarily, I would say "nobody should use --color with diff-files". But
we do, in git-add--interactive (see Wincent's 4af756f3). So we can
probably fix that with a "git_diff_minimal_ui_config" which does just
the colors, and use that from the plumbing diff scripts (or just move
the color stuff into git_default_config).
But it gets worse. Try this:
# make a custom color
git config color.diff.meta yellow
# now show a plumbing diff
git diff-tree --color -p 257f3020^ 257f3020
The first two lines of meta-info will be in the stock colors, but
everything after will be in the custom colors. So we are actually
reading the diff_ui options _during_ the diff. The culprit is
funcname_pattern, which calls read_config_if_needed.
It's my understanding that diff_ui_config is about porcelain diff
options, so it is a bit worrisome that in the middle of a plumbing diff
process, we load porcelain config. Fortunately, most of them aren't
looked at except in diff_setup, which has already run. Colors actually
affect globals which are used during the diff, and so are noticed.
So I think the best course is probably:
1. before v1.5.4, we need to fix the color handling in "git-diff -i",
either by declaring git-diff-files --color illegal and finding
another way to do 4af756f3, or by moving the diff color
functionality into the default config.
2. Probably post-v1.5.4, some thought should be given to
how the diff ui config is demand-loaded by
diff.c:read_config_if_needed. I don't _think_ it is a problem for
now except for the colors, because most parts just get used in
diff_setup. But it seems a bit flaky.
-Peff
next reply other threads:[~2008-01-04 8:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-04 8:14 Jeff King [this message]
2008-01-04 8:24 ` [BUG] git-diff-* --color oddness 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
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=20080104081429.GA30635@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