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 https://github.com/git-for-windows/git/issues/1075 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jan 9, 2018 at 15:33 UTC
2cd9179c14dc830247a84a602caac42afa0fcf8f
1 file changed
+10
-2
git-gui.sh
+10
-2
@@ -2505,7 +2505,9 @@ proc toggle_or_diff {mode w args} {
2505
if {$last_clicked ne {}} {
2506
set lno [lindex $last_clicked 1]
2507
} 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} {
2511
set last_clicked {}
2512
return
2513
}
@@ -2519,7 +2521,13 @@ proc toggle_or_diff {mode w args} {
2521
}
2522
}
2523
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
+ }
2531
if {$path eq {}} {
2532
set last_clicked {}
2533
return