Skip to content

Commit c227a5f

Browse files
committed
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 git-for-windows#1075 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7cd5ed9 commit c227a5f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

git-gui/git-gui.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,9 @@ proc toggle_or_diff {mode w args} {
25042504
if {$last_clicked ne {}} {
25052505
set lno [lindex $last_clicked 1]
25062506
} else {
2507-
if {[llength $file_lists($w)] == 0} {
2507+
if {![info exists file_lists]
2508+
|| ![info exists file_lists($w)]
2509+
|| [llength $file_lists($w)] == 0} {
25082510
set last_clicked {}
25092511
return
25102512
}
@@ -2518,7 +2520,13 @@ proc toggle_or_diff {mode w args} {
25182520
}
25192521
}
25202522
2521-
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2523+
if {![info exists file_lists]
2524+
|| ![info exists file_lists($w)]
2525+
|| [llength $file_lists($w)] < $lno - 1} {
2526+
set path {}
2527+
} else {
2528+
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2529+
}
25222530
if {$path eq {}} {
25232531
set last_clicked {}
25242532
return

0 commit comments

Comments
 (0)