Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/gitk/gitk
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/gitk/gitk:
  gitk: initial Italian translation
  gitk: Default to using po2msg.sh if msgfmt doesn't grok --tcl, -l and -d
  gitk: Avoid Tcl error when switching views
  [PATCH] gitk: Don't show local changes when we there is no work tree
  [PATCH] gitk: Add horizontal scrollbar to the diff view
  [PATCH] gitk: make autoselect optional
  [PATCH] gitk: Mark another string for translation
  [PATCH] Add an --argscmd flag to get the list of refs to show
  gitk: Only restore window size from ~/.gitk, not position
  • Loading branch information
gitster committed Mar 15, 2008
2 parents 1658c61 + 2708d9d commit 4698ef5
Show file tree
Hide file tree
Showing 3 changed files with 980 additions and 26 deletions.
4 changes: 4 additions & 0 deletions gitk-git/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gitk_libdir ?= $(sharedir)/gitk/lib
msgsdir ?= $(gitk_libdir)/msgs
msgsdir_SQ = $(subst ','\'',$(msgsdir))

TCL_PATH ?= tclsh
TCLTK_PATH ?= wish
INSTALL ?= install
RM ?= rm -f
Expand All @@ -22,6 +23,9 @@ ifdef NO_MSGFMT
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
else
MSGFMT ?= msgfmt
ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
MSGFMT := $(TCL_PATH) po/po2msg.sh
endif
endif

PO_TEMPLATE = po/gitk.pot
Expand Down
112 changes: 86 additions & 26 deletions gitk-git/gitk
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,31 @@ 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

set startmsecs [clock clicks -milliseconds]
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
Expand Down Expand Up @@ -393,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
Expand Down Expand Up @@ -827,6 +840,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
Expand Down Expand Up @@ -854,18 +868,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

Expand Down Expand Up @@ -930,9 +951,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}} {
Expand Down Expand Up @@ -1160,9 +1189,10 @@ 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
global autoselect

if {$stuffsaved} return
if {![winfo viewable .]} return
Expand All @@ -1177,6 +1207,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]
Expand All @@ -1199,7 +1230,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 "}"
Expand Down Expand Up @@ -1850,24 +1881,25 @@ 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
if {[winfo exists $top]} {
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)
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]} {
Expand All @@ -1877,6 +1909,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)"
}

Expand All @@ -1897,6 +1930,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
Expand Down Expand Up @@ -1940,7 +1981,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)]
Expand All @@ -1964,6 +2005,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
Expand All @@ -1980,9 +2022,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
}
Expand Down Expand Up @@ -2058,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
Expand Down Expand Up @@ -2120,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]
Expand Down Expand Up @@ -2844,8 +2886,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
Expand Down Expand Up @@ -4650,6 +4693,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
Expand Down Expand Up @@ -4705,8 +4749,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
Expand Down Expand Up @@ -5604,7 +5650,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
}
Expand Down Expand Up @@ -7943,7 +7989,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
Expand Down Expand Up @@ -7973,6 +8019,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
Expand Down Expand Up @@ -8463,6 +8514,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
Expand Down Expand Up @@ -8522,8 +8574,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" {
Expand All @@ -8534,6 +8587,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
}
Expand Down Expand Up @@ -8635,6 +8691,7 @@ set highlight_files {}
set viewfiles(0) {}
set viewperm(0) 0
set viewargs(0) {}
set viewargscmd(0) {}

set cmdlineok 0
set stopped 0
Expand All @@ -8643,21 +8700,23 @@ 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
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
set nextviewnum 2
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
Expand All @@ -8671,6 +8730,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
}
Expand Down
Loading

0 comments on commit 4698ef5

Please sign in to comment.