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>

Heiko Voigt committed May 9, 2013 at 18:30 UTC 1fcd24d04358ea10c296a414e2b93f3714adca4b
1 file changed +9 -2
lib/diff.tcl
+9 -2
@@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {
764 # context line
765 set ln [$ui_diff get $i_l $next_l]
766 set patch "$patch$pre_context$ln"
767 - set n [expr $n+1]
768 - set m [expr $m+1]
767 + # Skip the "\ No newline at end of
768 + # file". Depending on the locale setting
769 + # we don't know what this line looks
770 + # like exactly. The only thing we do
771 + # know is that it starts with "\ "
772 + if {![string match {\\ *} $ln]} {
773 + set n [expr $n+1]
774 + set m [expr $m+1]
775 + }
776 set pre_context {}
777 } elseif {$c1 eq $to_context} {
778 # turn change line into context line