From: Pat Thoyts <patthoyts@users.sourceforge.net>
To: Bert Wesarg <bert.wesarg@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] git-gui: handle config booleans without value
Date: Tue, 18 Oct 2011 09:25:04 +0100 [thread overview]
Message-ID: <87ehyan1un.fsf@fox.patthoyts.tk> (raw)
In-Reply-To: <CAKPyHN3dQ+qWeJtGzigEm=fZe62ZeRW-QGq0jnycKEBVaWn=mA@mail.gmail.com> (Bert Wesarg's message of "Tue, 18 Oct 2011 08:39:26 +0200")
Bert Wesarg <bert.wesarg@googlemail.com> writes:
>On Tue, Oct 18, 2011 at 01:13, Pat Thoyts
><patthoyts@users.sourceforge.net> wrote:
>> Bert Wesarg <bert.wesarg@googlemail.com> writes:
>>
>>>When git interprets a config variable without a value as bool it is considered
>>>as true. But git-gui doesn't so until yet.
>>>
>>>The value for boolean configs are also case-insensitive.
>>>
>>>Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
>>>---
>>> git-gui.sh | 16 ++++++++++++++--
>>> 1 files changed, 14 insertions(+), 2 deletions(-)
>>>
>>>diff --git a/git-gui.sh b/git-gui.sh
>>>index f897160..d687871 100755
>>>--- a/git-gui.sh
>>>+++ b/git-gui.sh
>>>@@ -299,7 +299,9 @@ proc is_config_true {name} {
>>> global repo_config
>>> if {[catch {set v $repo_config($name)}]} {
>>> return 0
>>>- } elseif {$v eq {true} || $v eq {1} || $v eq {yes}} {
>>>+ }
>>>+ set v [string tolower $v]
>>>+ if {$v eq {} || $v eq {true} || $v eq {1} || $v eq {yes} || $v eq {on}} {
>>> return 1
>>> } else {
>>> return 0
>>
>> This looks ok - we actually have a [string is boolean $v] test we could
>> use eg:
>> if {[string is boolean $v]} {
>> return [expr {$v eq {} ? 1 : !!$v}]
>> }
>> although I'm not sure it gains us much. This would match everything Tcl
>> believes to be a boolean - yes/no, on/off, true/false and 1/0. Without
>> -strict the [string is] test will consider {} to be a boolean.
>>
>>
>>>@@ -310,7 +312,9 @@ proc is_config_false {name} {
>>> global repo_config
>>> if {[catch {set v $repo_config($name)}]} {
>>> return 0
>>>- } elseif {$v eq {false} || $v eq {0} || $v eq {no}} {
>>>+ }
>>>+ set v [string tolower $v]
>>>+ if {$v eq {false} || $v eq {0} || $v eq {no} || $v eq {off}} {
>>> return 1
>>> } else {
>>> return 0
>>>@@ -1060,6 +1064,10 @@ git-version proc _parse_config {arr_name args} {
>>> } else {
>>> set arr($name) $value
>>> }
>>>+ } elseif {[regexp {^([^\n]+)$} $line line name]} {
>>>+ # no value given, but interpreting them as
>>>+ # boolean will be handled as true
>>>+ set arr($name) {}
>>> }
>>> }
>>> }
>>>@@ -1075,6 +1083,10 @@ git-version proc _parse_config {arr_name args} {
>>> } else {
>>> set arr($name) $value
>>> }
>>>+ } elseif {[regexp {^([^=]+)$} $line line name]} {
>>>+ # no value given, but interpreting them as
>>>+ # boolean will be handled as true
>>>+ set arr($name) {}
>>> }
>>> }
>>> close $fd_rc
>>
>> Is this really how git treats boolean config values? I can't seem to
>> demonstrate that to myself:
>> pat@frog:/opt/src/git-gui$ git config --unset core.xyzzy
>> pat@frog:/opt/src/git-gui$ git config --bool --get core.xyzzy
>> pat@frog:/opt/src/git-gui$ git config --bool core.xyzzy 1
>> pat@frog:/opt/src/git-gui$ git config --bool --get core.xyzzy
>> true
>>
>> I assume I'm using the wrong test for this.
>
>It looks like you can't set it with git-config. But I know, that writing:
>
>[core]
> xyyzy
>
>into the git config file and than calling git config --bool --get
>core.xyzzy, will give you true.
>
>Bert
OK thanks for explaining.
--
Pat Thoyts http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD
prev parent reply other threads:[~2011-10-18 8:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 8:14 [PATCH 1/4] git-gui: handle config booleans without value Bert Wesarg
2011-10-14 8:14 ` [PATCH 2/4] git-gui: add smart case search mode in searchbar Bert Wesarg
2011-10-14 8:14 ` [PATCH 3/4] git-gui: add regexp search mode to the searchbar Bert Wesarg
2011-10-14 8:14 ` [PATCH 4/4] git-gui: add search history to searchbar Bert Wesarg
2011-10-16 22:32 ` [PATCH 2/4] git-gui: add smart case search mode in searchbar Andrew Ardill
2011-10-17 5:32 ` Bert Wesarg
2011-10-17 23:29 ` Pat Thoyts
2011-10-18 3:33 ` Andrew Ardill
2011-10-17 23:13 ` [PATCH 1/4] git-gui: handle config booleans without value Pat Thoyts
2011-10-18 6:39 ` Bert Wesarg
2011-10-18 8:25 ` Pat Thoyts [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=87ehyan1un.fsf@fox.patthoyts.tk \
--to=patthoyts@users.sourceforge.net \
--cc=bert.wesarg@googlemail.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).