summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Voigt <hvoigt@hvoigt.net>2013-05-09 18:30:02 +0200
committerPat Thoyts <patthoyts@users.sourceforge.net>2013-05-16 23:40:59 +0100
commit1fcd24d04358ea10c296a414e2b93f3714adca4b (patch)
treed6613fa710989529cb9331cb7bc381b5048d07fb
parent60468d6c893a6ad8795869d979a601e47cb90732 (diff)
downloadgit-1fcd24d04358ea10c296a414e2b93f3714adca4b.tar.gz
git-gui: allow "\ No newline at end of file" for linewise staging
Counting of lines did not skip this line when generating the hunk header. Acked-by: Tobias Preuss <tobias.preuss@googlemail.com> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
-rw-r--r--lib/diff.tcl11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl
index ec4405567a..30d9a79776 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {
# context line
set ln [$ui_diff get $i_l $next_l]
set patch "$patch$pre_context$ln"
- set n [expr $n+1]
- set m [expr $m+1]
+ # Skip the "\ No newline at end of
+ # file". Depending on the locale setting
+ # we don't know what this line looks
+ # like exactly. The only thing we do
+ # know is that it starts with "\ "
+ if {![string match {\\ *} $ln]} {
+ set n [expr $n+1]
+ set m [expr $m+1]
+ }
set pre_context {}
} elseif {$c1 eq $to_context} {
# turn change line into context line