@matheusbsbs / matheus-bagliano / commits / 835e62aef8
Fork 0

gitk: Fallback to selecting the head commit upon load

Try selecting the head, if the previously selected commit is not available in the new view. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Jul 26, 2008 at 20:15 UTC 835e62aef81b75301129625f5d5df76149862909
1 file changed +18 -7
gitk
+18 -7
@@ -1506,8 +1506,15 @@ proc chewcommits {} {
1506 global numcommits startmsecs
1507
1508 if {[info exists pending_select]} {
1509 - set row [first_real_row]
1510 - selectline $row 1
1509 + update
1510 + reset_pending_select {}
1511 +
1512 + if {[commitinview $pending_select $curview]} {
1513 + selectline [rowofcommit $pending_select] 1
1514 + } else {
1515 + set row [first_real_row]
1516 + selectline $row 1
1517 + }
1518 }
1519 if {$commitidx($curview) > 0} {
1520 #set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
@@ -3372,14 +3379,18 @@ proc showview {n} {
3379 drawvisible
3380 if {$row ne {}} {
3381 selectline $row 0
3375 - } elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} {
3376 - selectline [rowofcommit $mainheadid] 1
3382 } elseif {!$viewcomplete($n)} {
3383 reset_pending_select $selid
3384 } else {
3380 - set row [first_real_row]
3381 - if {$row < $numcommits} {
3382 - selectline $row 0
3385 + reset_pending_select {}
3386 +
3387 + if {[commitinview $pending_select $curview]} {
3388 + selectline [rowofcommit $pending_select] 1
3389 + } else {
3390 + set row [first_real_row]
3391 + if {$row < $numcommits} {
3392 + selectline $row 0
3393 + }
3394 }
3395 }
3396 if {!$viewcomplete($n)} {