From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH B v4 5/5] git config: don't allow --get-color* and variable type
Date: Sun, 22 Feb 2009 09:35:01 -0800 [thread overview]
Message-ID: <7vmycez86y.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <94a0d4530902220912r94e00d6ha7592bc397baa57c@mail.gmail.com> (Felipe Contreras's message of "Sun, 22 Feb 2009 19:12:07 +0200")
Felipe Contreras <felipe.contreras@gmail.com> writes:
>>> diff --git a/builtin-config.c b/builtin-config.c
>>> index 8045926..9930568 100644
>>> --- a/builtin-config.c
>>> +++ b/builtin-config.c
>>> @@ -359,6 +359,11 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
>>> if (get_colorbool_slot)
>>> actions |= ACTION_GET_COLORBOOL;
>>>
>>> + if ((get_color_slot || get_colorbool_slot) && types) {
>>> + error("--get-color and variable type are incoherent");
>>> + usage_with_options(builtin_config_usage, builtin_config_options);
>>> + }
>>> +
>>
>> I do not think I suggested anything like this, so I'd decline to take
>> credit for this patch.
>>
>> Strictly speaking, "--bool --get-colorbool diff.color 1" shouldn't error
>> out, don't you think? And it certainly shouldn't say "--get-color".
>
> Huh? I misinterpreted:
> I see "git config --bool --get-color diff.color.whitespace" is still
> allowed, which you might want to tighten further.
"--get-color" gets, escape sequence to throw at the terminal to get the
color configured. It does not make sense to ask for bool (or int) for
that action.
"--get-colorbool" asks if it is appropriate to use such escape sequence
(e.g. when the output is tty and config says "auto", you would get "please
use color"). In other words, its type is always bool, so using it as
--int does not make sense but we cannot really say using it with --bool is
nonsense.
The two use formats with and without is_tty are meant to be used in
scripts this way:
# without $is_tty
if git config --get-colorbool color.diff
then
use_color=true
else
use_color=false
fi
# with $is_tty
if test -t 1
then
is_tty=1
else
is_tty=0
fi
use_color=$(git config --get-colorbool color.diff $is_tty)
In the latter form, output from the command is captured by $() and does
not see if the stdout of the calling script is a tty, hence the script
feeds that information to the command as an extra parameter.
next prev parent reply other threads:[~2009-02-22 17:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-21 0:49 [PATCH B v4 0/5] git config: reorganization Felipe Contreras
2009-02-21 0:49 ` [PATCH B v4 1/5] git config: reorganize to use parseopt Felipe Contreras
2009-02-21 0:49 ` [PATCH B v4 2/5] git config: don't allow multiple config file locations Felipe Contreras
2009-02-21 0:49 ` [PATCH B v4 3/5] git config: don't allow multiple variable types Felipe Contreras
2009-02-21 0:49 ` [PATCH B v4 4/5] git config: don't allow extra arguments for -e or -l Felipe Contreras
2009-02-21 0:49 ` [PATCH B v4 5/5] git config: don't allow --get-color* and variable type Felipe Contreras
2009-02-22 16:48 ` Junio C Hamano
2009-02-22 17:12 ` Felipe Contreras
2009-02-22 17:35 ` Junio C Hamano [this message]
2009-03-07 9:47 ` Felipe Contreras
2009-02-22 16:48 ` [PATCH B v4 1/5] git config: reorganize to use parseopt Junio C Hamano
2009-02-22 17:19 ` Felipe Contreras
2009-02-21 0:53 ` [PATCH B v4 0/5] git config: reorganization Felipe Contreras
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=7vmycez86y.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.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).