Skip to content

Commit 2cd9179

Browse files
dschogitster
authored andcommitted
git-gui: fix exception when trying to stage with empty file list
If there is nothing to stage, there is nothing to stage. Let's not try to, even if the file list contains nothing at all. This fixes #1075 Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2365e5b commit 2cd9179

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

git-gui.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,9 @@ proc toggle_or_diff {mode w args} {
25052505
if {$last_clicked ne {}} {
25062506
set lno [lindex $last_clicked 1]
25072507
} else {
2508-
if {[llength $file_lists($w)] == 0} {
2508+
if {![info exists file_lists]
2509+
|| ![info exists file_lists($w)]
2510+
|| [llength $file_lists($w)] == 0} {
25092511
set last_clicked {}
25102512
return
25112513
}
@@ -2519,7 +2521,13 @@ proc toggle_or_diff {mode w args} {
25192521
}
25202522
}
25212523
2522-
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2524+
if {![info exists file_lists]
2525+
|| ![info exists file_lists($w)]
2526+
|| [llength $file_lists($w)] < $lno - 1} {
2527+
set path {}
2528+
} else {
2529+
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2530+
}
25232531
if {$path eq {}} {
25242532
set last_clicked {}
25252533
return

0 commit comments

Comments
 (0)