diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index ee1e4891d6f455..32ede6ad817980 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -2516,7 +2516,9 @@ proc toggle_or_diff {mode w args} { if {$last_clicked ne {}} { set lno [lindex $last_clicked 1] } else { - if {[llength $file_lists($w)] == 0} { + if {![info exists file_lists] + || ![info exists file_lists($w)] + || [llength $file_lists($w)] == 0} { set last_clicked {} return } @@ -2530,7 +2532,13 @@ proc toggle_or_diff {mode w args} { } } - set path [lindex $file_lists($w) [expr {$lno - 1}]] + if {![info exists file_lists] + || ![info exists file_lists($w)] + || [llength $file_lists($w)] < $lno - 1} { + set path {} + } else { + set path [lindex $file_lists($w) [expr {$lno - 1}]] + } if {$path eq {}} { set last_clicked {} return