diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-01-09 11:07:03 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-01-09 11:07:03 -0800 |
commit | 02a5f25d956be187bc0f47b20671a76419aebb83 (patch) | |
tree | 2fa418b19ec2daf764d509589f3d88c14edf52da | |
parent | 36438dc19dd2a305dddebd44bf7a65f1a220075b (diff) | |
parent | 76756d67061076c046973bff2089ad49f5dc2eb6 (diff) | |
download | git-02a5f25d956be187bc0f47b20671a76419aebb83.tar.gz |
Merge branch 'js/misc-git-gui-stuff' of ../git-gui
* 'js/misc-git-gui-stuff' of ../git-gui:
git-gui: allow Ctrl+T to toggle multiple paths
git-gui: fix exception when trying to stage with empty file list
git-gui: avoid exception upon Ctrl+T in an empty list
git gui: fix staging a second line to a 1-line file
-rwxr-xr-x | git-gui/git-gui.sh | 27 | ||||
-rw-r--r-- | git-gui/lib/diff.tcl | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index ed24aa9d2f..91c00e6489 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -2501,9 +2501,28 @@ proc toggle_or_diff {mode w args} { set pos [split [$w index @$x,$y] .] foreach {lno col} $pos break } else { + if {$mode eq "toggle"} { + if {$w eq $ui_workdir} { + do_add_selection + set last_clicked {} + return + } + if {$w eq $ui_index} { + do_unstage_selection + set last_clicked {} + return + } + } + if {$last_clicked ne {}} { set lno [lindex $last_clicked 1] } else { + if {![info exists file_lists] + || ![info exists file_lists($w)] + || [llength $file_lists($w)] == 0} { + set last_clicked {} + return + } set lno [expr {int([lindex [$w tag ranges in_diff] 0])}] } if {$mode eq "toggle"} { @@ -2514,7 +2533,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 diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl index 4cae10a4c7..68c4a6c736 100644 --- a/git-gui/lib/diff.tcl +++ b/git-gui/lib/diff.tcl @@ -698,6 +698,7 @@ proc apply_range_or_line {x y} { set hh [$ui_diff get $i_l "$i_l + 1 lines"] set hh [lindex [split $hh ,] 0] set hln [lindex [split $hh -] 1] + set hln [lindex [split $hln " "] 0] # There is a special situation to take care of. Consider this # hunk: |