Skip to content

Commit a2441bc

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 #1075 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5bf0cf8 commit a2441bc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

git-gui/git-gui.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,9 @@ proc toggle_or_diff {mode w args} {
25162516
if {$last_clicked ne {}} {
25172517
set lno [lindex $last_clicked 1]
25182518
} else {
2519-
if {[llength $file_lists($w)] == 0} {
2519+
if {![info exists file_lists]
2520+
|| ![info exists file_lists($w)]
2521+
|| [llength $file_lists($w)] == 0} {
25202522
set last_clicked {}
25212523
return
25222524
}
@@ -2530,7 +2532,13 @@ proc toggle_or_diff {mode w args} {
25302532
}
25312533
}
25322534
2533-
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2535+
if {![info exists file_lists]
2536+
|| ![info exists file_lists($w)]
2537+
|| [llength $file_lists($w)] < $lno - 1} {
2538+
set path {}
2539+
} else {
2540+
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2541+
}
25342542
if {$path eq {}} {
25352543
set last_clicked {}
25362544
return

0 commit comments

Comments
 (0)