Skip to content

Commit 4698ef5

Browse files
committed
Merge git://git.kernel.org/pub/scm/gitk/gitk
* 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
2 parents 1658c61 + 2708d9d commit 4698ef5

File tree

3 files changed

+980
-26
lines changed

3 files changed

+980
-26
lines changed

gitk-git/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gitk_libdir ?= $(sharedir)/gitk/lib
88
msgsdir ?= $(gitk_libdir)/msgs
99
msgsdir_SQ = $(subst ','\'',$(msgsdir))
1010

11+
TCL_PATH ?= tclsh
1112
TCLTK_PATH ?= wish
1213
INSTALL ?= install
1314
RM ?= rm -f
@@ -22,6 +23,9 @@ ifdef NO_MSGFMT
2223
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
2324
else
2425
MSGFMT ?= msgfmt
26+
ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
27+
MSGFMT := $(TCL_PATH) po/po2msg.sh
28+
endif
2529
endif
2630

2731
PO_TEMPLATE = po/gitk.pot

gitk-git/gitk

Lines changed: 86 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,31 @@ proc dorunq {} {
8282
proc start_rev_list {view} {
8383
global startmsecs
8484
global commfd leftover tclencoding datemode
85-
global viewargs viewfiles commitidx viewcomplete vnextroot
85+
global viewargs viewargscmd viewfiles commitidx viewcomplete vnextroot
8686
global showlocalchanges commitinterest mainheadid
8787
global progressdirn progresscoords proglastnc curview
8888

8989
set startmsecs [clock clicks -milliseconds]
9090
set commitidx($view) 0
9191
set viewcomplete($view) 0
9292
set vnextroot($view) 0
93+
set args $viewargs($view)
94+
if {$viewargscmd($view) ne {}} {
95+
if {[catch {
96+
set str [exec sh -c $viewargscmd($view)]
97+
} err]} {
98+
error_popup "Error executing --argscmd command: $err"
99+
exit 1
100+
}
101+
set args [concat $args [split $str "\n"]]
102+
}
93103
set order "--topo-order"
94104
if {$datemode} {
95105
set order "--date-order"
96106
}
97107
if {[catch {
98108
set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \
99-
--boundary $viewargs($view) "--" $viewfiles($view)] r]
109+
--boundary $args "--" $viewfiles($view)] r]
100110
} err]} {
101111
error_popup "[mc "Error executing git rev-list:"] $err"
102112
exit 1
@@ -393,6 +403,9 @@ proc readcommit {id} {
393403
proc updatecommits {} {
394404
global viewdata curview phase displayorder ordertok idpending
395405
global children commitrow selectedline thickerline showneartags
406+
global isworktree
407+
408+
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
396409

397410
if {$phase ne {}} {
398411
stop_rev_list
@@ -827,6 +840,7 @@ proc makewindow {} {
827840
}
828841
frame .bleft.top
829842
frame .bleft.mid
843+
frame .bleft.bottom
830844

831845
button .bleft.top.search -text [mc "Search"] -command dosearch
832846
pack .bleft.top.search -side left -padx 5
@@ -854,18 +868,25 @@ proc makewindow {} {
854868
checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
855869
-command changeignorespace -variable ignorespace
856870
pack .bleft.mid.ignspace -side left -padx 5
857-
set ctext .bleft.ctext
871+
set ctext .bleft.bottom.ctext
858872
text $ctext -background $bgcolor -foreground $fgcolor \
859873
-state disabled -font textfont \
860-
-yscrollcommand scrolltext -wrap none
874+
-yscrollcommand scrolltext -wrap none \
875+
-xscrollcommand ".bleft.bottom.sbhorizontal set"
861876
if {$have_tk85} {
862877
$ctext conf -tabstyle wordprocessor
863878
}
864-
scrollbar .bleft.sb -command "$ctext yview"
879+
scrollbar .bleft.bottom.sb -command "$ctext yview"
880+
scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \
881+
-width 10
865882
pack .bleft.top -side top -fill x
866883
pack .bleft.mid -side top -fill x
867-
pack .bleft.sb -side right -fill y
868-
pack $ctext -side left -fill both -expand 1
884+
grid $ctext .bleft.bottom.sb -sticky nsew
885+
grid .bleft.bottom.sbhorizontal -sticky ew
886+
grid columnconfigure .bleft.bottom 0 -weight 1
887+
grid rowconfigure .bleft.bottom 0 -weight 1
888+
grid rowconfigure .bleft.bottom 1 -weight 0
889+
pack .bleft.bottom -side top -fill both -expand 1
869890
lappend bglist $ctext
870891
lappend fglist $ctext
871892

@@ -930,9 +951,17 @@ proc makewindow {} {
930951
.pwbottom add .bright
931952
.ctop add .pwbottom
932953

933-
# restore window position if known
954+
# restore window width & height if known
934955
if {[info exists geometry(main)]} {
935-
wm geometry . "$geometry(main)"
956+
if {[scan $geometry(main) "%dx%d" w h] >= 2} {
957+
if {$w > [winfo screenwidth .]} {
958+
set w [winfo screenwidth .]
959+
}
960+
if {$h > [winfo screenheight .]} {
961+
set h [winfo screenheight .]
962+
}
963+
wm geometry . "${w}x$h"
964+
}
936965
}
937966

938967
if {[tk windowingsystem] eq {aqua}} {
@@ -1160,9 +1189,10 @@ proc savestuff {w} {
11601189
global canv canv2 canv3 mainfont textfont uifont tabstop
11611190
global stuffsaved findmergefiles maxgraphpct
11621191
global maxwidth showneartags showlocalchanges
1163-
global viewname viewfiles viewargs viewperm nextviewnum
1192+
global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
11641193
global cmitmode wrapcomment datetimeformat limitdiffs
11651194
global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
1195+
global autoselect
11661196

11671197
if {$stuffsaved} return
11681198
if {![winfo viewable .]} return
@@ -1177,6 +1207,7 @@ proc savestuff {w} {
11771207
puts $f [list set maxwidth $maxwidth]
11781208
puts $f [list set cmitmode $cmitmode]
11791209
puts $f [list set wrapcomment $wrapcomment]
1210+
puts $f [list set autoselect $autoselect]
11801211
puts $f [list set showneartags $showneartags]
11811212
puts $f [list set showlocalchanges $showlocalchanges]
11821213
puts $f [list set datetimeformat $datetimeformat]
@@ -1199,7 +1230,7 @@ proc savestuff {w} {
11991230
puts -nonewline $f "set permviews {"
12001231
for {set v 0} {$v < $nextviewnum} {incr v} {
12011232
if {$viewperm($v)} {
1202-
puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v)]}"
1233+
puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}"
12031234
}
12041235
}
12051236
puts $f "}"
@@ -1850,24 +1881,25 @@ proc shellsplit {str} {
18501881

18511882
proc newview {ishighlight} {
18521883
global nextviewnum newviewname newviewperm newishighlight
1853-
global newviewargs revtreeargs
1884+
global newviewargs revtreeargs viewargscmd newviewargscmd curview
18541885

18551886
set newishighlight $ishighlight
18561887
set top .gitkview
18571888
if {[winfo exists $top]} {
18581889
raise $top
18591890
return
18601891
}
1861-
set newviewname($nextviewnum) "View $nextviewnum"
1892+
set newviewname($nextviewnum) "[mc "View"] $nextviewnum"
18621893
set newviewperm($nextviewnum) 0
18631894
set newviewargs($nextviewnum) [shellarglist $revtreeargs]
1895+
set newviewargscmd($nextviewnum) $viewargscmd($curview)
18641896
vieweditor $top $nextviewnum [mc "Gitk view definition"]
18651897
}
18661898

18671899
proc editview {} {
18681900
global curview
18691901
global viewname viewperm newviewname newviewperm
1870-
global viewargs newviewargs
1902+
global viewargs newviewargs viewargscmd newviewargscmd
18711903

18721904
set top .gitkvedit-$curview
18731905
if {[winfo exists $top]} {
@@ -1877,6 +1909,7 @@ proc editview {} {
18771909
set newviewname($curview) $viewname($curview)
18781910
set newviewperm($curview) $viewperm($curview)
18791911
set newviewargs($curview) [shellarglist $viewargs($curview)]
1912+
set newviewargscmd($curview) $viewargscmd($curview)
18801913
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
18811914
}
18821915

@@ -1897,6 +1930,14 @@ proc vieweditor {top n title} {
18971930
entry $top.args -width 50 -textvariable newviewargs($n) \
18981931
-background $bgcolor
18991932
grid $top.args - -sticky ew -padx 5
1933+
1934+
message $top.ac -aspect 1000 \
1935+
-text [mc "Command to generate more commits to include:"]
1936+
grid $top.ac - -sticky w -pady 5
1937+
entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \
1938+
-background white
1939+
grid $top.argscmd - -sticky ew -padx 5
1940+
19001941
message $top.l -aspect 1000 \
19011942
-text [mc "Enter files and directories to include, one per line:"]
19021943
grid $top.l - -sticky w
@@ -1940,7 +1981,7 @@ proc allviewmenus {n op args} {
19401981
proc newviewok {top n} {
19411982
global nextviewnum newviewperm newviewname newishighlight
19421983
global viewname viewfiles viewperm selectedview curview
1943-
global viewargs newviewargs viewhlmenu
1984+
global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu
19441985

19451986
if {[catch {
19461987
set newargs [shellsplit $newviewargs($n)]
@@ -1964,6 +2005,7 @@ proc newviewok {top n} {
19642005
set viewperm($n) $newviewperm($n)
19652006
set viewfiles($n) $files
19662007
set viewargs($n) $newargs
2008+
set viewargscmd($n) $newviewargscmd($n)
19672009
addviewmenu $n
19682010
if {!$newishighlight} {
19692011
run showview $n
@@ -1980,9 +2022,11 @@ proc newviewok {top n} {
19802022
# doviewmenu $viewhlmenu 1 [list addvhighlight $n] \
19812023
# entryconf [list -label $viewname($n) -value $viewname($n)]
19822024
}
1983-
if {$files ne $viewfiles($n) || $newargs ne $viewargs($n)} {
2025+
if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
2026+
$newviewargscmd($n) ne $viewargscmd($n)} {
19842027
set viewfiles($n) $files
19852028
set viewargs($n) $newargs
2029+
set viewargscmd($n) $newviewargscmd($n)
19862030
if {$curview == $n} {
19872031
run updatecommits
19882032
}
@@ -2058,8 +2102,6 @@ proc showview {n} {
20582102
set ybot [expr {[lindex $span 1] * $ymax}]
20592103
if {$ytop < $y && $y < $ybot} {
20602104
set yscreen [expr {$y - $ytop}]
2061-
} else {
2062-
set yscreen [expr {($ybot - $ytop) / 2}]
20632105
}
20642106
} elseif {[info exists pending_select]} {
20652107
set selid $pending_select
@@ -2120,7 +2162,7 @@ proc showview {n} {
21202162
set yf 0
21212163
set row {}
21222164
set selectfirst 0
2123-
if {$selid ne {} && [info exists commitrow($n,$selid)]} {
2165+
if {[info exists yscreen] && [info exists commitrow($n,$selid)]} {
21242166
set row $commitrow($n,$selid)
21252167
# try to get the selected row in the same position on the screen
21262168
set ymax [lindex [$canv cget -scrollregion] 3]
@@ -2844,8 +2886,9 @@ proc dohidelocalchanges {} {
28442886
# spawn off a process to do git diff-index --cached HEAD
28452887
proc dodiffindex {} {
28462888
global localirow localfrow lserial showlocalchanges
2889+
global isworktree
28472890

2848-
if {!$showlocalchanges} return
2891+
if {!$showlocalchanges || !$isworktree} return
28492892
incr lserial
28502893
set localfrow -1
28512894
set localirow -1
@@ -4650,6 +4693,7 @@ proc selectline {l isnew} {
46504693
global commentend idtags linknum
46514694
global mergemax numcommits pending_select
46524695
global cmitmode showneartags allcommits
4696+
global autoselect
46534697

46544698
catch {unset pending_select}
46554699
$canv delete hover
@@ -4705,8 +4749,10 @@ proc selectline {l isnew} {
47054749
set currentid $id
47064750
$sha1entry delete 0 end
47074751
$sha1entry insert 0 $id
4708-
$sha1entry selection from 0
4709-
$sha1entry selection to end
4752+
if {$autoselect} {
4753+
$sha1entry selection from 0
4754+
$sha1entry selection to end
4755+
}
47104756
rhighlight_sel $id
47114757

47124758
$ctext conf -state normal
@@ -5604,7 +5650,7 @@ proc searchmarkvisible {doall} {
56045650
proc scrolltext {f0 f1} {
56055651
global searchstring
56065652

5607-
.bleft.sb set $f0 $f1
5653+
.bleft.bottom.sb set $f0 $f1
56085654
if {$searchstring ne {}} {
56095655
searchmarkvisible 0
56105656
}
@@ -7943,7 +7989,7 @@ proc doprefs {} {
79437989
global maxwidth maxgraphpct
79447990
global oldprefs prefstop showneartags showlocalchanges
79457991
global bgcolor fgcolor ctext diffcolors selectbgcolor
7946-
global tabstop limitdiffs
7992+
global tabstop limitdiffs autoselect
79477993

79487994
set top .gitkprefs
79497995
set prefstop $top
@@ -7973,6 +8019,11 @@ proc doprefs {} {
79738019
checkbutton $top.showlocal.b -variable showlocalchanges
79748020
pack $top.showlocal.b $top.showlocal.l -side left
79758021
grid x $top.showlocal -sticky w
8022+
frame $top.autoselect
8023+
label $top.autoselect.l -text [mc "Auto-select SHA1"] -font optionfont
8024+
checkbutton $top.autoselect.b -variable autoselect
8025+
pack $top.autoselect.b $top.autoselect.l -side left
8026+
grid x $top.autoselect -sticky w
79768027

79778028
label $top.ddisp -text [mc "Diff display options"]
79788029
grid $top.ddisp - -sticky w -pady 10
@@ -8463,6 +8514,7 @@ set maxlinelen 200
84638514
set showlocalchanges 1
84648515
set limitdiffs 1
84658516
set datetimeformat "%Y-%m-%d %H:%M:%S"
8517+
set autoselect 1
84668518

84678519
set colors {green red blue magenta darkgrey brown orange}
84688520
set bgcolor white
@@ -8522,8 +8574,9 @@ set mergeonly 0
85228574
set revtreeargs {}
85238575
set cmdline_files {}
85248576
set i 0
8577+
set revtreeargscmd {}
85258578
foreach arg $argv {
8526-
switch -- $arg {
8579+
switch -glob -- $arg {
85278580
"" { }
85288581
"-d" { set datemode 1 }
85298582
"--merge" {
@@ -8534,6 +8587,9 @@ foreach arg $argv {
85348587
set cmdline_files [lrange $argv [expr {$i + 1}] end]
85358588
break
85368589
}
8590+
"--argscmd=*" {
8591+
set revtreeargscmd [string range $arg 10 end]
8592+
}
85378593
default {
85388594
lappend revtreeargs $arg
85398595
}
@@ -8635,6 +8691,7 @@ set highlight_files {}
86358691
set viewfiles(0) {}
86368692
set viewperm(0) 0
86378693
set viewargs(0) {}
8694+
set viewargscmd(0) {}
86388695

86398696
set cmdlineok 0
86408697
set stopped 0
@@ -8643,21 +8700,23 @@ set patchnum 0
86438700
set localirow -1
86448701
set localfrow -1
86458702
set lserial 0
8703+
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
86468704
setcoords
86478705
makewindow
86488706
# wait for the window to become visible
86498707
tkwait visibility .
86508708
wm title . "[file tail $argv0]: [file tail [pwd]]"
86518709
readrefs
86528710

8653-
if {$cmdline_files ne {} || $revtreeargs ne {}} {
8711+
if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
86548712
# create a view for the files/dirs specified on the command line
86558713
set curview 1
86568714
set selectedview 1
86578715
set nextviewnum 2
86588716
set viewname(1) [mc "Command line"]
86598717
set viewfiles(1) $cmdline_files
86608718
set viewargs(1) $revtreeargs
8719+
set viewargscmd(1) $revtreeargscmd
86618720
set viewperm(1) 0
86628721
addviewmenu 1
86638722
.bar.view entryconf [mc "Edit view..."] -state normal
@@ -8671,6 +8730,7 @@ if {[info exists permviews]} {
86718730
set viewname($n) [lindex $v 0]
86728731
set viewfiles($n) [lindex $v 1]
86738732
set viewargs($n) [lindex $v 2]
8733+
set viewargscmd($n) [lindex $v 3]
86748734
set viewperm($n) 1
86758735
addviewmenu $n
86768736
}

0 commit comments

Comments
 (0)