@@ -641,12 +641,16 @@ proc varcinit {view} {
641
641
642
642
proc resetvarcs {view} {
643
643
global varcid varccommits parents children vseedcount ordertok
644
+ global vshortids
644
645
645
646
foreach vid [array names varcid $view ,*] {
646
647
unset varcid($vid )
647
648
unset children($vid )
648
649
unset parents($vid )
649
650
}
651
+ foreach vid [array names vshortids $view ,*] {
652
+ unset vshortids($vid )
653
+ }
650
654
# some commits might have children but haven't been seen yet
651
655
foreach vid [array names children $view ,*] {
652
656
unset children($vid )
@@ -933,7 +937,7 @@ proc fix_reversal {p a v} {
933
937
proc insertrow {id p v} {
934
938
global cmitlisted children parents varcid varctok vtokmod
935
939
global varccommits ordertok commitidx numcommits curview
936
- global targetid targetrow
940
+ global targetid targetrow vshortids
937
941
938
942
readcommit $id
939
943
set vid $v ,$id
@@ -942,6 +946,7 @@ proc insertrow {id p v} {
942
946
set parents($vid ) [list $p ]
943
947
set a [newvarc $v $id ]
944
948
set varcid($vid ) $a
949
+ lappend vshortids($v ,[string range $id 0 3]) $id
945
950
if {[string compare [lindex $varctok($v) $a ] $vtokmod($v) ] < 0} {
946
951
modify_arc $v $a
947
952
}
@@ -1397,7 +1402,7 @@ proc getcommitlines {fd inst view updating} {
1397
1402
global commitidx commitdata vdatemode
1398
1403
global parents children curview hlview
1399
1404
global idpending ordertok
1400
- global varccommits varcid varctok vtokmod vfilelimit
1405
+ global varccommits varcid varctok vtokmod vfilelimit vshortids
1401
1406
1402
1407
set stuff [read $fd 500000]
1403
1408
# git log doesn't terminate the last commit with a null...
@@ -1497,6 +1502,8 @@ proc getcommitlines {fd inst view updating} {
1497
1502
set id [lindex $ids 0]
1498
1503
set vid $view ,$id
1499
1504
1505
+ lappend vshortids($view ,[string range $id 0 3]) $id
1506
+
1500
1507
if {!$listed && $updating && ![info exists varcid($vid )] &&
1501
1508
$vfilelimit($view) ne {}} {
1502
1509
# git log doesn't rewrite parents for unlisted commits
@@ -1719,11 +1726,26 @@ proc getcommit {id} {
1719
1726
# and are present in the current view.
1720
1727
# This is fairly slow...
1721
1728
proc longid {prefix} {
1722
- global varcid curview
1729
+ global varcid curview vshortids
1723
1730
1724
1731
set ids {}
1725
- foreach match [array names varcid " $curview ,$prefix *" ] {
1726
- lappend ids [lindex [split $match " ," ] 1]
1732
+ if {[string length $prefix ] >= 4} {
1733
+ set vshortid $curview ,[string range $prefix 0 3]
1734
+ if {[info exists vshortids($vshortid )]} {
1735
+ foreach id $vshortids($vshortid) {
1736
+ if {[string match " $prefix *" $id ]} {
1737
+ if {[lsearch -exact $ids $id ] < 0} {
1738
+ lappend ids $id
1739
+ if {[llength $ids ] >= 2} break
1740
+ }
1741
+ }
1742
+ }
1743
+ }
1744
+ } else {
1745
+ foreach match [array names varcid " $curview ,$prefix *" ] {
1746
+ lappend ids [lindex [split $match " ," ] 1]
1747
+ if {[llength $ids ] >= 2} break
1748
+ }
1727
1749
}
1728
1750
return $ids
1729
1751
}
0 commit comments