Skip to content

Commit f3326b6

Browse files
committed
gitk: Fix bug causing nearby tags/heads to sometimes not be displayed
When we compute descendent heads and descendent/ancestor tags, we cache the results. We need to be careful to invalidate the cache when we add stuff to the graph. Also make sure that when we cache descendent heads for a node we only cache the heads that are actually descendents of that node. Signed-off-by: Paul Mackerras <[email protected]>
1 parent a2c2236 commit f3326b6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

gitk

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5950,7 +5950,7 @@ proc regetallcommits {} {
59505950
# coming from descendents, and "outgoing" means going towards ancestors.
59515951

59525952
proc getallclines {fd} {
5953-
global allids allparents allchildren idtags nextarc nbmp
5953+
global allids allparents allchildren idtags idheads nextarc nbmp
59545954
global arcnos arcids arctags arcout arcend arcstart archeads growing
59555955
global seeds allcommits
59565956

@@ -6023,6 +6023,12 @@ proc getallclines {fd} {
60236023
}
60246024
set arcout($id) $ao
60256025
}
6026+
if {$nid > 0} {
6027+
global cached_dheads cached_dtags cached_atags
6028+
catch {unset cached_dheads}
6029+
catch {unset cached_dtags}
6030+
catch {unset cached_atags}
6031+
}
60266032
if {![eof $fd]} {
60276033
return [expr {$nid >= 1000? 2: 1}]
60286034
}
@@ -6674,7 +6680,7 @@ proc descheads {id} {
66746680
if {![info exists allparents($id)]} {
66756681
return {}
66766682
}
6677-
set ret {}
6683+
set aret {}
66786684
if {[llength $arcnos($id)] == 1 && [llength $allparents($id)] == 1} {
66796685
# part-way along an arc; check it first
66806686
set a [lindex $arcnos($id) 0]
@@ -6684,14 +6690,15 @@ proc descheads {id} {
66846690
foreach t $archeads($a) {
66856691
set j [lsearch -exact $arcids($a) $t]
66866692
if {$j > $i} break
6687-
lappend $ret $t
6693+
lappend aret $t
66886694
}
66896695
}
66906696
set id $arcstart($a)
66916697
}
66926698
set origid $id
66936699
set todo [list $id]
66946700
set seen($id) 1
6701+
set ret {}
66956702
for {set i 0} {$i < [llength $todo]} {incr i} {
66966703
set id [lindex $todo $i]
66976704
if {[info exists cached_dheads($id)]} {
@@ -6714,6 +6721,7 @@ proc descheads {id} {
67146721
}
67156722
set ret [lsort -unique $ret]
67166723
set cached_dheads($origid) $ret
6724+
return [concat $ret $aret]
67176725
}
67186726

67196727
proc addedtag {id} {

0 commit comments

Comments
 (0)