git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] git-gui: handle config booleans without value

From
Pat Thoyts <patthoyts@users.sourceforge.net>
Date
Oct 17, 2011, 23:13 UTC
Message-ID
<87mxczgqiw.fsf@fox.patthoyts.tk>
In-Reply-To
<94b050c4cf7ae8df8d79112e13613244ebff4037.1318579823.git.bert.wesarg@googlemail.com>
Bert Wesarg <bert.wesarg@googlemail.com> writes:
Show 25 quoted lines
>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.
Show 33 quoted lines
>@@ -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.
-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
Previous: Andrew ArdillNext: Bert Wesarg
Message 9 of 11 in “git-gui: handle config booleans without value”
  1. 1/4 git-gui: handle config booleans without valueBert Wesarg, Oct 14, 2011
  2. 2/4 git-gui: add smart case search mode in searchbarBert Wesarg, Oct 14, 2011
  3. 3/4 git-gui: add regexp search mode to the searchbarBert Wesarg, Oct 14, 2011
  4. 4/4 git-gui: add search history to searchbarBert Wesarg, Oct 14, 2011
  5. Andrew ArdillOct 16, 2011
  6. Bert WesargOct 17, 2011
  7. Pat ThoytsOct 17, 2011
  8. Andrew ArdillOct 18, 2011
  9. Pat ThoytsOct 17, 2011
  10. Bert WesargOct 18, 2011
  11. Pat ThoytsOct 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.