Merge tag 'gitgui-0.18.0' of git://repo.or.cz/git-gui
[gitweb.git] / git-gui / lib / diff.tcl
index ec4405567a9b86a9bfd8bf50815b3c9c14e2df40..30d9a797769b49cdd9d42fba925d8fa8ecbffb21 100644 (file)
@@ -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