Skip to content

Commit

Permalink
git-gui: fix exception when trying to stage with empty file list
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Nov 29, 2017
1 parent 4ab2825 commit 5ef74eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,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
}
Expand All @@ -2529,7 +2531,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
Expand Down

0 comments on commit 5ef74eb

Please sign in to comment.