summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Paul Mackerras <paulus@samba.org>2008-01-06 13:54:58 +1100
committerLibravatar Paul Mackerras <paulus@samba.org>2008-01-06 13:54:58 +1100
commitc8c9f3d9cc9a21084c9fe4742d0e66b7c988635c (patch)
tree157b6a4af6637aec5ee9b9b6a97a1af511d87829
parentgitk: Fix a couple of bugs in the find function (diff)
downloadtgif-c8c9f3d9cc9a21084c9fe4742d0e66b7c988635c.tar.xz
gitk: Fix potential bug with fake commit IDs in renumbervarc
When a fake row is added, we add its (fake) ID to the children list for its (fake) parent. If renumbervarc were to then renumber the parent it would incorrectly use the fake child. This avoids the problem by adding a last_real_child procedure which won't return a fake ID, and using it in renumbervarc. For symmetry this also adds a first_real_child procedure and uses it in ordertoken. Signed-off-by: Paul Mackerras <paulus@samba.org>
-rwxr-xr-xgitk37
1 files changed, 28 insertions, 9 deletions
diff --git a/gitk b/gitk
index cddd2189e5..fda06186b4 100755
--- a/gitk
+++ b/gitk
@@ -462,8 +462,8 @@ proc renumbervarc {a v} {
set tok $oldtok
}
set ka 0
- if {[llength $children($v,$id)] > 0} {
- set kid [lindex $children($v,$id) end]
+ set kid [last_real_child $v,$id]
+ if {$kid ne {}} {
set k $varcid($v,$kid)
if {[string compare [lindex $varctok($v) $k] $tok] > 0} {
set ki $kid
@@ -628,6 +628,30 @@ proc removerow {id v} {
drawvisible
}
+proc first_real_child {vp} {
+ global children nullid nullid2
+
+ foreach id $children($vp) {
+ if {$id ne $nullid && $id ne $nullid2} {
+ return $id
+ }
+ }
+ return {}
+}
+
+proc last_real_child {vp} {
+ global children nullid nullid2
+
+ set kids $children($vp)
+ for {set i [llength $kids]} {[incr i -1] >= 0} {} {
+ set id [lindex $kids $i]
+ if {$id ne $nullid && $id ne $nullid2} {
+ return $id
+ }
+ }
+ return {}
+}
+
proc vtokcmp {v a b} {
global varctok varcid
@@ -3376,17 +3400,12 @@ proc ordertoken {id} {
set tok $ordertok($p)
break
}
- if {[llength $children($curview,$p)] == 0} {
+ set id [first_real_child $curview,$p]
+ if {$id eq {}} {
# it's a root
set tok [lindex $varctok($curview) $a]
break
}
- set id [lindex $children($curview,$p) 0]
- if {$id eq $nullid || $id eq $nullid2} {
- # XXX treat it as a root
- set tok [lindex $varctok($curview) $a]
- break
- }
if {[llength $parents($curview,$id)] == 1} {
lappend todo [list $p {}]
} else {