Skip to content

Commit 1fcd24d

Browse files
hvoigtpatthoyts
authored andcommitted
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 <[email protected]> Signed-off-by: Heiko Voigt <[email protected]> Signed-off-by: Pat Thoyts <[email protected]>
1 parent 60468d6 commit 1fcd24d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/diff.tcl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,15 @@ proc apply_range_or_line {x y} {
764764
# context line
765765
set ln [$ui_diff get $i_l $next_l]
766766
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+
}
769776
set pre_context {}
770777
} elseif {$c1 eq $to_context} {
771778
# turn change line into context line

0 commit comments

Comments
 (0)