Skip to content

Commit 0a4dd8b

Browse files
committed
gitk: Don't try to list large numbers of tags or heads in the details pane
With some large repositories, a commit can end up on thousands of branches, which results in an extremely long "Branches:" line in the details window, and that results in the window being extremely slow to scroll. This fixes it by just showing "many (N)" after "Branches:", "Follows:" or "Precedes:", where N is the number of heads or tags. The limit is currently set at 20 but could be made configurable (and the "many" could be a link to pop up a window listing them all in case anyone really wants to know). Signed-off-by: Paul Mackerras <[email protected]>
1 parent e11f123 commit 0a4dd8b

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

gitk

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,7 @@ proc viewnextline {dir} {
38313831
# add a list of tag or branch names at position pos
38323832
# returns the number of names inserted
38333833
proc appendrefs {pos ids var} {
3834-
global ctext commitrow linknum curview $var
3834+
global ctext commitrow linknum curview $var maxrefs
38353835

38363836
if {[catch {$ctext index $pos}]} {
38373837
return 0
@@ -3844,24 +3844,29 @@ proc appendrefs {pos ids var} {
38443844
lappend tags [list $tag $id]
38453845
}
38463846
}
3847-
set tags [lsort -index 0 -decreasing $tags]
3848-
set sep {}
3849-
foreach ti $tags {
3850-
set id [lindex $ti 1]
3851-
set lk link$linknum
3852-
incr linknum
3853-
$ctext tag delete $lk
3854-
$ctext insert $pos $sep
3855-
$ctext insert $pos [lindex $ti 0] $lk
3856-
if {[info exists commitrow($curview,$id)]} {
3857-
$ctext tag conf $lk -foreground blue
3858-
$ctext tag bind $lk <1> \
3859-
[list selectline $commitrow($curview,$id) 1]
3860-
$ctext tag conf $lk -underline 1
3861-
$ctext tag bind $lk <Enter> { %W configure -cursor hand2 }
3862-
$ctext tag bind $lk <Leave> { %W configure -cursor $curtextcursor }
3847+
if {[llength $tags] > $maxrefs} {
3848+
$ctext insert $pos "many ([llength $tags])"
3849+
} else {
3850+
set tags [lsort -index 0 -decreasing $tags]
3851+
set sep {}
3852+
foreach ti $tags {
3853+
set id [lindex $ti 1]
3854+
set lk link$linknum
3855+
incr linknum
3856+
$ctext tag delete $lk
3857+
$ctext insert $pos $sep
3858+
$ctext insert $pos [lindex $ti 0] $lk
3859+
if {[info exists commitrow($curview,$id)]} {
3860+
$ctext tag conf $lk -foreground blue
3861+
$ctext tag bind $lk <1> \
3862+
[list selectline $commitrow($curview,$id) 1]
3863+
$ctext tag conf $lk -underline 1
3864+
$ctext tag bind $lk <Enter> { %W configure -cursor hand2 }
3865+
$ctext tag bind $lk <Leave> \
3866+
{ %W configure -cursor $curtextcursor }
3867+
}
3868+
set sep ", "
38633869
}
3864-
set sep ", "
38653870
}
38663871
$ctext conf -state disabled
38673872
return [llength $tags]
@@ -6856,6 +6861,7 @@ set mingaplen 30
68566861
set cmitmode "patch"
68576862
set wrapcomment "none"
68586863
set showneartags 1
6864+
set maxrefs 20
68596865

68606866
set colors {green red blue magenta darkgrey brown orange}
68616867
set bgcolor white

0 commit comments

Comments
 (0)