git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/4] git-gui: handle config booleans without value
@ 2011-10-14  8:14 Bert Wesarg
  2011-10-14  8:14 ` [PATCH 2/4] git-gui: add smart case search mode in searchbar Bert Wesarg
  2011-10-17 23:13 ` [PATCH 1/4] git-gui: handle config booleans without value Pat Thoyts
  0 siblings, 2 replies; 11+ messages in thread
From: Bert Wesarg @ 2011-10-14  8:14 UTC (permalink / raw
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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
@@ -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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] git-gui: add smart case search mode in searchbar
  2011-10-14  8:14 [PATCH 1/4] git-gui: handle config booleans without value Bert Wesarg
@ 2011-10-14  8:14 ` Bert Wesarg
  2011-10-14  8:14   ` [PATCH 3/4] git-gui: add regexp search mode to the 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 23:13 ` [PATCH 1/4] git-gui: handle config booleans without value Pat Thoyts
  1 sibling, 2 replies; 11+ messages in thread
From: Bert Wesarg @ 2011-10-14  8:14 UTC (permalink / raw
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] git-gui: add regexp search mode to the searchbar
  2011-10-14  8:14 ` [PATCH 2/4] git-gui: add smart case search mode in searchbar Bert Wesarg
@ 2011-10-14  8:14   ` 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
  1 sibling, 1 reply; 11+ messages in thread
From: Bert Wesarg @ 2011-10-14  8:14 UTC (permalink / raw
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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(-)

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] git-gui: add search history to searchbar
  2011-10-14  8:14   ` [PATCH 3/4] git-gui: add regexp search mode to the searchbar Bert Wesarg
@ 2011-10-14  8:14     ` Bert Wesarg
  0 siblings, 0 replies; 11+ messages in thread
From: Bert Wesarg @ 2011-10-14  8:14 UTC (permalink / raw
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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(-)

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar
  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-16 22:32   ` Andrew Ardill
  2011-10-17  5:32     ` Bert Wesarg
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Ardill @ 2011-10-16 22:32 UTC (permalink / raw
  To: Bert Wesarg; +Cc: Pat Thoyts, git

On 14 October 2011 19:14, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Bert Wesarg @ 2011-10-17  5:32 UTC (permalink / raw
  To: Andrew Ardill; +Cc: Pat Thoyts, git

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

> Regards,
>
> Andrew Ardill
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] git-gui: handle config booleans without value
  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-17 23:13 ` Pat Thoyts
  2011-10-18  6:39   ` Bert Wesarg
  1 sibling, 1 reply; 11+ messages in thread
From: Pat Thoyts @ 2011-10-17 23:13 UTC (permalink / raw
  To: Bert Wesarg; +Cc: git

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.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar
  2011-10-17  5:32     ` Bert Wesarg
@ 2011-10-17 23:29       ` Pat Thoyts
  2011-10-18  3:33         ` Andrew Ardill
  0 siblings, 1 reply; 11+ messages in thread
From: Pat Thoyts @ 2011-10-17 23:29 UTC (permalink / raw
  To: Bert Wesarg; +Cc: Andrew Ardill, git

Bert Wesarg <bert.wesarg@googlemail.com> writes:

>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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] git-gui: add smart case search mode in searchbar
  2011-10-17 23:29       ` Pat Thoyts
@ 2011-10-18  3:33         ` Andrew Ardill
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Ardill @ 2011-10-18  3:33 UTC (permalink / raw
  To: Pat Thoyts; +Cc: Bert Wesarg, git

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] git-gui: handle config booleans without value
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Bert Wesarg @ 2011-10-18  6:39 UTC (permalink / raw
  To: Pat Thoyts; +Cc: git

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

>
> --
> Pat Thoyts                            http://www.patthoyts.tk/
> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] git-gui: handle config booleans without value
  2011-10-18  6:39   ` Bert Wesarg
@ 2011-10-18  8:25     ` Pat Thoyts
  0 siblings, 0 replies; 11+ messages in thread
From: Pat Thoyts @ 2011-10-18  8:25 UTC (permalink / raw
  To: Bert Wesarg; +Cc: git

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-10-18  8:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).