Skip to content

Commit 02a5f25

Browse files
committed
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
2 parents 36438dc + 76756d6 commit 02a5f25

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

git-gui/git-gui.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2501,9 +2501,28 @@ proc toggle_or_diff {mode w args} {
25012501
set pos [split [$w index @$x,$y] .]
25022502
foreach {lno col} $pos break
25032503
} else {
2504+
if {$mode eq "toggle"} {
2505+
if {$w eq $ui_workdir} {
2506+
do_add_selection
2507+
set last_clicked {}
2508+
return
2509+
}
2510+
if {$w eq $ui_index} {
2511+
do_unstage_selection
2512+
set last_clicked {}
2513+
return
2514+
}
2515+
}
2516+
25042517
if {$last_clicked ne {}} {
25052518
set lno [lindex $last_clicked 1]
25062519
} else {
2520+
if {![info exists file_lists]
2521+
|| ![info exists file_lists($w)]
2522+
|| [llength $file_lists($w)] == 0} {
2523+
set last_clicked {}
2524+
return
2525+
}
25072526
set lno [expr {int([lindex [$w tag ranges in_diff] 0])}]
25082527
}
25092528
if {$mode eq "toggle"} {
@@ -2514,7 +2533,13 @@ proc toggle_or_diff {mode w args} {
25142533
}
25152534
}
25162535
2517-
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2536+
if {![info exists file_lists]
2537+
|| ![info exists file_lists($w)]
2538+
|| [llength $file_lists($w)] < $lno - 1} {
2539+
set path {}
2540+
} else {
2541+
set path [lindex $file_lists($w) [expr {$lno - 1}]]
2542+
}
25182543
if {$path eq {}} {
25192544
set last_clicked {}
25202545
return

git-gui/lib/diff.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {
698698
set hh [$ui_diff get $i_l "$i_l + 1 lines"]
699699
set hh [lindex [split $hh ,] 0]
700700
set hln [lindex [split $hh -] 1]
701+
set hln [lindex [split $hln " "] 0]
701702

702703
# There is a special situation to take care of. Consider this
703704
# hunk:

0 commit comments

Comments
 (0)