threads / patch / 28672

patch, 4 partsgit-gui: handle config booleans without value

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

## tl;dr

11 messages between Oct 14, 2011 and Oct 18, 2011. Diffs are folded; open one to read it.

replies: 10people: 3as markdown or json

Bert Wesarg· Oct 14, 2011, 08:14 UTC · lore

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(-)
Show changes to git-gui.sh +14 −2
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
@@ -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
-- 
1.7.6.789.gb4599
Bert Wesarg· Oct 14, 2011, 08:14 UTC · re: Bert Wesarg · lore

[PATCH 2/4] git-gui: add smart case search mode in searchbar

Setting config gui.search.smartcase to true, the search mode in the searchbar (from the blame view) is by default case-insensitive. But entering an upper case letter into the search field activates the case- sensitive search mode.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 lib/search.tcl |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
Show changes to lib/search.tcl +12 −1
diff --git a/lib/search.tcl b/lib/search.tcl
index ef3486f..461c66d 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -7,7 +7,8 @@ field w
 field ctext
 
 field searchstring   {}
-field casesensitive  1
+field casesensitive
+field default_casesensitive
 field searchdirn     -forwards
 
 field smarktop
@@ -18,6 +19,12 @@ constructor new {i_w i_text args} {
 	set w      $i_w
 	set ctext  $i_text
 
+	if {[is_config_true gui.search.smartcase]} {
+		set default_casesensitive 0
+	} else {
+		set default_casesensitive 1
+	}
+
 	${NS}::frame  $w
 	${NS}::label  $w.l       -text [mc Find:]
 	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
@@ -45,6 +52,7 @@ constructor new {i_w i_text args} {
 method show {} {
 	if {![visible $this]} {
 		grid $w
+		set casesensitive $default_casesensitive
 	}
 	focus -force $w.ent
 }
@@ -125,6 +133,9 @@ method _incrsearch {} {
 	if {[catch {$ctext index anchor}]} {
 		$ctext mark set anchor [_get_new_anchor $this]
 	}
+	if {[regexp {[[:upper:]]} $searchstring]} {
+		set casesensitive 1
+	}
 	if {$searchstring ne {}} {
 		set here [_do_search $this anchor mlen]
 		if {$here ne {}} {
-- 
1.7.6.789.gb4599
Bert Wesarg· Oct 14, 2011, 08:14 UTC · re: Bert Wesarg · lore

[PATCH 3/4] git-gui: add regexp search mode to the searchbar

It's off by default, but can be enabled via the config gui.search.regexp.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 lib/search.tcl |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
Show changes to lib/search.tcl +11 −1
diff --git a/lib/search.tcl b/lib/search.tcl
index 461c66d..9268ec3 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -7,6 +7,8 @@ field w
 field ctext
 
 field searchstring   {}
+field regexpsearch
+field default_regexpsearch
 field casesensitive
 field default_casesensitive
 field searchdirn     -forwards
@@ -19,6 +21,7 @@ constructor new {i_w i_text args} {
 	set w      $i_w
 	set ctext  $i_text
 
+	set default_regexpsearch [is_config_true gui.search.regexp]
 	if {[is_config_true gui.search.smartcase]} {
 		set default_casesensitive 0
 	} else {
@@ -30,10 +33,13 @@ constructor new {i_w i_text args} {
 	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
 	${NS}::button $w.bn      -text [mc Next] -command [cb find_next]
 	${NS}::button $w.bp      -text [mc Prev] -command [cb find_prev]
-	${NS}::checkbutton $w.cs -text [mc Case-Sensitive] \
+	${NS}::checkbutton $w.re -text [mc RegExp] \
+		-variable ${__this}::regexpsearch -command [cb _incrsearch]
+	${NS}::checkbutton $w.cs -text [mc Case] \
 		-variable ${__this}::casesensitive -command [cb _incrsearch]
 	pack   $w.l   -side left
 	pack   $w.cs  -side right
+	pack   $w.re  -side right
 	pack   $w.bp  -side right
 	pack   $w.bn  -side right
 	pack   $w.ent -side left -expand 1 -fill x
@@ -52,6 +58,7 @@ constructor new {i_w i_text args} {
 method show {} {
 	if {![visible $this]} {
 		grid $w
+		set regexpsearch  $default_regexpsearch
 		set casesensitive $default_casesensitive
 	}
 	focus -force $w.ent
@@ -106,6 +113,9 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} {
 		upvar $mlenvar mlen
 		lappend cmd -count mlen
 	}
+	if {$regexpsearch} {
+		lappend cmd -regexp
+	}
 	if {!$casesensitive} {
 		lappend cmd -nocase
 	}
-- 
1.7.6.789.gb4599
Bert Wesarg· Oct 14, 2011, 08:14 UTC · re: Bert Wesarg · lore

[PATCH 4/4] git-gui: add search history to searchbar

Use the up/down keys to browse the history.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 lib/search.tcl |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
Show changes to lib/search.tcl +60 −0
diff --git a/lib/search.tcl b/lib/search.tcl
index 9268ec3..15f99d8 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -13,6 +13,9 @@ field casesensitive
 field default_casesensitive
 field searchdirn     -forwards
 
+field history
+field history_index
+
 field smarktop
 field smarkbot
 
@@ -28,6 +31,8 @@ constructor new {i_w i_text args} {
 		set default_casesensitive 1
 	}
 
+	set history [list]
+
 	${NS}::frame  $w
 	${NS}::label  $w.l       -text [mc Find:]
 	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
@@ -50,6 +55,8 @@ constructor new {i_w i_text args} {
 	trace add variable searchstring write [cb _incrsearch_cb]
 	bind $w.ent <Return> [cb find_next]
 	bind $w.ent <Shift-Return> [cb find_prev]
+	bind $w.ent <Key-Up>   [cb _prev_search]
+	bind $w.ent <Key-Down> [cb _next_search]
 	
 	bind $w <Destroy> [list delete_this $this]
 	return $this
@@ -58,8 +65,10 @@ constructor new {i_w i_text args} {
 method show {} {
 	if {![visible $this]} {
 		grid $w
+		$w.ent delete 0 end
 		set regexpsearch  $default_regexpsearch
 		set casesensitive $default_casesensitive
+		set history_index [llength $history]
 	}
 	focus -force $w.ent
 }
@@ -68,6 +77,7 @@ method hide {} {
 	if {[visible $this]} {
 		focus $ctext
 		grid remove $w
+		_save_search $this
 	}
 }
 
@@ -160,6 +170,55 @@ method _incrsearch {} {
 	}
 }
 
+method _save_search {} {
+	if {$searchstring eq {}} {
+		return
+	}
+	if {[llength $history] > 0} {
+		foreach {s_regexp s_case s_expr} [lindex $history end] break
+	} else {
+		set s_regexp $regexpsearch
+		set s_case   $casesensitive
+		set s_expr   ""
+	}
+	if {$searchstring eq $s_expr} {
+		# update modes
+		set history [lreplace $history end end \
+				[list $regexpsearch $casesensitive $searchstring]]
+	} else {
+		lappend history [list $regexpsearch $casesensitive $searchstring]
+	}
+	set history_index [llength $history]
+}
+
+method _prev_search {} {
+	if {$history_index > 0} {
+		incr history_index -1
+		foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
+		$w.ent delete 0 end
+		$w.ent insert 0 $s_expr
+		set regexpsearch $s_regexp
+		set casesensitive $s_case
+	}
+}
+
+method _next_search {} {
+	if {$history_index < [llength $history]} {
+		incr history_index
+	}
+	if {$history_index < [llength $history]} {
+		foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
+	} else {
+		set s_regexp $default_regexpsearch
+		set s_case   $default_casesensitive
+		set s_expr   ""
+	}
+	$w.ent delete 0 end
+	$w.ent insert 0 $s_expr
+	set regexpsearch $s_regexp
+	set casesensitive $s_case
+}
+
 method find_prev {} {
 	find_next $this -backwards
 }
@@ -170,6 +229,7 @@ method find_next {{dir -forwards}} {
 	set searchdirn $dir
 	$ctext mark unset anchor
 	if {$searchstring ne {}} {
+		_save_search $this
 		set start [_get_new_anchor $this]
 		if {$dir eq "-forwards"} {
 			set start "$start + 1c"
-- 
1.7.6.789.gb4599
Andrew Ardill· Oct 16, 2011, 22:32 UTC · re: Bert Wesarg · lore

Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar

On 14 October 2011 19:14, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 58 quoted lines
> Setting config gui.search.smartcase to true, the search mode in the
> searchbar (from the blame view) is by default case-insensitive. But
> entering an upper case letter into the search field activates the case-
> sensitive search mode.
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
>  lib/search.tcl |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/lib/search.tcl b/lib/search.tcl
> index ef3486f..461c66d 100644
> --- a/lib/search.tcl
> +++ b/lib/search.tcl
> @@ -7,7 +7,8 @@ field w
>  field ctext
>
>  field searchstring   {}
> -field casesensitive  1
> +field casesensitive
> +field default_casesensitive
>  field searchdirn     -forwards
>
>  field smarktop
> @@ -18,6 +19,12 @@ constructor new {i_w i_text args} {
>        set w      $i_w
>        set ctext  $i_text
>
> +       if {[is_config_true gui.search.smartcase]} {
> +               set default_casesensitive 0
> +       } else {
> +               set default_casesensitive 1
> +       }
> +
>        ${NS}::frame  $w
>        ${NS}::label  $w.l       -text [mc Find:]
>        entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
> @@ -45,6 +52,7 @@ constructor new {i_w i_text args} {
>  method show {} {
>        if {![visible $this]} {
>                grid $w
> +               set casesensitive $default_casesensitive
>        }
>        focus -force $w.ent
>  }
> @@ -125,6 +133,9 @@ method _incrsearch {} {
>        if {[catch {$ctext index anchor}]} {
>                $ctext mark set anchor [_get_new_anchor $this]
>        }
> +       if {[regexp {[[:upper:]]} $searchstring]} {
> +               set casesensitive 1
> +       }
>        if {$searchstring ne {}} {
>                set here [_do_search $this anchor mlen]
>                if {$here ne {}} {
> --
> 1.7.6.789.gb4599
>

I don't really know tcl so I'm not certain, but it looks like you never reset the case sensitive flag once it has been set by entering an upper case letter. If I accidentally enter an upper case letter and have set smartcase true, I would expect that deleting that character would turn case sensitivity off again.

Regards,
Andrew Ardill
Bert Wesarg· Oct 17, 2011, 05:32 UTC · re: Andrew Ardill · lore

Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar

On Mon, Oct 17, 2011 at 00:32, Andrew Ardill <andrew.ardill@gmail.com> wrote:
Show 6 quoted lines
> I don't really know tcl so I'm not certain, but it looks like you
> never reset the case sensitive flag once it has been set by entering
> an upper case letter. If I accidentally enter an upper case letter and
> have set smartcase true, I would expect that deleting that character
> would turn case sensitivity off again.
>

I never reset it, because your case is a way to search case-sensitive for an expression in all lower-case. For example, if you would like to search for 'git' case-sensitively, you would type: 'gitA^H'. A direct shortcut to toggle the case flag could also be of use. The other idea which come to mind, is to reset the case flag, if you clear the input field. I.e. type 'G^Hgit' would still seach case-insensitive.

Bert
> Regards,
>
> Andrew Ardill
>
Pat Thoyts· Oct 17, 2011, 23:29 UTC · re: Bert Wesarg · lore

Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar

Bert Wesarg <bert.wesarg@googlemail.com> writes:
Show 16 quoted lines
>On Mon, Oct 17, 2011 at 00:32, Andrew Ardill <andrew.ardill@gmail.com> wrote:
>> I don't really know tcl so I'm not certain, but it looks like you
>> never reset the case sensitive flag once it has been set by entering
>> an upper case letter. If I accidentally enter an upper case letter and
>> have set smartcase true, I would expect that deleting that character
>> would turn case sensitivity off again.
>>
>
>I never reset it, because your case is a way to search case-sensitive
>for an expression in all lower-case. For example, if you would like to
>search for 'git' case-sensitively, you would type: 'gitA^H'. A direct
>shortcut to toggle the case flag could also be of use. The other idea
>which come to mind, is to reset the case flag, if you clear the input
>field. I.e. type 'G^Hgit' would still seach case-insensitive.
>
>Bert

I don't really like the way it works at the moment. It seems very keen to enable the case sensitive mode and you must use the mouse to disable that. I see why you chose to make it work that way though. I think resetting it in clearing the field makes sense.

The rest of the series looks good. The history recording is nice to have.
-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
Andrew Ardill· Oct 18, 2011, 03:33 UTC · re: Pat Thoyts · lore

Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar

I agree that clearing the field to reset case sensitivity is a nice compromise between easily turning smartcase off (by typing a capital) and easily turning it on again if you accidentally turned it off, or decided you don't want it on.

In most cases you would think an accidental capital would be the first letter typed anyhow.

Regards,
Andrew Ardill
Pat Thoyts· Oct 17, 2011, 23:13 UTC · re: Bert Wesarg · lore

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

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
Bert Wesarg· Oct 18, 2011, 06:39 UTC · re: Pat Thoyts · lore

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

On Tue, Oct 18, 2011 at 01:13, Pat Thoyts <patthoyts@users.sourceforge.net> wrote:

Show 81 quoted lines
> 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
Show 5 quoted lines
>
> --
> Pat Thoyts                            http://www.patthoyts.tk/
> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
>
Pat Thoyts· Oct 18, 2011, 08:25 UTC · re: Bert Wesarg · lore

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

Bert Wesarg <bert.wesarg@googlemail.com> writes:
Show 93 quoted lines
>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

← back to recent threads