Re: [PATCH 2/2] git-gui: fix applying line/ranges when the selection ends at the begin of a line
- From
Bert Wesarg <bert.wesarg@googlemail.com>
- Date
- Jan 14, 2012, 12:08 UTC
- Message-ID
- <CAKPyHN1CQ4nHDSgsd2862_AugsDR6m1BcZ+rgOkPJr4E6eYaEA@mail.gmail.com>
- In-Reply-To
- <37339be035746797fcec7634e3560ffcd5b26cf3.1326116492.git.bert.wesarg@googlemail.com>
On Mon, Jan 9, 2012 at 14:43, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> Selecting also the trailing newline of a line for staging/unstaging would > have resulted in also staging/unstaging of the next line.
The fix is not complete, this logic should only be applied if we have actually a range. I will send a replacement patch in the coming days.
Bert
Show 28 quoted lines
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
> 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. <lno>.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
>