From a8ca786991f7308ef12cb1d54ff5d28137c0feb1 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 10:19:26 +0200 Subject: git-gui: fix multi selected file operation When staging a selection of files using Shift-Click to choose a range of files then using Ctrl-T or the Stage To Commit menu item will stage all the selected files. However if a non-sequential range is selected using Ctrl-Click then all but the first name selected gets staged. This commit fixes this to properly stage all selected files by explicitly adding the path to the list before showing the diff. Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index f897160..e5dd8bc 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2474,6 +2474,7 @@ proc toggle_or_diff {w x y} { [concat $after [list ui_ready]] } } else { + set selected_paths($path) 1 show_diff $path $w $lno } } -- cgit v0.10.2-6-g49f6 From 12b219f7f95f2d089e49140dcb1c2dd6259ff5cf Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 10:14:49 +0200 Subject: git-gui: handle config booleans without value 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 Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index e5dd8bc..33ab5dc 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 -- cgit v0.10.2-6-g49f6 From 0a0243d7333a5c0de107170d02f667c37fb4dc54 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 10:14:50 +0200 Subject: 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 Signed-off-by: Pat Thoyts 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 {}} { -- cgit v0.10.2-6-g49f6 From e9144d5555133a76addb4829dca0e7a9684e1ed4 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 10:14:51 +0200 Subject: 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 Signed-off-by: Pat Thoyts 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 } -- cgit v0.10.2-6-g49f6 From 1159971baa28ed3a9934cf92f4b22e9d0681bdce Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 10:14:52 +0200 Subject: git-gui: add search history to searchbar Use the up/down keys to browse the history. Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts 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 [cb find_next] bind $w.ent [cb find_prev] + bind $w.ent [cb _prev_search] + bind $w.ent [cb _next_search] bind $w [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" -- cgit v0.10.2-6-g49f6 From b020bbd5a0923ceac688fcec1f760beec00dd5ec Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 21:25:19 +0200 Subject: git-gui: fix unintended line break in message string Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/index.tcl b/lib/index.tcl index e38b647..3a9c8b7 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -367,8 +367,7 @@ proc do_add_all {} { } } if {[llength $unknown_paths]} { - set reply [ask_popup [mc "There are unknown files do you also want -to stage those?"]] + set reply [ask_popup [mc "There are unknown files do you also want to stage those?"]] if {$reply} { set paths [concat $paths $unknown_paths] } -- cgit v0.10.2-6-g49f6 From 526aa2b2033048bc90ff40228a60619ca6872e21 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 21:25:20 +0200 Subject: git-gui: use "untracked" for files which are not known to git "untracked" is the right phrase for files new to git. For example git-status uses this phrase. Also make the question shorter. Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/index.tcl b/lib/index.tcl index 3a9c8b7..014acf9 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -356,20 +356,20 @@ proc do_add_all {} { global file_states set paths [list] - set unknown_paths [list] + set untracked_paths [list] foreach path [array names file_states] { switch -glob -- [lindex $file_states($path) 0] { U? {continue} ?M - ?T - ?D {lappend paths $path} - ?O {lappend unknown_paths $path} + ?O {lappend untracked_paths $path} } } - if {[llength $unknown_paths]} { - set reply [ask_popup [mc "There are unknown files do you also want to stage those?"]] + if {[llength $untracked_paths]} { + set reply [ask_popup [mc "Stage also untracked files?"]] if {$reply} { - set paths [concat $paths $unknown_paths] + set paths [concat $paths $untracked_paths] } } add_helper {Adding all changed files} $paths -- cgit v0.10.2-6-g49f6 From bb196e2619652f02f3459ad9464a18ccdebe3ebf Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Fri, 14 Oct 2011 21:25:21 +0200 Subject: git-gui: new config to control staging of untracked files The default is the current "ask". Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index e5dd8bc..7eeec52 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -859,6 +859,7 @@ set font_descs { {fontui font_ui {mc "Main Font"}} {fontdiff font_diff {mc "Diff/Console Font"}} } +set default_config(gui.stageuntracked) ask ###################################################################### ## diff --git a/lib/index.tcl b/lib/index.tcl index 014acf9..45094c2 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -367,7 +367,19 @@ proc do_add_all {} { } } if {[llength $untracked_paths]} { - set reply [ask_popup [mc "Stage also untracked files?"]] + set reply 0 + switch -- [get_config gui.stageuntracked] { + no { + set reply 0 + } + yes { + set reply 1 + } + ask - + default { + set reply [ask_popup [mc "Stage also untracked files?"]] + } + } if {$reply} { set paths [concat $paths $untracked_paths] } diff --git a/lib/option.tcl b/lib/option.tcl index 3807c8d..719103a 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -156,6 +156,7 @@ proc do_options {} { {i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}} {t gui.newbranchtemplate {mc "New Branch Name Template"}} {c gui.encoding {mc "Default File Contents Encoding"}} + {s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}} } { set type [lindex $option 0] set name [lindex $option 1] @@ -208,6 +209,23 @@ proc do_options {} { } pack $w.$f.$optid -side top -anchor w -fill x } + s { + set opts [eval [lindex $option 3]] + ${NS}::frame $w.$f.$optid + ${NS}::label $w.$f.$optid.l -text "$text:" + if {$use_ttk} { + ttk::combobox $w.$f.$optid.v \ + -textvariable ${f}_config_new($name) \ + -values $opts -state readonly + } else { + eval tk_optionMenu $w.$f.$optid.v \ + ${f}_config_new($name) \ + $opts + } + pack $w.$f.$optid.l -side left -anchor w -fill x + pack $w.$f.$optid.v -side right -anchor e -padx 5 + pack $w.$f.$optid -side top -anchor w -fill x + } } } } -- cgit v0.10.2-6-g49f6 From 99665fc58269cfd608558cc0afbc53824703fc6b Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Tue, 18 Oct 2011 09:32:22 +0100 Subject: git-gui: include the number of untracked files to stage when asking the user Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/index.tcl b/lib/index.tcl index 45094c2..8efbbdd 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -377,7 +377,8 @@ proc do_add_all {} { } ask - default { - set reply [ask_popup [mc "Stage also untracked files?"]] + set reply [ask_popup [mc "Stage %d untracked files?" \ + [llength $untracked_paths]]] } } if {$reply} { -- cgit v0.10.2-6-g49f6 From 35927672765f39a045a89d2ef1b392ab3ac61189 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 19 Oct 2011 12:44:39 +0100 Subject: git-gui: theme the search and line-number entry fields on blame screen Signed-off-by: Pat Thoyts diff --git a/lib/line.tcl b/lib/line.tcl index c160012..a026de9 100644 --- a/lib/line.tcl +++ b/lib/line.tcl @@ -15,7 +15,7 @@ constructor new {i_w i_text args} { ${NS}::frame $w ${NS}::label $w.l -text [mc "Goto Line:"] - entry $w.ent \ + tentry $w.ent \ -textvariable ${__this}::linenum \ -background lightgreen \ -validate key \ diff --git a/lib/search.tcl b/lib/search.tcl index 15f99d8..fe16572 100644 --- a/lib/search.tcl +++ b/lib/search.tcl @@ -35,7 +35,7 @@ constructor new {i_w i_text args} { ${NS}::frame $w ${NS}::label $w.l -text [mc Find:] - entry $w.ent -textvariable ${__this}::searchstring -background lightgreen + tentry $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.re -text [mc RegExp] \ @@ -162,10 +162,12 @@ method _incrsearch {} { $ctext see $here $ctext tag remove sel 1.0 end $ctext tag add sel $here "$here + $mlen c" - $w.ent configure -background lightgreen + #$w.ent configure -background lightgreen + $w.ent state !pressed _set_marks $this 1 } else { - $w.ent configure -background lightpink + #$w.ent configure -background lightpink + $w.ent state pressed } } } diff --git a/lib/themed.tcl b/lib/themed.tcl index 1da4586..29a1696 100644 --- a/lib/themed.tcl +++ b/lib/themed.tcl @@ -23,10 +23,59 @@ proc InitTheme {} { ttk::style configure Gold.TFrame -background gold -relief flat # listboxes should have a theme border so embed in ttk::frame ttk::style layout SListbox.TFrame { - SListbox.Frame.Entry.field -sticky news -border true -children { - SListbox.Frame.padding -sticky news - } - } + SListbox.Frame.Entry.field -sticky news -border true -children { + SListbox.Frame.padding -sticky news + } + } + + # Handle either current Tk or older versions of 8.5 + if {[catch {set theme [ttk::style theme use]}]} { + set theme $::ttk::currentTheme + } + + if {[lsearch -exact {default alt classic clam} $theme] != -1} { + # Simple override of standard ttk::entry to change the field + # packground according to a state flag. We should use 'user1' + # but not all versions of 8.5 support that so make use of 'pressed' + # which is not normally in use for entry widgets. + ttk::style layout Edged.Entry [ttk::style layout TEntry] + ttk::style map Edged.Entry {*}[ttk::style map TEntry] + ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \ + -fieldbackground lightgreen + ttk::style map Edged.Entry -fieldbackground { + {pressed !disabled} lightpink + } + } else { + # For fancier themes, in particular the Windows ones, the field + # element may not support changing the background color. So instead + # override the fill using the default fill element. If we overrode + # the vista theme field element we would loose the themed border + # of the widget. + catch { + ttk::style element create color.fill from default + } + + ttk::style layout Edged.Entry { + Edged.Entry.field -sticky nswe -border 0 -children { + Edged.Entry.border -sticky nswe -border 1 -children { + Edged.Entry.padding -sticky nswe -children { + Edged.Entry.color.fill -sticky nswe -children { + Edged.Entry.textarea -sticky nswe + } + } + } + } + } + + ttk::style configure Edged.Entry {*}[ttk::style configure TEntry] \ + -background lightgreen -padding 0 -borderwidth 0 + ttk::style map Edged.Entry {*}[ttk::style map TEntry] \ + -background {{pressed !disabled} lightpink} + } + + if {[lsearch [bind . <>] InitTheme] == -1} { + bind . <> +[namespace code [list InitTheme]] + } } proc gold_frame {w args} { @@ -143,6 +192,47 @@ proc tspinbox {w args} { } } +proc tentry {w args} { + global use_ttk + if {$use_ttk} { + InitTheme + ttk::entry $w -style Edged.Entry + } else { + entry $w + } + + rename $w _$w + interp alias {} $w {} tentry_widgetproc $w + eval [linsert $args 0 tentry_widgetproc $w configure] + return $w +} +proc tentry_widgetproc {w cmd args} { + global use_ttk + switch -- $cmd { + state { + if {$use_ttk} { + return [uplevel 1 [list _$w $cmd] $args] + } else { + if {[lsearch -exact $args pressed] != -1} { + _$w configure -background lightpink + } else { + _$w configure -background lightgreen + } + } + } + configure { + if {$use_ttk} { + if {[set n [lsearch -exact $args -background]] != -1} { + set args [lreplace $args $n [incr n]] + if {[llength $args] == 0} {return} + } + } + return [uplevel 1 [list _$w $cmd] $args] + } + default { return [uplevel 1 [list _$w $cmd] $args] } + } +} + # Tk 8.6 provides a standard font selection dialog. This uses the native # dialogs on Windows and MacOSX or a standard Tk dialog on X11. proc tchoosefont {w title familyvar sizevar} { -- cgit v0.10.2-6-g49f6 From b66f4f7aa750ebebbd5186e1cafeee76df4691f8 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 19 Oct 2011 13:22:33 +0100 Subject: git-gui: catch invalid or complete regular expressions and treat as no match. Signed-off-by: Pat Thoyts diff --git a/lib/search.tcl b/lib/search.tcl index fe16572..db88d87 100644 --- a/lib/search.tcl +++ b/lib/search.tcl @@ -133,14 +133,16 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} { set dir $searchdirn } lappend cmd $dir -- $searchstring - if {$endbound ne {}} { - set here [eval $cmd [list $start] [list $endbound]] - } else { - set here [eval $cmd [list $start]] - if {$here eq {}} { - set here [eval $cmd [_get_wrap_anchor $this $dir]] + if {[catch { + if {$endbound ne {}} { + set here [eval $cmd [list $start] [list $endbound]] + } else { + set here [eval $cmd [list $start]] + if {$here eq {}} { + set here [eval $cmd [_get_wrap_anchor $this $dir]] + } } - } + } err]} { set here {} } return $here } -- cgit v0.10.2-6-g49f6 From 8eaf24b93bdb49d5adfb2f52f0f14dd01735db37 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 19 Oct 2011 13:29:52 +0100 Subject: git-gui: enable the smart case sensitive search only if gui.search.smartcase is true Signed-off-by: Pat Thoyts diff --git a/lib/search.tcl b/lib/search.tcl index db88d87..04a316b 100644 --- a/lib/search.tcl +++ b/lib/search.tcl @@ -11,6 +11,7 @@ field regexpsearch field default_regexpsearch field casesensitive field default_casesensitive +field smartcase field searchdirn -forwards field history @@ -25,7 +26,8 @@ constructor new {i_w i_text args} { set ctext $i_text set default_regexpsearch [is_config_true gui.search.regexp] - if {[is_config_true gui.search.smartcase]} { + set smartcase [is_config_true gui.search.smartcase] + if {$smartcase} { set default_casesensitive 0 } else { set default_casesensitive 1 @@ -155,8 +157,10 @@ method _incrsearch {} { if {[catch {$ctext index anchor}]} { $ctext mark set anchor [_get_new_anchor $this] } - if {[regexp {[[:upper:]]} $searchstring]} { - set casesensitive 1 + if {$smartcase} { + if {[regexp {[[:upper:]]} $searchstring]} { + set casesensitive 1 + } } if {$searchstring ne {}} { set here [_do_search $this anchor mlen] -- cgit v0.10.2-6-g49f6 From 80e66678092700354f8cfc334eab62861d509201 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Tue, 23 Nov 2010 08:37:50 +0100 Subject: git-gui: fix display of path in browser title Ensure the browser path is shown on the title with a / suffix and escape any backslashes or newlines in path elements before display. Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/browser.tcl b/lib/browser.tcl index a8c6223..0328338 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -26,8 +26,14 @@ constructor new {commit {path {}}} { wm withdraw $top wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]] + if {$path ne {}} { + if {[string index $path end] ne {/}} { + append path / + } + } + set browser_commit $commit - set browser_path $browser_commit:$path + set browser_path "$browser_commit:[escape_path $path]" ${NS}::label $w.path \ -textvariable @browser_path \ -- cgit v0.10.2-6-g49f6 From 508dee31f3412d8708b7b47c1677b4294c865edb Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 19 Oct 2011 14:26:29 +0100 Subject: git-gui: set suitable extended window manager hints. This patch uses recent Tk attributes support to specify the intended use of new toplevels by setting the correct EWMH hint. This helps modern window managers to apply sensible decoration for the tooltip and dialogs. Signed-off-by: Pat Thoyts diff --git a/lib/blame.tcl b/lib/blame.tcl index 691941e..49eae19 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -1201,6 +1201,7 @@ method _open_tooltip {cur_w} { _hide_tooltip $this set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1] + catch {wm attributes $tooltip_wm -type tooltip} wm overrideredirect $tooltip_wm 1 wm transient $tooltip_wm [winfo toplevel $cur_w] set tooltip_t $tooltip_wm.label diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index 54c7957..6dae793 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -497,6 +497,7 @@ method _open_tooltip {} { if {$tooltip_wm eq {}} { set tooltip_wm [toplevel $w_list.tooltip -borderwidth 1] + catch {wm attributes $tooltip_wm -type tooltip} wm overrideredirect $tooltip_wm 1 wm transient $tooltip_wm [winfo toplevel $w_list] set tooltip_t $tooltip_wm.label diff --git a/lib/class.tcl b/lib/class.tcl index c27b714..f08506f 100644 --- a/lib/class.tcl +++ b/lib/class.tcl @@ -138,6 +138,7 @@ proc make_dialog {t w args} { upvar $t top $w pfx this this global use_ttk uplevel [linsert $args 0 make_toplevel $t $w] + catch {wm attributes $top -type dialog} pave_toplevel $pfx } diff --git a/lib/themed.tcl b/lib/themed.tcl index 29a1696..8b88d36 100644 --- a/lib/themed.tcl +++ b/lib/themed.tcl @@ -123,6 +123,7 @@ proc paddedlabel {w args} { # place a themed frame over the surface. proc Dialog {w args} { eval [linsert $args 0 toplevel $w -class Dialog] + catch {wm attributes $w -type dialog} pave_toplevel $w return $w } diff --git a/lib/transport.tcl b/lib/transport.tcl index 7fad9b7..e5d211e 100644 --- a/lib/transport.tcl +++ b/lib/transport.tcl @@ -124,6 +124,7 @@ proc do_push_anywhere {} { set w .push_setup toplevel $w + catch {wm attributes $w -type dialog} wm withdraw $w wm geometry $w "+[winfo rootx .]+[winfo rooty .]" pave_toplevel $w -- cgit v0.10.2-6-g49f6 From f9ace9e63d1ea0ce55b8239971b3c99d32dd4692 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Thu, 20 Oct 2011 21:27:27 +0200 Subject: git-gui: use a tristate to control the case mode in the searchbar The config is now called gui.search.case and can have the three values: no/yes/smart. yes is the default. It also resets the case detection in smart mode, when the entry field was cleared by the use. Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/search.tcl b/lib/search.tcl index 04a316b..ef1e555 100644 --- a/lib/search.tcl +++ b/lib/search.tcl @@ -26,11 +26,20 @@ constructor new {i_w i_text args} { set ctext $i_text set default_regexpsearch [is_config_true gui.search.regexp] - set smartcase [is_config_true gui.search.smartcase] - if {$smartcase} { + switch -- [get_config gui.search.case] { + no { set default_casesensitive 0 - } else { + set smartcase 0 + } + smart { + set default_casesensitive 0 + set smartcase 1 + } + yes - + default { set default_casesensitive 1 + set smartcase 0 + } } set history [list] @@ -157,12 +166,10 @@ method _incrsearch {} { if {[catch {$ctext index anchor}]} { $ctext mark set anchor [_get_new_anchor $this] } - if {$smartcase} { - if {[regexp {[[:upper:]]} $searchstring]} { + if {$searchstring ne {}} { + if {$smartcase && [regexp {[[:upper:]]} $searchstring]} { set casesensitive 1 } - } - if {$searchstring ne {}} { set here [_do_search $this anchor mlen] if {$here ne {}} { $ctext see $here @@ -175,6 +182,9 @@ method _incrsearch {} { #$w.ent configure -background lightpink $w.ent state pressed } + } elseif {$smartcase} { + # clearing the field resets the smart case detection + set casesensitive 0 } } -- cgit v0.10.2-6-g49f6 From ff3f01bba9d67a6f7194bbcf2716e55cc596cce1 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Thu, 20 Oct 2011 21:30:30 +0200 Subject: git-gui: span widgets over the full file output area in the blame view Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/blame.tcl b/lib/blame.tcl index 49eae19..b031e66 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -219,7 +219,8 @@ constructor new {i_commit i_path i_jump} { eval grid $w_columns $w.file_pane.out.sby -sticky nsew grid conf \ $w.file_pane.out.sbx \ - -column [expr {[llength $w_columns] - 1}] \ + -column 0 \ + -columnspan [expr {[llength $w_columns] + 1}] \ -sticky we grid columnconfigure \ $w.file_pane.out \ @@ -229,12 +230,14 @@ constructor new {i_commit i_path i_jump} { set finder [::searchbar::new \ $w.file_pane.out.ff $w_file \ - -column [expr {[llength $w_columns] - 1}] \ + -column 0 \ + -columnspan [expr {[llength $w_columns] + 1}] \ ] set gotoline [::linebar::new \ $w.file_pane.out.lf $w_file \ - -column [expr {[llength $w_columns] - 1}] \ + -column 0 \ + -columnspan [expr {[llength $w_columns] + 1}] \ ] set w_cviewer $w.file_pane.cm.t -- cgit v0.10.2-6-g49f6 From 95fa862b577711918fe17cadc3b18851cd077a2b Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Thu, 20 Oct 2011 21:32:30 +0200 Subject: git-gui: include the file path in guitools confirmation dialog For those guitools that require a filename, display this filename when asking the user to confirm the tool launch. [PT: modified to use positional parameters for i18n] Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/tools.tcl b/lib/tools.tcl index 95e6e55..6ec9411 100644 --- a/lib/tools.tcl +++ b/lib/tools.tcl @@ -87,8 +87,14 @@ proc tools_exec {fullname} { return } } elseif {[is_config_true "guitool.$fullname.confirm"]} { - if {[ask_popup [mc "Are you sure you want to run %s?" $fullname]] ne {yes}} { - return + if {[is_config_true "guitool.$fullname.needsfile"]} { + if {[ask_popup [mc "Are you sure you want to run %1\$s on file \"%2\$s\"?" $fullname $current_diff_path]] ne {yes}} { + return + } + } else { + if {[ask_popup [mc "Are you sure you want to run %s?" $fullname]] ne {yes}} { + return + } } } -- cgit v0.10.2-6-g49f6 From 4198579b0a35edfc17e77ba11be3f801e89205ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dejan=20Ribi=C4=8D?= Date: Sun, 30 Oct 2011 18:18:44 +0100 Subject: git-gui: fix spelling error in sshkey.tcl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spelling error originally reported to Ubuntu as launchpad bug #879427. Acked-by: Erik Faye-Lund Signed-off-by: Dejan Ribič Signed-off-by: Pat Thoyts diff --git a/lib/sshkey.tcl b/lib/sshkey.tcl index 5f75bc9..aa6457b 100644 --- a/lib/sshkey.tcl +++ b/lib/sshkey.tcl @@ -117,7 +117,7 @@ proc read_sshkey_output {fd w} { } else { set finfo [find_ssh_key] if {$finfo eq {}} { - set sshkey_title [mc "Generation succeded, but no keys found."] + set sshkey_title [mc "Generation succeeded, but no keys found."] $w.contents insert end $sshkey_output } else { set sshkey_title [mc "Your key is in: %s" [lindex $finfo 0]] -- cgit v0.10.2-6-g49f6 From 9af6413b96c85c9fcd9c34c015cd8fae0219ee04 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 19 Nov 2010 10:00:49 +0000 Subject: git-gui: support underline style when parsing diff output Suggested-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index 21033cb..789c177 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3376,6 +3376,7 @@ foreach {n c} {0 black 1 red4 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 gr $ui_diff tag configure clri3$n -background $c } $ui_diff tag configure clr1 -font font_diffbold +$ui_diff tag configure clr4 -underline 1 $ui_diff tag conf d_info -foreground blue -font font_diffbold diff --git a/lib/diff.tcl b/lib/diff.tcl index cf8a95e..39e4d90 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -504,7 +504,7 @@ proc read_diff {fd conflict_size cont_info} { set prefix clr foreach style [split $colbegin ";"] { if {$style eq "7"} {append prefix i; continue} - if {$style < 30 || $style > 47} {continue} + if {$style != 4 && ($style < 30 || $style > 47)} {continue} set a "$mark linestart + $posbegin chars" set b "$mark linestart + $posend chars" catch {$ui_diff tag add $prefix$style $a $b} -- cgit v0.10.2-6-g49f6 From 3f2fb173ace1afa7040d31cd3239c6a9cac49006 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 19 Nov 2010 22:22:20 +0000 Subject: git-gui: sort the numeric ansi codes This ensures that underline does not conflict with inverse colors. Signed-off-by: Pat Thoyts diff --git a/lib/diff.tcl b/lib/diff.tcl index 39e4d90..f5ed5d1 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -502,7 +502,7 @@ proc read_diff {fd conflict_size cont_info} { foreach {posbegin colbegin posend colend} $markup { set prefix clr - foreach style [split $colbegin ";"] { + foreach style [lsort -integer [split $colbegin ";"]] { if {$style eq "7"} {append prefix i; continue} if {$style != 4 && ($style < 30 || $style > 47)} {continue} set a "$mark linestart + $posbegin chars" -- cgit v0.10.2-6-g49f6 From 54531e7c7aeca965c23e60a6805059826a8de75a Mon Sep 17 00:00:00 2001 From: Tilman Vogel Date: Fri, 21 Jan 2011 11:59:45 +0100 Subject: git-gui: add config value gui.diffopts for passing additional diff options Signed-off-by: Tilman Vogel Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index 789c177..c190cbe 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -850,6 +850,7 @@ set default_config(gui.fastcopyblame) false set default_config(gui.copyblamethreshold) 40 set default_config(gui.blamehistoryctx) 7 set default_config(gui.diffcontext) 5 +set default_config(gui.diffopts) {} set default_config(gui.commitmsgwidth) 75 set default_config(gui.newbranchtemplate) {} set default_config(gui.spellingdictionary) {} diff --git a/lib/diff.tcl b/lib/diff.tcl index f5ed5d1..ec44055 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -309,6 +309,7 @@ proc start_show_diff {cont_info {add_opts {}}} { lappend cmd -p lappend cmd --color + set cmd [concat $cmd $repo_config(gui.diffopts)] if {$repo_config(gui.diffcontext) >= 1} { lappend cmd "-U$repo_config(gui.diffcontext)" } diff --git a/lib/option.tcl b/lib/option.tcl index 719103a..fb06776 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -153,6 +153,7 @@ proc do_options {} { {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}} {i-0..300 gui.blamehistoryctx {mc "Blame History Context Radius (days)"}} {i-1..99 gui.diffcontext {mc "Number of Diff Context Lines"}} + {t gui.diffopts {mc "Additional Diff Parameters"}} {i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}} {t gui.newbranchtemplate {mc "New Branch Name Template"}} {c gui.encoding {mc "Default File Contents Encoding"}} -- cgit v0.10.2-6-g49f6 From f49517a862529f8f0898c414113a45f40cc54565 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Sat, 22 Oct 2011 21:39:39 +0200 Subject: git-gui: make config gui.warndetachedcommit a boolean Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/commit.tcl b/lib/commit.tcl index 372bed9..e27e148 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -263,7 +263,7 @@ proc commit_commitmsg {curHEAD msg_p} { global is_detached repo_config global pch_error - if {$is_detached && $repo_config(gui.warndetachedcommit)} { + if {$is_detached && [is_config_true gui.warndetachedcommit]} { set msg [mc "You are about to commit on a detached head.\ This is a potentially dangerous thing to do because if you switch\ to another branch you will loose your changes and it can be difficult\ diff --git a/lib/option.tcl b/lib/option.tcl index fb06776..0cf1da1 100644 --- a/lib/option.tcl +++ b/lib/option.tcl @@ -157,6 +157,7 @@ proc do_options {} { {i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}} {t gui.newbranchtemplate {mc "New Branch Name Template"}} {c gui.encoding {mc "Default File Contents Encoding"}} + {b gui.warndetachedcommit {mc "Warn before committing to a detached head"}} {s gui.stageuntracked {mc "Staging of untracked files"} {list "yes" "no" "ask"}} } { set type [lindex $option 0] -- cgit v0.10.2-6-g49f6 From d8d166bf0950889743695174e55ea9201e9db9cd Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Sat, 22 Oct 2011 21:39:40 +0200 Subject: git-gui: don't warn for detached head when rebasing Signed-off-by: Bert Wesarg Signed-off-by: Pat Thoyts diff --git a/lib/commit.tcl b/lib/commit.tcl index e27e148..0d81432 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -263,7 +263,9 @@ proc commit_commitmsg {curHEAD msg_p} { global is_detached repo_config global pch_error - if {$is_detached && [is_config_true gui.warndetachedcommit]} { + if {$is_detached + && ![file exists [gitdir rebase-merge head-name]] + && [is_config_true gui.warndetachedcommit]} { set msg [mc "You are about to commit on a detached head.\ This is a potentially dangerous thing to do because if you switch\ to another branch you will loose your changes and it can be difficult\ -- cgit v0.10.2-6-g49f6 From 6f01e20e25f7a164cb27067c690aa49d4cb5178e Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 30 Nov 2011 11:35:28 +0000 Subject: git-gui: set whitespace warnings appropriate to this project Signed-off-by: Pat Thoyts diff --git a/.gitattributes b/.gitattributes index f96112d..33d07c0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +* whitespace=indent-with-non-tab,trailing-space,space-before-tab,tabwidth=4 * encoding=US-ASCII git-gui.sh encoding=UTF-8 /po/*.po encoding=UTF-8 -- cgit v0.10.2-6-g49f6 From af867683345838f1adc606618e873ae4387a3c81 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Tue, 29 Nov 2011 09:27:17 +0000 Subject: git-gui: added config gui.gcwarning to disable the gc hint message On startup in multicommit mode git-gui checks to see if the repository has a lot of objects. If so it shows a dialog suggesting gc be run. This adds 'gui.gcwarning' as a control config variable to allow this to be disabled. The default is true (the warning is shown). Setting this false will prevent the check being done. Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index c190cbe..8d95dda 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3894,7 +3894,7 @@ after 1 { $ui_comm configure -state disabled -background gray } } -if {[is_enabled multicommit]} { +if {[is_enabled multicommit] && ![is_config_false gui.gcwarning]} { after 1000 hint_gc } if {[is_enabled retcode]} { -- cgit v0.10.2-6-g49f6 From 215d4fdbaa9d32459cc199667970dc7f63d94982 Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Wed, 7 Dec 2011 12:48:04 +0000 Subject: git-gui: Set both 16x16 and 32x32 icons on X to pacify Xming. It would be better if the 32x32 icon was equivalent to the one used on Windows (in git-gui.ico), but I'm not sure how that would best be done, so I copied this code from gitk instead. Signed-off-by: Samuel Bronson Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index 8d95dda..2c57fb4 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -729,7 +729,10 @@ if {[is_Windows]} { gitlogo put gray26 -to 5 15 11 16 gitlogo redither - wm iconphoto . -default gitlogo + image create photo gitlogo32 -width 32 -height 32 + gitlogo32 copy gitlogo -zoom 2 2 + + wm iconphoto . -default gitlogo gitlogo32 } } -- cgit v0.10.2-6-g49f6 From 7d076d56757c238aa1b90534cd0d2450528b3580 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 9 Dec 2011 15:14:32 +0000 Subject: git-gui: handle shell script text filters when loading for blame. When loading a file into the blame window git-gui does all the work and must handle the text conversion filters if defined. On Windows it is necessary to detect the need for a shell script explicitly. Such filter commands are run using non-blocking I/O but this has the unfortunate side effect of losing any error that might be reported when the pipe is closed. Switching to blocking mode just before closing enables reporting of errors in the filter scripts to the user. Tested-by: Sebastian Schuberth Signed-off-by: Pat Thoyts diff --git a/git-gui.sh b/git-gui.sh index 2c57fb4..ba4e5c1 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -464,6 +464,35 @@ proc _which {what args} { return {} } +# Test a file for a hashbang to identify executable scripts on Windows. +proc is_shellscript {filename} { + if {![file exists $filename]} {return 0} + set f [open $filename r] + fconfigure $f -encoding binary + set magic [read $f 2] + close $f + return [expr {$magic eq "#!"}] +} + +# Run a command connected via pipes on stdout. +# This is for use with textconv filters and uses sh -c "..." to allow it to +# contain a command with arguments. On windows we must check for shell +# scripts specifically otherwise just call the filter command. +proc open_cmd_pipe {cmd path} { + global env + if {![file executable [shellpath]]} { + set exe [auto_execok [lindex $cmd 0]] + if {[is_shellscript [lindex $exe 0]]} { + set run [linsert [auto_execok sh] end -c "$cmd \"\$0\"" $path] + } else { + set run [concat $exe [lrange $cmd 1 end] $path] + } + } else { + set run [list [shellpath] -c "$cmd \"\$0\"" $path] + } + return [open |$run r] +} + proc _lappend_nice {cmd_var} { global _nice upvar $cmd_var cmd diff --git a/lib/blame.tcl b/lib/blame.tcl index b031e66..324f774 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -476,14 +476,7 @@ method _load {jump} { } if {$commit eq {}} { if {$do_textconv ne 0} { - # Run textconv with sh -c "..." to allow it to - # contain command + arguments. On windows, just - # call the filter command. - if {![file executable [shellpath]]} { - set fd [open |[linsert $textconv end $path] r] - } else { - set fd [open |[list [shellpath] -c "$textconv \"\$0\"" $path] r] - } + set fd [open_cmd_pipe $textconv $path] } else { set fd [open $path r] } @@ -575,7 +568,11 @@ method _read_file {fd jump} { foreach i $w_columns {$i conf -state disabled} if {[eof $fd]} { - close $fd + fconfigure $fd -blocking 1; # enable error reporting on close + if {[catch {close $fd} err]} { + tk_messageBox -icon error -title [mc Error] \ + -message $err + } # If we don't force Tk to update the widgets *right now* # none of our jump commands will cause a change in the UI. @@ -1065,7 +1062,7 @@ method _gitkcommit {} { set radius [get_config gui.blamehistoryctx] set cmdline [list --select-commit=$cmit] - if {$radius > 0} { + if {$radius > 0} { set author_time {} set committer_time {} @@ -1173,7 +1170,7 @@ method _read_diff_load_commit {fd cparent new_path tline} { } if {[eof $fd]} { - close $fd; + close $fd set current_fd {} _load_new_commit $this \ -- cgit v0.10.2-6-g49f6 From 942e6baa92846e5628752c65a22bc4957d8de4d0 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Tue, 13 Dec 2011 23:44:30 +0000 Subject: git-gui 0.16 Signed-off-by: Pat Thoyts diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 1fb4d9b..6570943 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=0.13.GITGUI +DEF_VER=0.16.GITGUI LF=' ' -- cgit v0.10.2-6-g49f6