From: Bert Wesarg Date: Mon, 09 Jan 2012 13:43:18 GMT Subject: [PATCH 2/2] git-gui: fix applying line/ranges when the selection ends at the begin of a line Message-ID: <37339be035746797fcec7634e3560ffcd5b26cf3.1326116492.git.bert.wesarg@googlemail.com> In-Reply-To: Selecting also the trailing newline of a line for staging/unstaging would have resulted in also staging/unstaging of the next line. Signed-off-by: Bert Wesarg --- lib/diff.tcl | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/lib/diff.tcl b/lib/diff.tcl index 63f8742..a750ea7 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -632,7 +632,13 @@ proc apply_range_or_line {x y} { } set first_l [$ui_diff index "$first linestart"] - set last_l [$ui_diff index "$last lineend"] + # don't include the next line if $last points to the start of a line + # ie. .0 + if {[lindex [split $last .] 1] == 0} { + set last_l [$ui_diff index "$last -1 line lineend"] + } else { + set last_l [$ui_diff index "$last lineend"] + } if {$current_diff_path eq {} || $current_diff_header eq {}} return if {![lock_index apply_hunk]} return -- 1.7.8.1.873.gfea665