Merge remote-tracking branch 'paulus/master' into pm/gitk-update

* paulus/master:
  gitk: Resize panes correctly when reducing window size
  gitk: replace tabs with spaces
  gitk: fix the context menu not appearing in the presence of submodule diffs
  gitk: Un-hide selection in areas with non-default background color
  gitk: add diff lines background colors
  gitk: be prepared to be run in a bare repository
  gitk: Preserve window dimensions on exit when not using ttk themes
  gitk: don't highlight files after submodules as submodules
  gitk: fix branch name encoding error
  gitk: rename "commit summary" to "commit reference"
maint
Junio C Hamano 2020-10-03 10:06:27 -07:00
commit e2b9cb1c5a
1 changed files with 5325 additions and 5293 deletions

View File

@ -34,8 +34,7 @@ proc gitworktree {} {
# cdup to obtain a relative path to the top of the worktree. If # cdup to obtain a relative path to the top of the worktree. If
# run from the top, the ./ prefix ensures normalize expands pwd. # run from the top, the ./ prefix ensures normalize expands pwd.
if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} { if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
catch {set _gitworktree [exec git config --get core.worktree]} if {[catch {set _gitworktree [exec git config --get core.worktree]}]} {
if {$_gitworktree eq ""} {
set _gitworktree [file normalize ./[exec git rev-parse --show-cdup]] set _gitworktree [file normalize ./[exec git rev-parse --show-cdup]]
} }
} }
@ -1780,11 +1779,15 @@ proc readrefs {} {
global otherrefids idotherrefs mainhead mainheadid global otherrefids idotherrefs mainhead mainheadid
global selecthead selectheadid global selecthead selectheadid
global hideremotes global hideremotes
global tclencoding


foreach v {tagids idtags headids idheads otherrefids idotherrefs} { foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
unset -nocomplain $v unset -nocomplain $v
} }
set refd [open [list | git show-ref -d] r] set refd [open [list | git show-ref -d] r]
if {$tclencoding != {}} {
fconfigure $refd -encoding $tclencoding
}
while {[gets $refd line] >= 0} { while {[gets $refd line] >= 0} {
if {[string index $line 40] ne " "} continue if {[string index $line 40] ne " "} continue
set id [string range $line 0 39] set id [string range $line 0 39]
@ -2069,7 +2072,7 @@ proc makewindow {} {
global rowctxmenu fakerowmenu mergemax wrapcomment global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype global highlight_files gdttype
global searchstring sstring global searchstring sstring
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
global uifgcolor uifgdisabledcolor global uifgcolor uifgdisabledcolor
global filesepbgcolor filesepfgcolor global filesepbgcolor filesepfgcolor
global mergecolors foundbgcolor currentsearchhitbgcolor global mergecolors foundbgcolor currentsearchhitbgcolor
@ -2430,7 +2433,9 @@ proc makewindow {} {
$ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor $ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor
$ctext tag conf hunksep -fore [lindex $diffcolors 2] $ctext tag conf hunksep -fore [lindex $diffcolors 2]
$ctext tag conf d0 -fore [lindex $diffcolors 0] $ctext tag conf d0 -fore [lindex $diffcolors 0]
$ctext tag conf d0 -back [lindex $diffbgcolors 0]
$ctext tag conf dresult -fore [lindex $diffcolors 1] $ctext tag conf dresult -fore [lindex $diffcolors 1]
$ctext tag conf dresult -back [lindex $diffbgcolors 1]
$ctext tag conf m0 -fore [lindex $mergecolors 0] $ctext tag conf m0 -fore [lindex $mergecolors 0]
$ctext tag conf m1 -fore [lindex $mergecolors 1] $ctext tag conf m1 -fore [lindex $mergecolors 1]
$ctext tag conf m2 -fore [lindex $mergecolors 2] $ctext tag conf m2 -fore [lindex $mergecolors 2]
@ -2455,6 +2460,12 @@ proc makewindow {} {
$ctext tag conf currentsearchhit -back $currentsearchhitbgcolor $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor
$ctext tag conf wwrap -wrap word -lmargin2 1c $ctext tag conf wwrap -wrap word -lmargin2 1c
$ctext tag conf bold -font textfontbold $ctext tag conf bold -font textfontbold
# set these to the lowest priority:
$ctext tag lower currentsearchhit
$ctext tag lower found
$ctext tag lower filesep
$ctext tag lower dresult
$ctext tag lower d0


.pwbottom add .bleft .pwbottom add .bleft
if {!$use_ttk} { if {!$use_ttk} {
@ -2526,9 +2537,9 @@ proc makewindow {} {
bind %W <Map> {} bind %W <Map> {}
%W sashpos 0 $::geometry(botwidth) %W sashpos 0 $::geometry(botwidth)
} }
bind .pwbottom <Configure> {resizecdetpanes %W %w}
} }


bind .pwbottom <Configure> {resizecdetpanes %W %w}
pack .ctop -fill both -expand 1 pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y} bindall <1> {selcanvline %W %x %y}
#bindall <B1-Motion> {selcanvline %W %x %y} #bindall <B1-Motion> {selcanvline %W %x %y}
@ -2640,7 +2651,7 @@ proc makewindow {} {
{mc "Diff selected -> this" command {diffvssel 1}} {mc "Diff selected -> this" command {diffvssel 1}}
{mc "Make patch" command mkpatch} {mc "Make patch" command mkpatch}
{mc "Create tag" command mktag} {mc "Create tag" command mktag}
{mc "Copy commit summary" command copysummary} {mc "Copy commit reference" command copyreference}
{mc "Write commit to file" command writecommit} {mc "Write commit to file" command writecommit}
{mc "Create new branch" command mkbranch} {mc "Create new branch" command mkbranch}
{mc "Cherry-pick this commit" command cherrypick} {mc "Cherry-pick this commit" command cherrypick}
@ -2942,9 +2953,12 @@ proc savestuff {w} {
} }


proc resizeclistpanes {win w} { proc resizeclistpanes {win w} {
global oldwidth use_ttk global oldwidth oldsash use_ttk
if {[info exists oldwidth($win)]} { if {[info exists oldwidth($win)]} {
if {$use_ttk} { if {[info exists oldsash($win)]} {
set s0 [lindex $oldsash($win) 0]
set s1 [lindex $oldsash($win) 1]
} elseif {$use_ttk} {
set s0 [$win sashpos 0] set s0 [$win sashpos 0]
set s1 [$win sashpos 1] set s1 [$win sashpos 1]
} else { } else {
@ -2978,14 +2992,17 @@ proc resizeclistpanes {win w} {
$win sash place 0 $sash0 [lindex $s0 1] $win sash place 0 $sash0 [lindex $s0 1]
$win sash place 1 $sash1 [lindex $s1 1] $win sash place 1 $sash1 [lindex $s1 1]
} }
set oldsash($win) [list $sash0 $sash1]
} }
set oldwidth($win) $w set oldwidth($win) $w
} }


proc resizecdetpanes {win w} { proc resizecdetpanes {win w} {
global oldwidth use_ttk global oldwidth oldsash use_ttk
if {[info exists oldwidth($win)]} { if {[info exists oldwidth($win)]} {
if {$use_ttk} { if {[info exists oldsash($win)]} {
set s0 $oldsash($win)
} elseif {$use_ttk} {
set s0 [$win sashpos 0] set s0 [$win sashpos 0]
} else { } else {
set s0 [$win sash coord 0] set s0 [$win sash coord 0]
@ -3007,6 +3024,7 @@ proc resizecdetpanes {win w} {
} else { } else {
$win sash place 0 $sash0 [lindex $s0 1] $win sash place 0 $sash0 [lindex $s0 1]
} }
set oldsash($win) $sash0
} }
set oldwidth($win) $w set oldwidth($win) $w
} }
@ -8146,6 +8164,8 @@ proc parseblobdiffline {ids line} {
} }
# start of a new file # start of a new file
set diffinhdr 1 set diffinhdr 1
set currdiffsubmod ""

$ctext insert end "\n" $ctext insert end "\n"
set curdiffstart [$ctext index "end - 1c"] set curdiffstart [$ctext index "end - 1c"]
lappend ctext_file_names "" lappend ctext_file_names ""
@ -8218,10 +8238,10 @@ proc parseblobdiffline {ids line} {
if {$currdiffsubmod != $fname} { if {$currdiffsubmod != $fname} {
$ctext insert end "\n"; # Add newline after commit message $ctext insert end "\n"; # Add newline after commit message
} }
if {$currdiffsubmod != $fname} {
set curdiffstart [$ctext index "end - 1c"] set curdiffstart [$ctext index "end - 1c"]
lappend ctext_file_names "" lappend ctext_file_names ""
if {$currdiffsubmod != $fname} { lappend ctext_file_lines [lindex [split $curdiffstart "."] 0]
lappend ctext_file_lines $fname
makediffhdr $fname $ids makediffhdr $fname $ids
set currdiffsubmod $fname set currdiffsubmod $fname
$ctext insert end "\n$line\n" filesep $ctext insert end "\n$line\n" filesep
@ -8229,11 +8249,9 @@ proc parseblobdiffline {ids line} {
$ctext insert end "$line\n" filesep $ctext insert end "$line\n" filesep
} }
} elseif {$currdiffsubmod != "" && ![string compare -length 3 " >" $line]} { } elseif {$currdiffsubmod != "" && ![string compare -length 3 " >" $line]} {
set $currdiffsubmod ""
set line [encoding convertfrom $diffencoding $line] set line [encoding convertfrom $diffencoding $line]
$ctext insert end "$line\n" dresult $ctext insert end "$line\n" dresult
} elseif {$currdiffsubmod != "" && ![string compare -length 3 " <" $line]} { } elseif {$currdiffsubmod != "" && ![string compare -length 3 " <" $line]} {
set $currdiffsubmod ""
set line [encoding convertfrom $diffencoding $line] set line [encoding convertfrom $diffencoding $line]
$ctext insert end "$line\n" d0 $ctext insert end "$line\n" d0
} elseif {$diffinhdr} { } elseif {$diffinhdr} {
@ -9426,7 +9444,7 @@ proc mktaggo {} {
mktagcan mktagcan
} }


proc copysummary {} { proc copyreference {} {
global rowmenuid autosellen global rowmenuid autosellen


set format "%h (\"%s\", %ad)" set format "%h (\"%s\", %ad)"
@ -9434,10 +9452,10 @@ proc copysummary {} {
if {$autosellen < 40} { if {$autosellen < 40} {
lappend cmd --abbrev=$autosellen lappend cmd --abbrev=$autosellen
} }
set summary [eval exec $cmd $rowmenuid] set reference [eval exec $cmd $rowmenuid]


clipboard clear clipboard clear
clipboard append $summary clipboard append $reference
} }


proc writecommit {} { proc writecommit {} {
@ -11603,6 +11621,7 @@ proc prefspage_general {notebook} {


proc prefspage_colors {notebook} { proc prefspage_colors {notebook} {
global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
global diffbgcolors


set page [create_prefs_page $notebook.colors] set page [create_prefs_page $notebook.colors]


@ -11625,11 +11644,23 @@ proc prefspage_colors {notebook} {
-command [list choosecolor diffcolors 0 $page.diffold [mc "diff old lines"] \ -command [list choosecolor diffcolors 0 $page.diffold [mc "diff old lines"] \
[list $ctext tag conf d0 -foreground]] [list $ctext tag conf d0 -foreground]]
grid x $page.diffoldbut $page.diffold -sticky w grid x $page.diffoldbut $page.diffold -sticky w
label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
${NS}::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
-command [list choosecolor diffbgcolors 0 $page.diffoldbg \
[mc "diff old lines bg"] \
[list $ctext tag conf d0 -background]]
grid x $page.diffoldbgbut $page.diffoldbg -sticky w
label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1] label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
${NS}::button $page.diffnewbut -text [mc "Diff: new lines"] \ ${NS}::button $page.diffnewbut -text [mc "Diff: new lines"] \
-command [list choosecolor diffcolors 1 $page.diffnew [mc "diff new lines"] \ -command [list choosecolor diffcolors 1 $page.diffnew [mc "diff new lines"] \
[list $ctext tag conf dresult -foreground]] [list $ctext tag conf dresult -foreground]]
grid x $page.diffnewbut $page.diffnew -sticky w grid x $page.diffnewbut $page.diffnew -sticky w
label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
${NS}::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
-command [list choosecolor diffbgcolors 1 $page.diffnewbg \
[mc "diff new lines bg"] \
[list $ctext tag conf dresult -background]]
grid x $page.diffnewbgbut $page.diffnewbg -sticky w
label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2] label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
${NS}::button $page.hunksepbut -text [mc "Diff: hunk header"] \ ${NS}::button $page.hunksepbut -text [mc "Diff: hunk header"] \
-command [list choosecolor diffcolors 2 $page.hunksep \ -command [list choosecolor diffcolors 2 $page.hunksep \
@ -12373,7 +12404,8 @@ if {[tk windowingsystem] eq "win32"} {
set web_browser "xdg-open" set web_browser "xdg-open"
} }
} }
set diffcolors {red "#00a000" blue} set diffcolors {"#c30000" "#009800" blue}
set diffbgcolors {"#fff3f3" "#f0fff0"}
set diffcontext 3 set diffcontext 3
set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"} set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
set ignorespace 0 set ignorespace 0
@ -12444,7 +12476,7 @@ set config_variables {
remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor
filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
web_browser web_browser
} }
foreach var $config_variables { foreach var $config_variables {
@ -12599,7 +12631,7 @@ set cdup {}
if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} { if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
set cdup [exec git rev-parse --show-cdup] set cdup [exec git rev-parse --show-cdup]
} }
set worktree [exec git rev-parse --show-toplevel] set worktree [gitworktree]
setcoords setcoords
makewindow makewindow
catch { catch {