Skip to content

Commit 835e62a

Browse files
angavrilovpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 567c34e commit 835e62a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

gitk

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,8 +1506,15 @@ proc chewcommits {} {
15061506
global numcommits startmsecs
15071507

15081508
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+
}
15111518
}
15121519
if {$commitidx($curview) > 0} {
15131520
#set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
@@ -3372,14 +3379,18 @@ proc showview {n} {
33723379
drawvisible
33733380
if {$row ne {}} {
33743381
selectline $row 0
3375-
} elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} {
3376-
selectline [rowofcommit $mainheadid] 1
33773382
} elseif {!$viewcomplete($n)} {
33783383
reset_pending_select $selid
33793384
} 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+
}
33833394
}
33843395
}
33853396
if {!$viewcomplete($n)} {

0 commit comments

Comments
 (0)