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 Oct 17, 2017
1 parent c329dc9 commit c707399
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 @@ -2516,7 +2516,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 @@ -2530,7 +2532,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 c707399

Please sign in to comment.