summaryrefslogtreecommitdiff
path: root/gitk-git/gitk
diff options
context:
space:
mode:
Diffstat (limited to 'gitk-git/gitk')
-rwxr-xr-xgitk-git/gitk869
1 files changed, 640 insertions, 229 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 64ef3c4013..5cd00d80fe 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -14,6 +14,35 @@ proc hasworktree {} {
[exec git rev-parse --is-inside-git-dir] == "false"}]
}
+proc reponame {} {
+ global gitdir
+ set n [file normalize $gitdir]
+ if {[string match "*/.git" $n]} {
+ set n [string range $n 0 end-5]
+ }
+ return [file tail $n]
+}
+
+proc gitworktree {} {
+ variable _gitworktree
+ if {[info exists _gitworktree]} {
+ return $_gitworktree
+ }
+ # v1.7.0 introduced --show-toplevel to return the canonical work-tree
+ if {[catch {set _gitworktree [exec git rev-parse --show-toplevel]}]} {
+ # try to set work tree from environment, core.worktree or use
+ # cdup to obtain a relative path to the top of the worktree. If
+ # run from the top, the ./ prefix ensures normalize expands pwd.
+ if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
+ catch {set _gitworktree [exec git config --get core.worktree]}
+ if {$_gitworktree eq ""} {
+ set _gitworktree [file normalize ./[exec git rev-parse --show-cdup]]
+ }
+ }
+ }
+ return $_gitworktree
+}
+
# A simple scheduler for compute-intensive stuff.
# The aim is to make sure that event handlers for GUI actions can
# run at least every 50-100 ms. Unfortunately fileevent handlers are
@@ -612,12 +641,16 @@ proc varcinit {view} {
proc resetvarcs {view} {
global varcid varccommits parents children vseedcount ordertok
+ global vshortids
foreach vid [array names varcid $view,*] {
unset varcid($vid)
unset children($vid)
unset parents($vid)
}
+ foreach vid [array names vshortids $view,*] {
+ unset vshortids($vid)
+ }
# some commits might have children but haven't been seen yet
foreach vid [array names children $view,*] {
unset children($vid)
@@ -904,7 +937,7 @@ proc fix_reversal {p a v} {
proc insertrow {id p v} {
global cmitlisted children parents varcid varctok vtokmod
global varccommits ordertok commitidx numcommits curview
- global targetid targetrow
+ global targetid targetrow vshortids
readcommit $id
set vid $v,$id
@@ -913,6 +946,7 @@ proc insertrow {id p v} {
set parents($vid) [list $p]
set a [newvarc $v $id]
set varcid($vid) $a
+ lappend vshortids($v,[string range $id 0 3]) $id
if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
modify_arc $v $a
}
@@ -1368,7 +1402,7 @@ proc getcommitlines {fd inst view updating} {
global commitidx commitdata vdatemode
global parents children curview hlview
global idpending ordertok
- global varccommits varcid varctok vtokmod vfilelimit
+ global varccommits varcid varctok vtokmod vfilelimit vshortids
set stuff [read $fd 500000]
# git log doesn't terminate the last commit with a null...
@@ -1468,6 +1502,8 @@ proc getcommitlines {fd inst view updating} {
set id [lindex $ids 0]
set vid $view,$id
+ lappend vshortids($view,[string range $id 0 3]) $id
+
if {!$listed && $updating && ![info exists varcid($vid)] &&
$vfilelimit($view) ne {}} {
# git log doesn't rewrite parents for unlisted commits
@@ -1690,11 +1726,26 @@ proc getcommit {id} {
# and are present in the current view.
# This is fairly slow...
proc longid {prefix} {
- global varcid curview
+ global varcid curview vshortids
set ids {}
- foreach match [array names varcid "$curview,$prefix*"] {
- lappend ids [lindex [split $match ","] 1]
+ if {[string length $prefix] >= 4} {
+ set vshortid $curview,[string range $prefix 0 3]
+ if {[info exists vshortids($vshortid)]} {
+ foreach id $vshortids($vshortid) {
+ if {[string match "$prefix*" $id]} {
+ if {[lsearch -exact $ids $id] < 0} {
+ lappend ids $id
+ if {[llength $ids] >= 2} break
+ }
+ }
+ }
+ }
+ } else {
+ foreach match [array names varcid "$curview,$prefix*"] {
+ lappend ids [lindex [split $match ","] 1]
+ if {[llength $ids] >= 2} break
+ }
}
return $ids
}
@@ -1947,6 +1998,9 @@ proc mca {str} {
return [string map {&& & & {}} [mc $str]]
}
+proc cleardropsel {w} {
+ $w selection clear
+}
proc makedroplist {w varname args} {
global use_ttk
if {$use_ttk} {
@@ -1956,7 +2010,9 @@ proc makedroplist {w varname args} {
if {$cx > $width} {set width $cx}
}
set gm [ttk::combobox $w -width $width -state readonly\
- -textvariable $varname -values $args]
+ -textvariable $varname -values $args \
+ -exportselection false]
+ bind $gm <<ComboboxSelected>> [list $gm selection clear]
} else {
set gm [eval [linsert $args 0 tk_optionMenu $w $varname]]
}
@@ -1975,6 +2031,9 @@ proc makewindow {} {
global highlight_files gdttype
global searchstring sstring
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
+ global uifgcolor uifgdisabledcolor
+ global filesepbgcolor filesepfgcolor
+ global mergecolors foundbgcolor currentsearchhitbgcolor
global headctxmenu progresscanv progressitem progresscoords statusw
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord rownumsel numcommits
@@ -1987,7 +2046,7 @@ proc makewindow {} {
set file {
mc "File" cascade {
{mc "Update" command updatecommits -accelerator F5}
- {mc "Reload" command reloadcommits -accelerator Meta1-F5}
+ {mc "Reload" command reloadcommits -accelerator Shift-F5}
{mc "Reread references" command rereadrefs}
{mc "List references" command showrefs -accelerator F2}
{xx "" separator}
@@ -2110,7 +2169,7 @@ proc makewindow {} {
trace add variable sha1string write sha1change
pack $sha1entry -side left -pady 2
- image create bitmap bm-left -data {
+ set bm_left_data {
#define left_width 16
#define left_height 16
static unsigned char left_bits[] = {
@@ -2118,7 +2177,7 @@ proc makewindow {} {
0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
}
- image create bitmap bm-right -data {
+ set bm_right_data {
#define right_width 16
#define right_height 16
static unsigned char right_bits[] = {
@@ -2126,11 +2185,24 @@ proc makewindow {} {
0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
}
- ${NS}::button .tf.bar.leftbut -image bm-left -command goback \
- -state disabled -width 26
+ image create bitmap bm-left -data $bm_left_data -foreground $uifgcolor
+ image create bitmap bm-left-gray -data $bm_left_data -foreground $uifgdisabledcolor
+ image create bitmap bm-right -data $bm_right_data -foreground $uifgcolor
+ image create bitmap bm-right-gray -data $bm_right_data -foreground $uifgdisabledcolor
+
+ ${NS}::button .tf.bar.leftbut -command goback -state disabled -width 26
+ if {$use_ttk} {
+ .tf.bar.leftbut configure -image [list bm-left disabled bm-left-gray]
+ } else {
+ .tf.bar.leftbut configure -image bm-left
+ }
pack .tf.bar.leftbut -side left -fill y
- ${NS}::button .tf.bar.rightbut -image bm-right -command goforw \
- -state disabled -width 26
+ ${NS}::button .tf.bar.rightbut -command goforw -state disabled -width 26
+ if {$use_ttk} {
+ .tf.bar.rightbut configure -image [list bm-right disabled bm-right-gray]
+ } else {
+ .tf.bar.rightbut configure -image bm-right
+ }
pack .tf.bar.rightbut -side left -fill y
${NS}::label .tf.bar.rowlabel -text [mc "Row"]
@@ -2181,7 +2253,8 @@ proc makewindow {} {
set gm [makedroplist .tf.lbar.gdttype gdttype \
[mc "containing:"] \
[mc "touching paths:"] \
- [mc "adding/removing string:"]]
+ [mc "adding/removing string:"] \
+ [mc "changing lines matching:"]]
trace add variable gdttype write gdttype_change
pack .tf.lbar.gdttype -side left -fill y
@@ -2285,31 +2358,33 @@ proc makewindow {} {
lappend fglist $ctext
$ctext tag conf comment -wrap $wrapcomment
- $ctext tag conf filesep -font textfontbold -back "#aaaaaa"
+ $ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor
$ctext tag conf hunksep -fore [lindex $diffcolors 2]
$ctext tag conf d0 -fore [lindex $diffcolors 0]
$ctext tag conf dresult -fore [lindex $diffcolors 1]
- $ctext tag conf m0 -fore red
- $ctext tag conf m1 -fore blue
- $ctext tag conf m2 -fore green
- $ctext tag conf m3 -fore purple
- $ctext tag conf m4 -fore brown
- $ctext tag conf m5 -fore "#009090"
- $ctext tag conf m6 -fore magenta
- $ctext tag conf m7 -fore "#808000"
- $ctext tag conf m8 -fore "#009000"
- $ctext tag conf m9 -fore "#ff0080"
- $ctext tag conf m10 -fore cyan
- $ctext tag conf m11 -fore "#b07070"
- $ctext tag conf m12 -fore "#70b0f0"
- $ctext tag conf m13 -fore "#70f0b0"
- $ctext tag conf m14 -fore "#f0b070"
- $ctext tag conf m15 -fore "#ff70b0"
+ $ctext tag conf m0 -fore [lindex $mergecolors 0]
+ $ctext tag conf m1 -fore [lindex $mergecolors 1]
+ $ctext tag conf m2 -fore [lindex $mergecolors 2]
+ $ctext tag conf m3 -fore [lindex $mergecolors 3]
+ $ctext tag conf m4 -fore [lindex $mergecolors 4]
+ $ctext tag conf m5 -fore [lindex $mergecolors 5]
+ $ctext tag conf m6 -fore [lindex $mergecolors 6]
+ $ctext tag conf m7 -fore [lindex $mergecolors 7]
+ $ctext tag conf m8 -fore [lindex $mergecolors 8]
+ $ctext tag conf m9 -fore [lindex $mergecolors 9]
+ $ctext tag conf m10 -fore [lindex $mergecolors 10]
+ $ctext tag conf m11 -fore [lindex $mergecolors 11]
+ $ctext tag conf m12 -fore [lindex $mergecolors 12]
+ $ctext tag conf m13 -fore [lindex $mergecolors 13]
+ $ctext tag conf m14 -fore [lindex $mergecolors 14]
+ $ctext tag conf m15 -fore [lindex $mergecolors 15]
$ctext tag conf mmax -fore darkgrey
set mergemax 16
$ctext tag conf mresult -font textfontbold
$ctext tag conf msep -font textfontbold
- $ctext tag conf found -back yellow
+ $ctext tag conf found -back $foundbgcolor
+ $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor
+ $ctext tag conf wwrap -wrap word
.pwbottom add .bleft
if {!$use_ttk} {
@@ -2444,10 +2519,9 @@ proc makewindow {} {
bindkey ? {dofind -1 1}
bindkey f nextfile
bind . <F5> updatecommits
- bind . <$M1B-F5> reloadcommits
+ bindmodfunctionkey Shift 5 reloadcommits
bind . <F2> showrefs
- bind . <Shift-F4> {newview 0}
- catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }
+ bindmodfunctionkey Shift 4 {newview 0}
bind . <F4> edit_or_newview
bind . <$M1B-q> doquit
bind . <$M1B-f> {dofind 1 1}
@@ -2472,6 +2546,7 @@ proc makewindow {} {
bind $cflist $ctxbut {pop_flist_menu %W %X %Y %x %y}
bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y}
bind $ctext <Button-1> {focus %W}
+ bind $ctext <<Selection>> rehighlight_search_results
set maincursor [. cget -cursor]
set textcursor [$ctext cget -cursor]
@@ -2491,6 +2566,9 @@ proc makewindow {} {
{mc "Return to mark" command gotomark}
{mc "Find descendant of this and mark" command find_common_desc}
{mc "Compare with marked commit" command compare_commits}
+ {mc "Diff this -> marked commit" command {diffvsmark 0}}
+ {mc "Diff marked commit -> this" command {diffvsmark 1}}
+ {mc "Revert this commit" command revert}
}
$rowctxmenu configure -tearoff 0
@@ -2499,6 +2577,8 @@ proc makewindow {} {
{mc "Diff this -> selected" command {diffvssel 0}}
{mc "Diff selected -> this" command {diffvssel 1}}
{mc "Make patch" command mkpatch}
+ {mc "Diff this -> marked commit" command {diffvsmark 0}}
+ {mc "Diff marked commit -> this" command {diffvsmark 1}}
}
$fakerowmenu configure -tearoff 0
@@ -2591,6 +2671,11 @@ proc bindkey {ev script} {
}
}
+proc bindmodfunctionkey {mod n script} {
+ bind . <$mod-F$n> $script
+ catch { bind . <$mod-XF86_Switch_VT_$n> $script }
+}
+
# set the focus back to the toplevel for any click outside
# the entry widgets
proc click {w} {
@@ -2646,8 +2731,16 @@ proc savestuff {w} {
global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
global cmitmode wrapcomment datetimeformat limitdiffs
global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor
+ global uifgcolor uifgdisabledcolor
+ global headbgcolor headfgcolor headoutlinecolor remotebgcolor
+ global tagbgcolor tagfgcolor tagoutlinecolor
+ global reflinecolor filesepbgcolor filesepfgcolor
+ global mergecolors foundbgcolor currentsearchhitbgcolor
+ global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor circlecolors
+ global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
+ global linkfgcolor circleoutlinecolor
global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
- global hideremotes want_ttk
+ global hideremotes want_ttk maxrefs
if {$stuffsaved} return
if {![winfo viewable .]} return
@@ -2669,6 +2762,7 @@ proc savestuff {w} {
puts $f [list set autoselect $autoselect]
puts $f [list set autosellen $autosellen]
puts $f [list set showneartags $showneartags]
+ puts $f [list set maxrefs $maxrefs]
puts $f [list set hideremotes $hideremotes]
puts $f [list set showlocalchanges $showlocalchanges]
puts $f [list set datetimeformat $datetimeformat]
@@ -2677,13 +2771,37 @@ proc savestuff {w} {
puts $f [list set want_ttk $want_ttk]
puts $f [list set bgcolor $bgcolor]
puts $f [list set fgcolor $fgcolor]
+ puts $f [list set uifgcolor $uifgcolor]
+ puts $f [list set uifgdisabledcolor $uifgdisabledcolor]
puts $f [list set colors $colors]
puts $f [list set diffcolors $diffcolors]
+ puts $f [list set mergecolors $mergecolors]
puts $f [list set markbgcolor $markbgcolor]
puts $f [list set diffcontext $diffcontext]
puts $f [list set selectbgcolor $selectbgcolor]
+ puts $f [list set foundbgcolor $foundbgcolor]
+ puts $f [list set currentsearchhitbgcolor $currentsearchhitbgcolor]
puts $f [list set extdifftool $extdifftool]
puts $f [list set perfile_attrs $perfile_attrs]
+ puts $f [list set headbgcolor $headbgcolor]
+ puts $f [list set headfgcolor $headfgcolor]
+ puts $f [list set headoutlinecolor $headoutlinecolor]
+ puts $f [list set remotebgcolor $remotebgcolor]
+ puts $f [list set tagbgcolor $tagbgcolor]
+ puts $f [list set tagfgcolor $tagfgcolor]
+ puts $f [list set tagoutlinecolor $tagoutlinecolor]
+ puts $f [list set reflinecolor $reflinecolor]
+ puts $f [list set filesepbgcolor $filesepbgcolor]
+ puts $f [list set filesepfgcolor $filesepfgcolor]
+ puts $f [list set linehoverbgcolor $linehoverbgcolor]
+ puts $f [list set linehoverfgcolor $linehoverfgcolor]
+ puts $f [list set linehoveroutlinecolor $linehoveroutlinecolor]
+ puts $f [list set mainheadcirclecolor $mainheadcirclecolor]
+ puts $f [list set workingfilescirclecolor $workingfilescirclecolor]
+ puts $f [list set indexcirclecolor $indexcirclecolor]
+ puts $f [list set circlecolors $circlecolors]
+ puts $f [list set linkfgcolor $linkfgcolor]
+ puts $f [list set circleoutlinecolor $circleoutlinecolor]
puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(state) [wm state .]"
@@ -3254,6 +3372,7 @@ proc sel_flist {w x y} {
} else {
catch {$ctext yview [lindex $difffilestart [expr {$l - 2}]]}
}
+ suppress_highlighting_file_for_current_scrollpos
}
proc pop_flist_menu {w X Y x y} {
@@ -4540,6 +4659,8 @@ proc do_file_hl {serial} {
set gdtargs [concat -- $relative_paths]
} elseif {$gdttype eq [mc "adding/removing string:"]} {
set gdtargs [list "-S$highlight_files"]
+ } elseif {$gdttype eq [mc "changing lines matching:"]} {
+ set gdtargs [list "-G$highlight_files"]
} else {
# must be "containing:", i.e. we're searching commit info
return
@@ -4630,8 +4751,9 @@ proc askfindhighlight {row id} {
}
set info $commitinfo($id)
set isbold 0
- set fldtypes [list [mc Headline] [mc Author] [mc Date] [mc Committer] [mc CDate] [mc Comments]]
+ set fldtypes [list [mc Headline] [mc Author] "" [mc Committer] "" [mc Comments]]
foreach f $info ty $fldtypes {
+ if {$ty eq ""} continue
if {($findloc eq [mc "All fields"] || $findloc eq $ty) &&
[doesmatch $f]} {
if {$ty eq [mc "Author"]} {
@@ -5847,15 +5969,17 @@ proc drawcmittext {id row col} {
global linehtag linentag linedtag selectedline
global canvxmax boldids boldnameids fgcolor markedid
global mainheadid nullid nullid2 circleitem circlecolors ctxbut
+ global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
+ global circleoutlinecolor
# listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
set listed $cmitlisted($curview,$id)
if {$id eq $nullid} {
- set ofill red
+ set ofill $workingfilescirclecolor
} elseif {$id eq $nullid2} {
- set ofill green
+ set ofill $indexcirclecolor
} elseif {$id eq $mainheadid} {
- set ofill yellow
+ set ofill $mainheadcirclecolor
} else {
set ofill [lindex $circlecolors $listed]
}
@@ -5865,21 +5989,21 @@ proc drawcmittext {id row col} {
if {$listed <= 2} {
set t [$canv create oval [expr {$x - $orad}] [expr {$y - $orad}] \
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
} elseif {$listed == 3} {
# triangle pointing left for left-side commits
set t [$canv create polygon \
[expr {$x - $orad}] $y \
[expr {$x + $orad - 1}] [expr {$y - $orad}] \
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
} else {
# triangle pointing right for right-side commits
set t [$canv create polygon \
[expr {$x + $orad - 1}] $y \
[expr {$x - $orad}] [expr {$y - $orad}] \
[expr {$x - $orad}] [expr {$y + $orad - 1}] \
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
}
set circleitem($row) $t
$canv raise $t
@@ -6267,6 +6391,9 @@ proc drawtags {id x xt y1} {
global idtags idheads idotherrefs mainhead
global linespc lthickness
global canv rowtextx curview fgcolor bgcolor ctxbut
+ global headbgcolor headfgcolor headoutlinecolor remotebgcolor
+ global tagbgcolor tagfgcolor tagoutlinecolor
+ global reflinecolor
set marks {}
set ntags 0
@@ -6304,7 +6431,7 @@ proc drawtags {id x xt y1} {
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
}
set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
- -width $lthickness -fill black -tags tag.$id]
+ -width $lthickness -fill $reflinecolor -tags tag.$id]
$canv lower $t
foreach tag $marks x $xvals wid $wvals {
set tag_quoted [string map {% %%} $tag]
@@ -6315,13 +6442,14 @@ proc drawtags {id x xt y1} {
# draw a tag
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
- -width 1 -outline black -fill yellow -tags tag.$id]
+ -width 1 -outline $tagoutlinecolor -fill $tagbgcolor \
+ -tags tag.$id]
$canv bind $t <1> [list showtag $tag_quoted 1]
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
} else {
# draw a head or other ref
if {[incr nheads -1] >= 0} {
- set col green
+ set col $headbgcolor
if {$tag eq $mainhead} {
set font mainfontbold
}
@@ -6337,10 +6465,10 @@ proc drawtags {id x xt y1} {
set yti [expr {$yt + 1}]
set xri [expr {$x + $rwid}]
$canv create polygon $xi $yti $xri $yti $xri $yb $xi $yb \
- -width 0 -fill "#ffddaa" -tags tag.$id
+ -width 0 -fill $remotebgcolor -tags tag.$id
}
}
- set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> [list showtag $tag_quoted 1]
@@ -6492,7 +6620,7 @@ proc findmore {} {
if {![info exists find_dirn]} {
return 0
}
- set fldtypes [list [mc "Headline"] [mc "Author"] [mc "Date"] [mc "Committer"] [mc "CDate"] [mc "Comments"]]
+ set fldtypes [list [mc "Headline"] [mc "Author"] "" [mc "Committer"] "" [mc "Comments"]]
set l $findcurline
set moretodo 0
if {$find_dirn > 0} {
@@ -6553,6 +6681,7 @@ proc findmore {} {
}
set info $commitinfo($id)
foreach f $info ty $fldtypes {
+ if {$ty eq ""} continue
if {($findloc eq [mc "All fields"] || $findloc eq $ty) &&
[doesmatch $f]} {
set found 1
@@ -6705,7 +6834,7 @@ proc appendwithlinks {text tags} {
set start [$ctext index "end - 1c"]
$ctext insert end $text $tags
- set links [regexp -indices -all -inline {\m[0-9a-f]{6,40}\M} $text]
+ set links [regexp -indices -all -inline {(?:\m|-g)[0-9a-f]{6,40}\M} $text]
foreach l $links {
set s [lindex $l 0]
set e [lindex $l 1]
@@ -6720,6 +6849,11 @@ proc appendwithlinks {text tags} {
proc setlink {id lk} {
global curview ctext pendinglinks
+ global linkfgcolor
+
+ if {[string range $id 0 1] eq "-g"} {
+ set id [string range $id 2 end]
+ }
set known 0
if {[string length $id] < 40} {
@@ -6733,7 +6867,7 @@ proc setlink {id lk} {
set known [commitinview $id $curview]
}
if {$known} {
- $ctext tag conf $lk -foreground blue -underline 1
+ $ctext tag conf $lk -foreground $linkfgcolor -underline 1
$ctext tag bind $lk <1> [list selbyid $id]
$ctext tag bind $lk <Enter> {linkcursor %W 1}
$ctext tag bind $lk <Leave> {linkcursor %W -1}
@@ -6796,7 +6930,7 @@ proc viewnextline {dir} {
# add a list of tag or branch names at position pos
# returns the number of names inserted
proc appendrefs {pos ids var} {
- global ctext linknum curview $var maxrefs
+ global ctext linknum curview $var maxrefs mainheadid
if {[catch {$ctext index $pos}]} {
return 0
@@ -6809,24 +6943,54 @@ proc appendrefs {pos ids var} {
lappend tags [list $tag $id]
}
}
+
+ set sep {}
+ set tags [lsort -index 0 -decreasing $tags]
+ set nutags 0
+
if {[llength $tags] > $maxrefs} {
- $ctext insert $pos "[mc "many"] ([llength $tags])"
- } else {
- set tags [lsort -index 0 -decreasing $tags]
- set sep {}
- foreach ti $tags {
- set id [lindex $ti 1]
- set lk link$linknum
- incr linknum
- $ctext tag delete $lk
- $ctext insert $pos $sep
- $ctext insert $pos [lindex $ti 0] $lk
- setlink $id $lk
- set sep ", "
+ # If we are displaying heads, and there are too many,
+ # see if there are some important heads to display.
+ # Currently this means "master" and the current head.
+ set itags {}
+ if {$var eq "idheads"} {
+ set utags {}
+ foreach ti $tags {
+ set hname [lindex $ti 0]
+ set id [lindex $ti 1]
+ if {($hname eq "master" || $id eq $mainheadid) &&
+ [llength $itags] < $maxrefs} {
+ lappend itags $ti
+ } else {
+ lappend utags $ti
+ }
+ }
+ set tags $utags
}
+ if {$itags ne {}} {
+ set str [mc "and many more"]
+ set sep " "
+ } else {
+ set str [mc "many"]
+ }
+ $ctext insert $pos "$str ([llength $tags])"
+ set nutags [llength $tags]
+ set tags $itags
+ }
+
+ foreach ti $tags {
+ set id [lindex $ti 1]
+ set lk link$linknum
+ incr linknum
+ $ctext tag delete $lk
+ $ctext insert $pos $sep
+ $ctext insert $pos [lindex $ti 0] $lk
+ setlink $id $lk
+ set sep ", "
}
+ $ctext tag add wwrap "$pos linestart" "$pos lineend"
$ctext conf -state disabled
- return [llength $tags]
+ return [expr {[llength $tags] + $nutags}]
}
# called when we have finished computing the nearby tags
@@ -7393,19 +7557,15 @@ proc startdiff {ids} {
}
}
+# If the filename (name) is under any of the passed filter paths
+# then return true to include the file in the listing.
proc path_filter {filter name} {
+ set worktree [gitworktree]
foreach p $filter {
- set l [string length $p]
- if {[string index $p end] eq "/"} {
- if {[string compare -length $l $p $name] == 0} {
- return 1
- }
- } else {
- if {[string compare -length $l $p $name] == 0 &&
- ([string length $name] == $l ||
- [string index $name $l] eq "/")} {
- return 1
- }
+ set fq_p [file normalize $p]
+ set fq_n [file normalize [file join $worktree $name]]
+ if {[string match [file normalize $fq_p]* $fq_n]} {
+ return 1
}
}
return 0
@@ -7419,7 +7579,7 @@ proc addtocflist {ids} {
}
proc diffcmd {ids flags} {
- global nullid nullid2
+ global log_showroot nullid nullid2
set i [lsearch -exact $ids $nullid]
set j [lsearch -exact $ids $nullid2]
@@ -7453,15 +7613,22 @@ proc diffcmd {ids flags} {
lappend cmd HEAD
}
} else {
+ if {$log_showroot} {
+ lappend flags --root
+ }
set cmd [concat | git diff-tree -r $flags $ids]
}
return $cmd
}
proc gettreediffs {ids} {
- global treediff treepending
+ global treediff treepending limitdiffs vfilelimit curview
- if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
+ set cmd [diffcmd $ids {--no-commit-id}]
+ if {$limitdiffs && $vfilelimit($curview) ne {}} {
+ set cmd [concat $cmd -- $vfilelimit($curview)]
+ }
+ if {[catch {set gdtf [open $cmd r]}]} return
set treepending $ids
set treediff {}
@@ -7505,17 +7672,7 @@ proc gettreediffline {gdtf ids} {
return [expr {$nr >= $max? 2: 1}]
}
close $gdtf
- if {$limitdiffs && $vfilelimit($curview) ne {}} {
- set flist {}
- foreach f $treediff {
- if {[path_filter $vfilelimit($curview) $f]} {
- lappend flist $f
- }
- }
- set treediffs($ids) $flist
- } else {
- set treediffs($ids) $treediff
- }
+ set treediffs($ids) $treediff
unset treepending
if {$cmitmode eq "tree" && [llength $diffids] == 1} {
gettree $diffids
@@ -7887,32 +8044,45 @@ proc changediffdisp {} {
$ctext tag conf dresult -elide [lindex $diffelide 1]
}
-proc highlightfile {loc cline} {
- global ctext cflist cflist_top
+proc highlightfile {cline} {
+ global cflist cflist_top
+
+ if {![info exists cflist_top]} return
- $ctext yview $loc
$cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
$cflist tag add highlight $cline.0 "$cline.0 lineend"
$cflist see $cline.0
set cflist_top $cline
}
+proc highlightfile_for_scrollpos {topidx} {
+ global cmitmode difffilestart
+
+ if {$cmitmode eq "tree"} return
+ if {![info exists difffilestart]} return
+
+ set top [lindex [split $topidx .] 0]
+ if {$difffilestart eq {} || $top < [lindex $difffilestart 0]} {
+ highlightfile 0
+ } else {
+ highlightfile [expr {[bsearch $difffilestart $top] + 2}]
+ }
+}
+
proc prevfile {} {
global difffilestart ctext cmitmode
if {$cmitmode eq "tree"} return
set prev 0.0
- set prevline 1
set here [$ctext index @0,0]
foreach loc $difffilestart {
if {[$ctext compare $loc >= $here]} {
- highlightfile $prev $prevline
+ $ctext yview $prev
return
}
set prev $loc
- incr prevline
}
- highlightfile $prev $prevline
+ $ctext yview $prev
}
proc nextfile {} {
@@ -7920,11 +8090,9 @@ proc nextfile {} {
if {$cmitmode eq "tree"} return
set here [$ctext index @0,0]
- set line 1
foreach loc $difffilestart {
- incr line
if {[$ctext compare $loc > $here]} {
- highlightfile $loc $line
+ $ctext yview $loc
return
}
}
@@ -7970,7 +8138,6 @@ proc settabs {{firstab {}}} {
proc incrsearch {name ix op} {
global ctext searchstring searchdirn
- $ctext tag remove found 1.0 end
if {[catch {$ctext index anchor}]} {
# no anchor set, use start of selection, or of visible area
set sel [$ctext tag ranges sel]
@@ -7983,12 +8150,17 @@ proc incrsearch {name ix op} {
}
}
if {$searchstring ne {}} {
- set here [$ctext search $searchdirn -- $searchstring anchor]
+ set here [$ctext search -count mlen $searchdirn -- $searchstring anchor]
if {$here ne {}} {
$ctext see $here
+ set mend "$here + $mlen c"
+ $ctext tag remove sel 1.0 end
+ $ctext tag add sel $here $mend
+ suppress_highlighting_file_for_current_scrollpos
+ highlightfile_for_scrollpos $here
}
- searchmarkvisible 1
}
+ rehighlight_search_results
}
proc dosearch {} {
@@ -8011,9 +8183,12 @@ proc dosearch {} {
return
}
$ctext see $match
+ suppress_highlighting_file_for_current_scrollpos
+ highlightfile_for_scrollpos $match
set mend "$match + $mlen c"
$ctext tag add sel $match $mend
$ctext mark unset anchor
+ rehighlight_search_results
}
}
@@ -8037,21 +8212,41 @@ proc dosearchback {} {
return
}
$ctext see $match
+ suppress_highlighting_file_for_current_scrollpos
+ highlightfile_for_scrollpos $match
set mend "$match + $ml c"
$ctext tag add sel $match $mend
$ctext mark unset anchor
+ rehighlight_search_results
+ }
+}
+
+proc rehighlight_search_results {} {
+ global ctext searchstring
+
+ $ctext tag remove found 1.0 end
+ $ctext tag remove currentsearchhit 1.0 end
+
+ if {$searchstring ne {}} {
+ searchmarkvisible 1
}
}
proc searchmark {first last} {
global ctext searchstring
+ set sel [$ctext tag ranges sel]
+
set mend $first.0
while {1} {
set match [$ctext search -count mlen -- $searchstring $mend $last.end]
if {$match eq {}} break
set mend "$match + $mlen c"
- $ctext tag add found $match $mend
+ if {$sel ne {} && [$ctext compare $match == [lindex $sel 0]]} {
+ $ctext tag add currentsearchhit $match $mend
+ } else {
+ $ctext tag add found $match $mend
+ }
}
}
@@ -8077,8 +8272,23 @@ proc searchmarkvisible {doall} {
}
}
+proc suppress_highlighting_file_for_current_scrollpos {} {
+ global ctext suppress_highlighting_file_for_this_scrollpos
+
+ set suppress_highlighting_file_for_this_scrollpos [$ctext index @0,0]
+}
+
proc scrolltext {f0 f1} {
- global searchstring
+ global searchstring cmitmode ctext
+ global suppress_highlighting_file_for_this_scrollpos
+
+ set topidx [$ctext index @0,0]
+ if {![info exists suppress_highlighting_file_for_this_scrollpos]
+ || $topidx ne $suppress_highlighting_file_for_this_scrollpos} {
+ highlightfile_for_scrollpos $topidx
+ }
+
+ catch {unset suppress_highlighting_file_for_this_scrollpos}
.bleft.bottom.sb set $f0 $f1
if {$searchstring ne {}} {
@@ -8294,6 +8504,8 @@ proc lineleave {id} {
proc linehover {} {
global hoverx hovery hoverid hovertimer
global canv linespc lthickness
+ global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor
+
global commitinfo
set text [lindex $commitinfo($hoverid) 0]
@@ -8307,10 +8519,11 @@ proc linehover {} {
set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
set y1 [expr {$y + $linespc + 2 * $lthickness}]
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
- -fill \#ffff80 -outline black -width 1 -tags hover]
+ -fill $linehoverbgcolor -outline $linehoveroutlinecolor \
+ -width 1 -tags hover]
$canv raise $t
set t [$canv create text $x $y -anchor nw -text $text -tags hover \
- -font mainfont]
+ -font mainfont -fill $linehoverfgcolor]
$canv raise $t
}
@@ -8442,6 +8655,11 @@ proc rowmenu {x y id} {
} else {
set state normal
}
+ if {[info exists markedid] && $markedid ne $id} {
+ set mstate normal
+ } else {
+ set mstate disabled
+ }
if {$id ne $nullid && $id ne $nullid2} {
set menu $rowctxmenu
if {$mainhead ne {}} {
@@ -8449,21 +8667,17 @@ proc rowmenu {x y id} {
} else {
$menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
}
- if {[info exists markedid] && $markedid ne $id} {
- $menu entryconfigure 9 -state normal
- $menu entryconfigure 10 -state normal
- $menu entryconfigure 11 -state normal
- } else {
- $menu entryconfigure 9 -state disabled
- $menu entryconfigure 10 -state disabled
- $menu entryconfigure 11 -state disabled
- }
+ $menu entryconfigure 9 -state $mstate
+ $menu entryconfigure 10 -state $mstate
+ $menu entryconfigure 11 -state $mstate
} else {
set menu $fakerowmenu
}
$menu entryconfigure [mca "Diff this -> selected"] -state $state
$menu entryconfigure [mca "Diff selected -> this"] -state $state
$menu entryconfigure [mca "Make patch"] -state $state
+ $menu entryconfigure [mca "Diff this -> marked commit"] -state $mstate
+ $menu entryconfigure [mca "Diff marked commit -> this"] -state $mstate
tk_popup $menu $x $y
}
@@ -8667,6 +8881,21 @@ proc diffvssel {dirn} {
doseldiff $oldid $newid
}
+proc diffvsmark {dirn} {
+ global rowmenuid markedid
+
+ if {![info exists markedid]} return
+ if {$dirn} {
+ set oldid $markedid
+ set newid $rowmenuid
+ } else {
+ set oldid $rowmenuid
+ set newid $markedid
+ }
+ addtohistory [list doseldiff $oldid $newid] savectextpos
+ doseldiff $oldid $newid
+}
+
proc doseldiff {oldid newid} {
global ctext
global commitinfo
@@ -8858,12 +9087,13 @@ proc domktag {} {
proc redrawtags {id} {
global canv linehtag idpos currentid curview cmitlisted markedid
global canvxmax iddrawn circleitem mainheadid circlecolors
+ global mainheadcirclecolor
if {![commitinview $id $curview]} return
if {![info exists iddrawn($id)]} return
set row [rowofcommit $id]
if {$id eq $mainheadid} {
- set ofill yellow
+ set ofill $mainheadcirclecolor
} else {
set ofill [lindex $circlecolors $cmitlisted($curview,$id)]
}
@@ -9120,6 +9350,67 @@ proc cherrypick {} {
notbusy cherrypick
}
+proc revert {} {
+ global rowmenuid curview
+ global mainhead mainheadid
+ global gitdir
+
+ set oldhead [exec git rev-parse HEAD]
+ set dheads [descheads $rowmenuid]
+ if { $dheads eq {} || [lsearch -exact $dheads $oldhead] == -1 } {
+ set ok [confirm_popup [mc "Commit %s is not\
+ included in branch %s -- really revert it?" \
+ [string range $rowmenuid 0 7] $mainhead]]
+ if {!$ok} return
+ }
+ nowbusy revert [mc "Reverting"]
+ update
+
+ if [catch {exec git revert --no-edit $rowmenuid} err] {
+ notbusy revert
+ if [regexp {files would be overwritten by merge:(\n(( |\t)+[^\n]+\n)+)}\
+ $err match files] {
+ regsub {\n( |\t)+} $files "\n" files
+ error_popup [mc "Revert failed because of local changes to\
+ the following files:%s Please commit, reset or stash \
+ your changes and try again." $files]
+ } elseif [regexp {error: could not revert} $err] {
+ if [confirm_popup [mc "Revert failed because of merge conflict.\n\
+ Do you wish to run git citool to resolve it?"]] {
+ # Force citool to read MERGE_MSG
+ file delete [file join $gitdir "GITGUI_MSG"]
+ exec_citool {} $rowmenuid
+ }
+ } else { error_popup $err }
+ run updatecommits
+ return
+ }
+
+ set newhead [exec git rev-parse HEAD]
+ if { $newhead eq $oldhead } {
+ notbusy revert
+ error_popup [mc "No changes committed"]
+ return
+ }
+
+ addnewchild $newhead $oldhead
+
+ if [commitinview $oldhead $curview] {
+ # XXX this isn't right if we have a path limit...
+ insertrow $newhead $oldhead $curview
+ if {$mainhead ne {}} {
+ movehead $newhead $mainhead
+ movedhead $newhead $mainhead
+ }
+ set mainheadid $newhead
+ redrawtags $oldhead
+ redrawtags $newhead
+ selbyid $newhead
+ }
+
+ notbusy revert
+}
+
proc resethead {} {
global mainhead rowmenuid confirm_ok resettype NS
@@ -10433,13 +10724,13 @@ proc anctags {id} {
# including id itself if it has a head.
proc descheads {id} {
global arcnos arcstart arcids archeads idheads cached_dheads
- global allparents
+ global allparents arcout
if {![info exists allparents($id)]} {
return {}
}
set aret {}
- if {[llength $arcnos($id)] == 1 && [llength $allparents($id)] == 1} {
+ if {![info exists arcout($id)]} {
# part-way along an arc; check it first
set a [lindex $arcnos($id) 0]
if {$archeads($a) ne {}} {
@@ -10523,7 +10814,7 @@ proc movedhead {hid head} {
}
proc changedrefs {} {
- global cached_dheads cached_dtags cached_atags
+ global cached_dheads cached_dtags cached_atags cached_tagcontent
global arctags archeads arcnos arcout idheads idtags
foreach id [concat [array names idheads] [array names idtags]] {
@@ -10535,6 +10826,7 @@ proc changedrefs {} {
}
}
}
+ catch {unset cached_tagcontent}
catch {unset cached_dtags}
catch {unset cached_atags}
catch {unset cached_dheads}
@@ -10587,7 +10879,7 @@ proc listrefs {id} {
}
proc showtag {tag isnew} {
- global ctext tagcontents tagids linknum tagobjid
+ global ctext cached_tagcontent tagids linknum tagobjid
if {$isnew} {
addtohistory [list showtag $tag 0] savectextpos
@@ -10596,13 +10888,13 @@ proc showtag {tag isnew} {
clear_ctext
settabs 0
set linknum 0
- if {![info exists tagcontents($tag)]} {
+ if {![info exists cached_tagcontent($tag)]} {
catch {
- set tagcontents($tag) [exec git cat-file tag $tag]
+ set cached_tagcontent($tag) [exec git cat-file -p $tag]
}
}
- if {[info exists tagcontents($tag)]} {
- set text $tagcontents($tag)
+ if {[info exists cached_tagcontent($tag)]} {
+ set text $cached_tagcontent($tag)
} else {
set text "[mc "Tag"]: $tag\n[mc "Id"]: $tagids($tag)"
}
@@ -10719,7 +11011,7 @@ proc fontok {} {
if {$fontparam(slant) eq "italic"} {
lappend fontpref($f) "italic"
}
- set w $prefstop.$f
+ set w $prefstop.notebook.fonts.$f
$w conf -text $fontparam(family) -font $fontpref($f)
fontcan
@@ -10773,6 +11065,142 @@ proc chg_fontparam {v sub op} {
font config sample -$sub $fontparam($sub)
}
+# Create a property sheet tab page
+proc create_prefs_page {w} {
+ global NS
+ set parent [join [lrange [split $w .] 0 end-1] .]
+ if {[winfo class $parent] eq "TNotebook"} {
+ ${NS}::frame $w
+ } else {
+ ${NS}::labelframe $w
+ }
+}
+
+proc prefspage_general {notebook} {
+ global NS maxwidth maxgraphpct showneartags showlocalchanges
+ global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
+ global hideremotes want_ttk have_ttk maxrefs
+
+ set page [create_prefs_page $notebook.general]
+
+ ${NS}::label $page.ldisp -text [mc "Commit list display options"]
+ grid $page.ldisp - -sticky w -pady 10
+ ${NS}::label $page.spacer -text " "
+ ${NS}::label $page.maxwidthl -text [mc "Maximum graph width (lines)"]
+ spinbox $page.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
+ grid $page.spacer $page.maxwidthl $page.maxwidth -sticky w
+ ${NS}::label $page.maxpctl -text [mc "Maximum graph width (% of pane)"]
+ spinbox $page.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
+ grid x $page.maxpctl $page.maxpct -sticky w
+ ${NS}::checkbutton $page.showlocal -text [mc "Show local changes"] \
+ -variable showlocalchanges
+ grid x $page.showlocal -sticky w
+ ${NS}::checkbutton $page.autoselect -text [mc "Auto-select SHA1 (length)"] \
+ -variable autoselect
+ spinbox $page.autosellen -from 1 -to 40 -width 4 -textvariable autosellen
+ grid x $page.autoselect $page.autosellen -sticky w
+ ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
+ -variable hideremotes
+ grid x $page.hideremotes -sticky w
+
+ ${NS}::label $page.ddisp -text [mc "Diff display options"]
+ grid $page.ddisp - -sticky w -pady 10
+ ${NS}::label $page.tabstopl -text [mc "Tab spacing"]
+ spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
+ grid x $page.tabstopl $page.tabstop -sticky w
+ ${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
+ -variable showneartags
+ grid x $page.ntag -sticky w
+ ${NS}::label $page.maxrefsl -text [mc "Maximum # tags/heads to show"]
+ spinbox $page.maxrefs -from 1 -to 1000 -width 4 -textvariable maxrefs
+ grid x $page.maxrefsl $page.maxrefs -sticky w
+ ${NS}::checkbutton $page.ldiff -text [mc "Limit diffs to listed paths"] \
+ -variable limitdiffs
+ grid x $page.ldiff -sticky w
+ ${NS}::checkbutton $page.lattr -text [mc "Support per-file encodings"] \
+ -variable perfile_attrs
+ grid x $page.lattr -sticky w
+
+ ${NS}::entry $page.extdifft -textvariable extdifftool
+ ${NS}::frame $page.extdifff
+ ${NS}::label $page.extdifff.l -text [mc "External diff tool" ]
+ ${NS}::button $page.extdifff.b -text [mc "Choose..."] -command choose_extdiff
+ pack $page.extdifff.l $page.extdifff.b -side left
+ pack configure $page.extdifff.l -padx 10
+ grid x $page.extdifff $page.extdifft -sticky ew
+
+ ${NS}::label $page.lgen -text [mc "General options"]
+ grid $page.lgen - -sticky w -pady 10
+ ${NS}::checkbutton $page.want_ttk -variable want_ttk \
+ -text [mc "Use themed widgets"]
+ if {$have_ttk} {
+ ${NS}::label $page.ttk_note -text [mc "(change requires restart)"]
+ } else {
+ ${NS}::label $page.ttk_note -text [mc "(currently unavailable)"]
+ }
+ grid x $page.want_ttk $page.ttk_note -sticky w
+ return $page
+}
+
+proc prefspage_colors {notebook} {
+ global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
+
+ set page [create_prefs_page $notebook.colors]
+
+ ${NS}::label $page.cdisp -text [mc "Colors: press to choose"]
+ grid $page.cdisp - -sticky w -pady 10
+ label $page.ui -padx 40 -relief sunk -background $uicolor
+ ${NS}::button $page.uibut -text [mc "Interface"] \
+ -command [list choosecolor uicolor {} $page.ui [mc "interface"] setui]
+ grid x $page.uibut $page.ui -sticky w
+ label $page.bg -padx 40 -relief sunk -background $bgcolor
+ ${NS}::button $page.bgbut -text [mc "Background"] \
+ -command [list choosecolor bgcolor {} $page.bg [mc "background"] setbg]
+ grid x $page.bgbut $page.bg -sticky w
+ label $page.fg -padx 40 -relief sunk -background $fgcolor
+ ${NS}::button $page.fgbut -text [mc "Foreground"] \
+ -command [list choosecolor fgcolor {} $page.fg [mc "foreground"] setfg]
+ grid x $page.fgbut $page.fg -sticky w
+ label $page.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
+ ${NS}::button $page.diffoldbut -text [mc "Diff: old lines"] \
+ -command [list choosecolor diffcolors 0 $page.diffold [mc "diff old lines"] \
+ [list $ctext tag conf d0 -foreground]]
+ grid x $page.diffoldbut $page.diffold -sticky w
+ label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
+ ${NS}::button $page.diffnewbut -text [mc "Diff: new lines"] \
+ -command [list choosecolor diffcolors 1 $page.diffnew [mc "diff new lines"] \
+ [list $ctext tag conf dresult -foreground]]
+ grid x $page.diffnewbut $page.diffnew -sticky w
+ label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
+ ${NS}::button $page.hunksepbut -text [mc "Diff: hunk header"] \
+ -command [list choosecolor diffcolors 2 $page.hunksep \
+ [mc "diff hunk header"] \
+ [list $ctext tag conf hunksep -foreground]]
+ grid x $page.hunksepbut $page.hunksep -sticky w
+ label $page.markbgsep -padx 40 -relief sunk -background $markbgcolor
+ ${NS}::button $page.markbgbut -text [mc "Marked line bg"] \
+ -command [list choosecolor markbgcolor {} $page.markbgsep \
+ [mc "marked line background"] \
+ [list $ctext tag conf omark -background]]
+ grid x $page.markbgbut $page.markbgsep -sticky w
+ label $page.selbgsep -padx 40 -relief sunk -background $selectbgcolor
+ ${NS}::button $page.selbgbut -text [mc "Select bg"] \
+ -command [list choosecolor selectbgcolor {} $page.selbgsep [mc "background"] setselbg]
+ grid x $page.selbgbut $page.selbgsep -sticky w
+ return $page
+}
+
+proc prefspage_fonts {notebook} {
+ global NS
+ set page [create_prefs_page $notebook.fonts]
+ ${NS}::label $page.cfont -text [mc "Fonts: press to choose"]
+ grid $page.cfont - -sticky w -pady 10
+ mkfontdisp mainfont $page [mc "Main font"]
+ mkfontdisp textfont $page [mc "Diff display font"]
+ mkfontdisp uifont $page [mc "User interface font"]
+ return $page
+}
+
proc doprefs {} {
global maxwidth maxgraphpct use_ttk NS
global oldprefs prefstop showneartags showlocalchanges
@@ -10793,106 +11221,38 @@ proc doprefs {} {
ttk_toplevel $top
wm title $top [mc "Gitk preferences"]
make_transient $top .
- ${NS}::label $top.ldisp -text [mc "Commit list display options"]
- grid $top.ldisp - -sticky w -pady 10
- ${NS}::label $top.spacer -text " "
- ${NS}::label $top.maxwidthl -text [mc "Maximum graph width (lines)"]
- spinbox $top.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
- grid $top.spacer $top.maxwidthl $top.maxwidth -sticky w
- ${NS}::label $top.maxpctl -text [mc "Maximum graph width (% of pane)"]
- spinbox $top.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
- grid x $top.maxpctl $top.maxpct -sticky w
- ${NS}::checkbutton $top.showlocal -text [mc "Show local changes"] \
- -variable showlocalchanges
- grid x $top.showlocal -sticky w
- ${NS}::checkbutton $top.autoselect -text [mc "Auto-select SHA1 (length)"] \
- -variable autoselect
- spinbox $top.autosellen -from 1 -to 40 -width 4 -textvariable autosellen
- grid x $top.autoselect $top.autosellen -sticky w
- ${NS}::checkbutton $top.hideremotes -text [mc "Hide remote refs"] \
- -variable hideremotes
- grid x $top.hideremotes -sticky w
-
- ${NS}::label $top.ddisp -text [mc "Diff display options"]
- grid $top.ddisp - -sticky w -pady 10
- ${NS}::label $top.tabstopl -text [mc "Tab spacing"]
- spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
- grid x $top.tabstopl $top.tabstop -sticky w
- ${NS}::checkbutton $top.ntag -text [mc "Display nearby tags"] \
- -variable showneartags
- grid x $top.ntag -sticky w
- ${NS}::checkbutton $top.ldiff -text [mc "Limit diffs to listed paths"] \
- -variable limitdiffs
- grid x $top.ldiff -sticky w
- ${NS}::checkbutton $top.lattr -text [mc "Support per-file encodings"] \
- -variable perfile_attrs
- grid x $top.lattr -sticky w
-
- ${NS}::entry $top.extdifft -textvariable extdifftool
- ${NS}::frame $top.extdifff
- ${NS}::label $top.extdifff.l -text [mc "External diff tool" ]
- ${NS}::button $top.extdifff.b -text [mc "Choose..."] -command choose_extdiff
- pack $top.extdifff.l $top.extdifff.b -side left
- pack configure $top.extdifff.l -padx 10
- grid x $top.extdifff $top.extdifft -sticky ew
-
- ${NS}::label $top.lgen -text [mc "General options"]
- grid $top.lgen - -sticky w -pady 10
- ${NS}::checkbutton $top.want_ttk -variable want_ttk \
- -text [mc "Use themed widgets"]
- if {$have_ttk} {
- ${NS}::label $top.ttk_note -text [mc "(change requires restart)"]
+
+ if {[set use_notebook [expr {$use_ttk && [info command ::ttk::notebook] ne ""}]]} {
+ set notebook [ttk::notebook $top.notebook]
} else {
- ${NS}::label $top.ttk_note -text [mc "(currently unavailable)"]
- }
- grid x $top.want_ttk $top.ttk_note -sticky w
-
- ${NS}::label $top.cdisp -text [mc "Colors: press to choose"]
- grid $top.cdisp - -sticky w -pady 10
- label $top.ui -padx 40 -relief sunk -background $uicolor
- ${NS}::button $top.uibut -text [mc "Interface"] \
- -command [list choosecolor uicolor {} $top.ui [mc "interface"] setui]
- grid x $top.uibut $top.ui -sticky w
- label $top.bg -padx 40 -relief sunk -background $bgcolor
- ${NS}::button $top.bgbut -text [mc "Background"] \
- -command [list choosecolor bgcolor {} $top.bg [mc "background"] setbg]
- grid x $top.bgbut $top.bg -sticky w
- label $top.fg -padx 40 -relief sunk -background $fgcolor
- ${NS}::button $top.fgbut -text [mc "Foreground"] \
- -command [list choosecolor fgcolor {} $top.fg [mc "foreground"] setfg]
- grid x $top.fgbut $top.fg -sticky w
- label $top.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
- ${NS}::button $top.diffoldbut -text [mc "Diff: old lines"] \
- -command [list choosecolor diffcolors 0 $top.diffold [mc "diff old lines"] \
- [list $ctext tag conf d0 -foreground]]
- grid x $top.diffoldbut $top.diffold -sticky w
- label $top.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
- ${NS}::button $top.diffnewbut -text [mc "Diff: new lines"] \
- -command [list choosecolor diffcolors 1 $top.diffnew [mc "diff new lines"] \
- [list $ctext tag conf dresult -foreground]]
- grid x $top.diffnewbut $top.diffnew -sticky w
- label $top.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
- ${NS}::button $top.hunksepbut -text [mc "Diff: hunk header"] \
- -command [list choosecolor diffcolors 2 $top.hunksep \
- [mc "diff hunk header"] \
- [list $ctext tag conf hunksep -foreground]]
- grid x $top.hunksepbut $top.hunksep -sticky w
- label $top.markbgsep -padx 40 -relief sunk -background $markbgcolor
- ${NS}::button $top.markbgbut -text [mc "Marked line bg"] \
- -command [list choosecolor markbgcolor {} $top.markbgsep \
- [mc "marked line background"] \
- [list $ctext tag conf omark -background]]
- grid x $top.markbgbut $top.markbgsep -sticky w
- label $top.selbgsep -padx 40 -relief sunk -background $selectbgcolor
- ${NS}::button $top.selbgbut -text [mc "Select bg"] \
- -command [list choosecolor selectbgcolor {} $top.selbgsep [mc "background"] setselbg]
- grid x $top.selbgbut $top.selbgsep -sticky w
-
- ${NS}::label $top.cfont -text [mc "Fonts: press to choose"]
- grid $top.cfont - -sticky w -pady 10
- mkfontdisp mainfont $top [mc "Main font"]
- mkfontdisp textfont $top [mc "Diff display font"]
- mkfontdisp uifont $top [mc "User interface font"]
+ set notebook [${NS}::frame $top.notebook -borderwidth 0 -relief flat]
+ }
+
+ lappend pages [prefspage_general $notebook] [mc "General"]
+ lappend pages [prefspage_colors $notebook] [mc "Colors"]
+ lappend pages [prefspage_fonts $notebook] [mc "Fonts"]
+ set col 0
+ foreach {page title} $pages {
+ if {$use_notebook} {
+ $notebook add $page -text $title
+ } else {
+ set btn [${NS}::button $notebook.b_[string map {. X} $page] \
+ -text $title -command [list raise $page]]
+ $page configure -text $title
+ grid $btn -row 0 -column [incr col] -sticky w
+ grid $page -row 1 -column 0 -sticky news -columnspan 100
+ }
+ }
+
+ if {!$use_notebook} {
+ grid columnconfigure $notebook 0 -weight 1
+ grid rowconfigure $notebook 1 -weight 1
+ raise [lindex $pages 0]
+ }
+
+ grid $notebook -sticky news -padx 2 -pady 2
+ grid rowconfigure $top 0 -weight 1
+ grid columnconfigure $top 0 -weight 1
${NS}::frame $top.buts
${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active
@@ -10904,7 +11264,7 @@ proc doprefs {} {
grid columnconfigure $top.buts 1 -weight 1 -uniform a
grid $top.buts - - -pady 10 -sticky ew
grid columnconfigure $top 2 -weight 1
- bind $top <Visibility> "focus $top.buts.ok"
+ bind $top <Visibility> [list focus $top.buts.ok]
}
proc choose_extdiff {} {
@@ -11391,6 +11751,20 @@ if {[catch {package require Tk 8.4} err]} {
exit 1
}
+# on OSX bring the current Wish process window to front
+if {[tk windowingsystem] eq "aqua"} {
+ exec osascript -e [format {
+ tell application "System Events"
+ set frontmost of processes whose unix id is %d to true
+ end tell
+ } [pid] ]
+}
+
+# Unset GIT_TRACE var if set
+if { [info exists ::env(GIT_TRACE)] } {
+ unset ::env(GIT_TRACE)
+}
+
# defaults...
set wrcomcmd "git diff-tree --stdin -p --pretty"
@@ -11422,10 +11796,20 @@ catch {
}
}
+set log_showroot true
+catch {
+ set log_showroot [exec git config --bool --get log.showroot]
+}
+
if {[tk windowingsystem] eq "aqua"} {
set mainfont {{Lucida Grande} 9}
set textfont {Monaco 9}
set uifont {{Lucida Grande} 9 bold}
+} elseif {![catch {::tk::pkgconfig get fontsystem} xft] && $xft eq "xft"} {
+ # fontconfig!
+ set mainfont {sans 9}
+ set textfont {monospace 9}
+ set uifont {sans 9 bold}
} else {
set mainfont {Helvetica 9}
set textfont {Courier 9}
@@ -11463,22 +11847,47 @@ if {[tk windowingsystem] eq "aqua"} {
set colors {green red blue magenta darkgrey brown orange}
if {[tk windowingsystem] eq "win32"} {
set uicolor SystemButtonFace
+ set uifgcolor SystemButtonText
+ set uifgdisabledcolor SystemDisabledText
set bgcolor SystemWindow
- set fgcolor SystemButtonText
+ set fgcolor SystemWindowText
set selectbgcolor SystemHighlight
} else {
set uicolor grey85
+ set uifgcolor black
+ set uifgdisabledcolor "#999"
set bgcolor white
set fgcolor black
set selectbgcolor gray85
}
set diffcolors {red "#00a000" blue}
set diffcontext 3
+set mergecolors {red blue green purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
set ignorespace 0
set worddiff ""
set markbgcolor "#e0e0ff"
+set headbgcolor green
+set headfgcolor black
+set headoutlinecolor black
+set remotebgcolor #ffddaa
+set tagbgcolor yellow
+set tagfgcolor black
+set tagoutlinecolor black
+set reflinecolor black
+set filesepbgcolor #aaaaaa
+set filesepfgcolor black
+set linehoverbgcolor #ffff80
+set linehoverfgcolor black
+set linehoveroutlinecolor black
+set mainheadcirclecolor yellow
+set workingfilescirclecolor red
+set indexcirclecolor green
set circlecolors {white blue gray blue blue}
+set linkfgcolor blue
+set circleoutlinecolor $fgcolor
+set foundbgcolor yellow
+set currentsearchhitbgcolor orange
# button for popping up context menus
if {[tk windowingsystem] eq "aqua"} {
@@ -11607,6 +12016,8 @@ if {[package vcompare $git_version "1.6.6.2"] >= 0} {
set show_notes "--show-notes"
}
+set appname "gitk"
+
set runq {}
set history {}
set historyindex 0
@@ -11676,7 +12087,7 @@ catch {
}
# wait for the window to become visible
tkwait visibility .
-wm title . "[file tail $argv0]: [file tail [pwd]]"
+wm title . "$appname: [reponame]"
update
readrefs