From b9bee11526ec23541ddbbd75716bfd1acc241463 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 10 Mar 2008 16:50:34 +1100 Subject: gitk: Only restore window size from ~/.gitk, not position This also limits the window size to the screen size. That is better than nothing, but it isn't perfect, since ideally we would take into account window decorations, and things such as gnome panels or the Mac OS X dock and menu bar, but I don't know how to do that. On Cygwin this is as good as restoring the whole geometry (size and position) at working around the Cygwin Tk bugs, according to Mark Levedahl. Tested-by: Mark Levedahl Signed-off-by: Paul Mackerras --- gitk | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gitk b/gitk index f1f21e97bf..f8f006fa11 100755 --- a/gitk +++ b/gitk @@ -930,9 +930,17 @@ proc makewindow {} { .pwbottom add .bright .ctop add .pwbottom - # restore window position if known + # restore window width & height if known if {[info exists geometry(main)]} { - wm geometry . "$geometry(main)" + if {[scan $geometry(main) "%dx%d" w h] >= 2} { + if {$w > [winfo screenwidth .]} { + set w [winfo screenwidth .] + } + if {$h > [winfo screenheight .]} { + set h [winfo screenheight .] + } + wm geometry . "${w}x$h" + } } if {[tk windowingsystem] eq {aqua}} { -- cgit v1.2.3 From 2d48085661e3f522904a10603e303dbec046a56f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 21 Feb 2008 21:23:31 +0100 Subject: [PATCH] Add an --argscmd flag to get the list of refs to show This allows gitk to be used to display a different set of refs each the display is refreshed. This is useful when gitk is called from other porcelain suites, for doing such things as displaying the set of patches in a patch stack. The user specifies a command as the argument to the --argscmd option. The command is run initially and each time the display is refreshed, and is expected to generate a list of commit IDs, one per line. Those commits are appended to the commits passed on the command-line when constructing the git log command to be executed. The command is considered to be an attribute of a view, and has its own field in the saved view, and an edit field in the view editor. Signed-off-by: Yann Dirson Signed-off-by: Paul Mackerras --- gitk | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/gitk b/gitk index f8f006fa11..bf6485b6e0 100755 --- a/gitk +++ b/gitk @@ -82,7 +82,7 @@ proc dorunq {} { proc start_rev_list {view} { global startmsecs global commfd leftover tclencoding datemode - global viewargs viewfiles commitidx viewcomplete vnextroot + global viewargs viewargscmd viewfiles commitidx viewcomplete vnextroot global showlocalchanges commitinterest mainheadid global progressdirn progresscoords proglastnc curview @@ -90,13 +90,23 @@ proc start_rev_list {view} { set commitidx($view) 0 set viewcomplete($view) 0 set vnextroot($view) 0 + set args $viewargs($view) + if {$viewargscmd($view) ne {}} { + if {[catch { + set str [exec sh -c $viewargscmd($view)] + } err]} { + error_popup "Error executing --argscmd command: $err" + exit 1 + } + set args [concat $args [split $str "\n"]] + } set order "--topo-order" if {$datemode} { set order "--date-order" } if {[catch { set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \ - --boundary $viewargs($view) "--" $viewfiles($view)] r] + --boundary $args "--" $viewfiles($view)] r] } err]} { error_popup "[mc "Error executing git rev-list:"] $err" exit 1 @@ -1168,7 +1178,7 @@ proc savestuff {w} { global canv canv2 canv3 mainfont textfont uifont tabstop global stuffsaved findmergefiles maxgraphpct global maxwidth showneartags showlocalchanges - global viewname viewfiles viewargs viewperm nextviewnum + global viewname viewfiles viewargs viewargscmd viewperm nextviewnum global cmitmode wrapcomment datetimeformat limitdiffs global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor @@ -1207,7 +1217,7 @@ proc savestuff {w} { puts -nonewline $f "set permviews {" for {set v 0} {$v < $nextviewnum} {incr v} { if {$viewperm($v)} { - puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v)]}" + puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}" } } puts $f "}" @@ -1858,7 +1868,7 @@ proc shellsplit {str} { proc newview {ishighlight} { global nextviewnum newviewname newviewperm newishighlight - global newviewargs revtreeargs + global newviewargs revtreeargs viewargscmd newviewargscmd curview set newishighlight $ishighlight set top .gitkview @@ -1869,13 +1879,14 @@ proc newview {ishighlight} { set newviewname($nextviewnum) "View $nextviewnum" set newviewperm($nextviewnum) 0 set newviewargs($nextviewnum) [shellarglist $revtreeargs] + set newviewargscmd($nextviewnum) $viewargscmd($curview) vieweditor $top $nextviewnum [mc "Gitk view definition"] } proc editview {} { global curview global viewname viewperm newviewname newviewperm - global viewargs newviewargs + global viewargs newviewargs viewargscmd newviewargscmd set top .gitkvedit-$curview if {[winfo exists $top]} { @@ -1885,6 +1896,7 @@ proc editview {} { set newviewname($curview) $viewname($curview) set newviewperm($curview) $viewperm($curview) set newviewargs($curview) [shellarglist $viewargs($curview)] + set newviewargscmd($curview) $viewargscmd($curview) vieweditor $top $curview "Gitk: edit view $viewname($curview)" } @@ -1905,6 +1917,14 @@ proc vieweditor {top n title} { entry $top.args -width 50 -textvariable newviewargs($n) \ -background $bgcolor grid $top.args - -sticky ew -padx 5 + + message $top.ac -aspect 1000 \ + -text [mc "Command to generate more commits to include:"] + grid $top.ac - -sticky w -pady 5 + entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \ + -background white + grid $top.argscmd - -sticky ew -padx 5 + message $top.l -aspect 1000 \ -text [mc "Enter files and directories to include, one per line:"] grid $top.l - -sticky w @@ -1948,7 +1968,7 @@ proc allviewmenus {n op args} { proc newviewok {top n} { global nextviewnum newviewperm newviewname newishighlight global viewname viewfiles viewperm selectedview curview - global viewargs newviewargs viewhlmenu + global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu if {[catch { set newargs [shellsplit $newviewargs($n)] @@ -1972,6 +1992,7 @@ proc newviewok {top n} { set viewperm($n) $newviewperm($n) set viewfiles($n) $files set viewargs($n) $newargs + set viewargscmd($n) $newviewargscmd($n) addviewmenu $n if {!$newishighlight} { run showview $n @@ -1988,9 +2009,11 @@ proc newviewok {top n} { # doviewmenu $viewhlmenu 1 [list addvhighlight $n] \ # entryconf [list -label $viewname($n) -value $viewname($n)] } - if {$files ne $viewfiles($n) || $newargs ne $viewargs($n)} { + if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \ + $newviewargscmd($n) ne $viewargscmd($n)} { set viewfiles($n) $files set viewargs($n) $newargs + set viewargscmd($n) $newviewargscmd($n) if {$curview == $n} { run updatecommits } @@ -8530,8 +8553,9 @@ set mergeonly 0 set revtreeargs {} set cmdline_files {} set i 0 +set revtreeargscmd {} foreach arg $argv { - switch -- $arg { + switch -glob -- $arg { "" { } "-d" { set datemode 1 } "--merge" { @@ -8542,6 +8566,9 @@ foreach arg $argv { set cmdline_files [lrange $argv [expr {$i + 1}] end] break } + "--argscmd=*" { + set revtreeargscmd [string range $arg 10 end] + } default { lappend revtreeargs $arg } @@ -8643,6 +8670,7 @@ set highlight_files {} set viewfiles(0) {} set viewperm(0) 0 set viewargs(0) {} +set viewargscmd(0) {} set cmdlineok 0 set stopped 0 @@ -8658,7 +8686,7 @@ tkwait visibility . wm title . "[file tail $argv0]: [file tail [pwd]]" readrefs -if {$cmdline_files ne {} || $revtreeargs ne {}} { +if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} { # create a view for the files/dirs specified on the command line set curview 1 set selectedview 1 @@ -8666,6 +8694,7 @@ if {$cmdline_files ne {} || $revtreeargs ne {}} { set viewname(1) [mc "Command line"] set viewfiles(1) $cmdline_files set viewargs(1) $revtreeargs + set viewargscmd(1) $revtreeargscmd set viewperm(1) 0 addviewmenu 1 .bar.view entryconf [mc "Edit view..."] -state normal @@ -8679,6 +8708,7 @@ if {[info exists permviews]} { set viewname($n) [lindex $v 0] set viewfiles($n) [lindex $v 1] set viewargs($n) [lindex $v 2] + set viewargscmd($n) [lindex $v 3] set viewperm($n) 1 addviewmenu $n } -- cgit v1.2.3 From a3a1f57959c38d5034f17b4f5d06ea3eb1a378e9 Mon Sep 17 00:00:00 2001 From: Michele Ballabio Date: Mon, 3 Mar 2008 21:12:47 +0100 Subject: [PATCH] gitk: Mark another string for translation Signed-off-by: Michele Ballabio Signed-off-by: Paul Mackerras --- gitk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitk b/gitk index bf6485b6e0..aaa35f632b 100755 --- a/gitk +++ b/gitk @@ -1876,7 +1876,7 @@ proc newview {ishighlight} { raise $top return } - set newviewname($nextviewnum) "View $nextviewnum" + set newviewname($nextviewnum) "[mc "View"] $nextviewnum" set newviewperm($nextviewnum) 0 set newviewargs($nextviewnum) [shellarglist $revtreeargs] set newviewargscmd($nextviewnum) $viewargscmd($curview) -- cgit v1.2.3 From 95293b58eb2ac31f93266f9e86ea17c0999d75c9 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 6 Mar 2008 06:49:25 -0500 Subject: [PATCH] gitk: make autoselect optional Whenever a commit is selected in the graph pane, its SHA1 is automatically put into the selection buffer for cut and paste. However, some users may find this behavior annoying since it can overwrite something they actually wanted to keep in the buffer. This makes the behavior optional under the name "Auto-select SHA1", but continues to default to "on". Signed-off-by: Jeff King Signed-off-by: Paul Mackerras --- gitk | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gitk b/gitk index aaa35f632b..d3c95cf915 100755 --- a/gitk +++ b/gitk @@ -1181,6 +1181,7 @@ proc savestuff {w} { global viewname viewfiles viewargs viewargscmd viewperm nextviewnum global cmitmode wrapcomment datetimeformat limitdiffs global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor + global autoselect if {$stuffsaved} return if {![winfo viewable .]} return @@ -1195,6 +1196,7 @@ proc savestuff {w} { puts $f [list set maxwidth $maxwidth] puts $f [list set cmitmode $cmitmode] puts $f [list set wrapcomment $wrapcomment] + puts $f [list set autoselect $autoselect] puts $f [list set showneartags $showneartags] puts $f [list set showlocalchanges $showlocalchanges] puts $f [list set datetimeformat $datetimeformat] @@ -4681,6 +4683,7 @@ proc selectline {l isnew} { global commentend idtags linknum global mergemax numcommits pending_select global cmitmode showneartags allcommits + global autoselect catch {unset pending_select} $canv delete hover @@ -4736,8 +4739,10 @@ proc selectline {l isnew} { set currentid $id $sha1entry delete 0 end $sha1entry insert 0 $id - $sha1entry selection from 0 - $sha1entry selection to end + if {$autoselect} { + $sha1entry selection from 0 + $sha1entry selection to end + } rhighlight_sel $id $ctext conf -state normal @@ -7974,7 +7979,7 @@ proc doprefs {} { global maxwidth maxgraphpct global oldprefs prefstop showneartags showlocalchanges global bgcolor fgcolor ctext diffcolors selectbgcolor - global tabstop limitdiffs + global tabstop limitdiffs autoselect set top .gitkprefs set prefstop $top @@ -8004,6 +8009,11 @@ proc doprefs {} { checkbutton $top.showlocal.b -variable showlocalchanges pack $top.showlocal.b $top.showlocal.l -side left grid x $top.showlocal -sticky w + frame $top.autoselect + label $top.autoselect.l -text [mc "Auto-select SHA1"] -font optionfont + checkbutton $top.autoselect.b -variable autoselect + pack $top.autoselect.b $top.autoselect.l -side left + grid x $top.autoselect -sticky w label $top.ddisp -text [mc "Diff display options"] grid $top.ddisp - -sticky w -pady 10 @@ -8494,6 +8504,7 @@ set maxlinelen 200 set showlocalchanges 1 set limitdiffs 1 set datetimeformat "%Y-%m-%d %H:%M:%S" +set autoselect 1 set colors {green red blue magenta darkgrey brown orange} set bgcolor white -- cgit v1.2.3 From 8809d691ec03f6cb60cb01c8bf00441600d6e757 Mon Sep 17 00:00:00 2001 From: Pekka Kaitaniemi Date: Sat, 8 Mar 2008 14:27:23 +0200 Subject: [PATCH] gitk: Add horizontal scrollbar to the diff view Adding horizontal scroll bar makes the scrolling feature more discoverable to the users. The horizontal scrollbar is a bit narrower than vertical ones so we don't make too big impact on available screen real estate. The text and scrollbar widget layout is done using grid geometry manager. An interesting side effect of Tk scrollbars is that the "elevator" size changes depending on the visible content. So the horizontal scrollbar "elevator" changes as the user scrolls the view up and down. Signed-off-by: Pekka Kaitaniemi Signed-off-by: Paul Mackerras --- gitk | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gitk b/gitk index d3c95cf915..5a78a916e4 100755 --- a/gitk +++ b/gitk @@ -837,6 +837,7 @@ proc makewindow {} { } frame .bleft.top frame .bleft.mid + frame .bleft.bottom button .bleft.top.search -text [mc "Search"] -command dosearch pack .bleft.top.search -side left -padx 5 @@ -864,18 +865,25 @@ proc makewindow {} { checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \ -command changeignorespace -variable ignorespace pack .bleft.mid.ignspace -side left -padx 5 - set ctext .bleft.ctext + set ctext .bleft.bottom.ctext text $ctext -background $bgcolor -foreground $fgcolor \ -state disabled -font textfont \ - -yscrollcommand scrolltext -wrap none + -yscrollcommand scrolltext -wrap none \ + -xscrollcommand ".bleft.bottom.sbhorizontal set" if {$have_tk85} { $ctext conf -tabstyle wordprocessor } - scrollbar .bleft.sb -command "$ctext yview" + scrollbar .bleft.bottom.sb -command "$ctext yview" + scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \ + -width 10 pack .bleft.top -side top -fill x pack .bleft.mid -side top -fill x - pack .bleft.sb -side right -fill y - pack $ctext -side left -fill both -expand 1 + grid $ctext .bleft.bottom.sb -sticky nsew + grid .bleft.bottom.sbhorizontal -sticky ew + grid columnconfigure .bleft.bottom 0 -weight 1 + grid rowconfigure .bleft.bottom 0 -weight 1 + grid rowconfigure .bleft.bottom 1 -weight 0 + pack .bleft.bottom -side top -fill both -expand 1 lappend bglist $ctext lappend fglist $ctext @@ -5640,7 +5648,7 @@ proc searchmarkvisible {doall} { proc scrolltext {f0 f1} { global searchstring - .bleft.sb set $f0 $f1 + .bleft.bottom.sb set $f0 $f1 if {$searchstring ne {}} { searchmarkvisible 0 } -- cgit v1.2.3 From cb8329aa9a6cc2e009d552b1180ce107cec4eb9d Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Mon, 10 Mar 2008 03:54:56 -0700 Subject: [PATCH] gitk: Don't show local changes when we there is no work tree Launching gitk on a bare repository or a .git directory would previously show the work tree as having removed all files. We now inhibit showing local changes when gitk is not launched from within a work tree. Signed-off-by: David Aguilar Signed-off-by: Paul Mackerras --- gitk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitk b/gitk index 5a78a916e4..5d9f589f02 100755 --- a/gitk +++ b/gitk @@ -403,6 +403,9 @@ proc readcommit {id} { proc updatecommits {} { global viewdata curview phase displayorder ordertok idpending global children commitrow selectedline thickerline showneartags + global isworktree + + set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] if {$phase ne {}} { stop_rev_list @@ -2885,8 +2888,9 @@ proc dohidelocalchanges {} { # spawn off a process to do git diff-index --cached HEAD proc dodiffindex {} { global localirow localfrow lserial showlocalchanges + global isworktree - if {!$showlocalchanges} return + if {!$showlocalchanges || !$isworktree} return incr lserial set localfrow -1 set localirow -1 @@ -8698,6 +8702,7 @@ set patchnum 0 set localirow -1 set localfrow -1 set lserial 0 +set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] setcoords makewindow # wait for the window to become visible -- cgit v1.2.3 From 494d3b8a6c93d88daf4a52dbcc6ab07903f8ed4e Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 11 Mar 2008 22:11:19 +1100 Subject: gitk: Avoid Tcl error when switching views Michele Ballabio pointed out that gitk sometimes throws a Tcl error (can't read "yscreen") when switching views, and proposed a patch. This is a different way of fixing it which is a bit neater. Basically, in showview we only set yscreen if the selected commit is on screen to start with, and then we only scroll the canvas to bring it onscreen if yscreen is set and the same commit exists in the new view. Signed-off-by: Paul Mackerras --- gitk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gitk b/gitk index 5d9f589f02..84ab02e15f 100755 --- a/gitk +++ b/gitk @@ -2102,8 +2102,6 @@ proc showview {n} { set ybot [expr {[lindex $span 1] * $ymax}] if {$ytop < $y && $y < $ybot} { set yscreen [expr {$y - $ytop}] - } else { - set yscreen [expr {($ybot - $ytop) / 2}] } } elseif {[info exists pending_select]} { set selid $pending_select @@ -2164,7 +2162,7 @@ proc showview {n} { set yf 0 set row {} set selectfirst 0 - if {$selid ne {} && [info exists commitrow($n,$selid)]} { + if {[info exists yscreen] && [info exists commitrow($n,$selid)]} { set row $commitrow($n,$selid) # try to get the selected row in the same position on the screen set ymax [lindex [$canv cget -scrollregion] 3] -- cgit v1.2.3