@matheusbsbs / matheus-bagliano / commits / e5ef6f952a
Fork 0

gitk: Fix "can't unset prevlines(...)" Tcl error

This fixes the error reported by Michele Ballabio, where gitk will throw a Tcl error "can't unset prevlines(...)" when displaying a commit that has a parent commit listed more than once, and the commit is the first child of that parent. The problem was basically that we had two variables, prevlines and lineends, and were relying on the invariant that prevlines($id) was set iff $id was in the lineends($r) list for some $r. But having a duplicate parent breaks that invariant since we end up with the parent listed twice in lineends. This fixes it by simplifying the logic to use only a single variable, lineend. It also rearranges things a little so that we don't try to draw the line for the duplicated parent twice. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Oct 21, 2007 at 12:58 UTC e5ef6f952a13342065d44bab53999e8d8529cc3b
1 file changed +5 -16
gitk
+5 -16
@@ -3695,34 +3695,23 @@ proc drawcommits {row {endrow {}}} {
3695 drawcmitrow $r
3696 if {$r == $er} break
3697 set nextid [lindex $displayorder [expr {$r + 1}]]
3698 - if {$wasdrawn && [info exists iddrawn($nextid)]} {
3699 - catch {unset prevlines}
3700 - continue
3701 - }
3698 + if {$wasdrawn && [info exists iddrawn($nextid)]} continue
3699 drawparentlinks $id $r
3700
3704 - if {[info exists lineends($r)]} {
3705 - foreach lid $lineends($r) {
3706 - unset prevlines($lid)
3707 - }
3708 - }
3701 set rowids [lindex $rowidlist $r]
3702 foreach lid $rowids {
3703 if {$lid eq {}} continue
3704 + if {[info exists lineend($lid)] && $lineend($lid) > $r} continue
3705 if {$lid eq $id} {
3706 # see if this is the first child of any of its parents
3707 foreach p [lindex $parentlist $r] {
3708 if {[lsearch -exact $rowids $p] < 0} {
3709 # make this line extend up to the child
3717 - set le [drawlineseg $p $r $er 0]
3718 - lappend lineends($le) $p
3719 - set prevlines($p) 1
3710 + set lineend($p) [drawlineseg $p $r $er 0]
3711 }
3712 }
3722 - } elseif {![info exists prevlines($lid)]} {
3723 - set le [drawlineseg $lid $r $er 1]
3724 - lappend lineends($le) $lid
3725 - set prevlines($lid) 1
3713 + } else {
3714 + set lineend($lid) [drawlineseg $lid $r $er 1]
3715 }
3716 }
3717 }