Fix apply --recount handling of no-EOL line
If a patch modifies the last line of a file that previously had no terminating '\n', it looks like -old text \ No newline at end of file +new text Hence, a '\' line does not signal the end of the hunk. This modifies 'git apply --recount' to take this into account. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Jul 4, 2008 at 21:10 UTC
6cf91492d9cd985e1fa65181d99d6d578d4439dc
6 files changed
+29
-1
builtin-apply.c
+1
-1
@@ -919,7 +919,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)
919
newlines++;
920
continue;
921
case '\\':
922
- break;
922
+ continue;
923
case '@':
924
ret = size < 3 || prefixcmp(line, "@@ ");
925
break;
t/t4100-apply-stat.sh
+2
@@ -33,6 +33,8 @@ mode
33
non git (1)
34
non git (2)
35
non git (3)
36
+incomplete (1)
37
+incomplete (2)
38
EOF
39
40
test_done
t/t4100/t-apply-8.expect
new
+2
@@ -0,0 +1,2 @@
1
+ t/t4100-apply-stat.sh | 2 +-
2
+ 1 files changed, 1 insertions(+), 1 deletions(-)
t/t4100/t-apply-8.patch
new
+11
@@ -0,0 +1,11 @@
1
+diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
2
+index be837bb..0798c64 100755
3
+--- a/t/t4100-apply-stat.sh
4
++++ b/t/t4100-apply-stat.sh
5
+@@ -35,4 +35,4 @@ non git (2)
6
+ non git (3)
7
+ EOF
8
+
9
+-test_done
10
++test_done
11
+\ No newline at end of file
t/t4100/t-apply-9.expect
new
+2
@@ -0,0 +1,2 @@
1
+ t/t4100-apply-stat.sh | 2 +-
2
+ 1 files changed, 1 insertions(+), 1 deletions(-)
t/t4100/t-apply-9.patch
new
+11
@@ -0,0 +1,11 @@
1
+diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
2
+index 0798c64..be837bb 100755
3
+--- a/t/t4100-apply-stat.sh
4
++++ b/t/t4100-apply-stat.sh
5
+@@ -35,4 +35,4 @@ non git (2)
6
+ non git (3)
7
+ EOF
8
+
9
+-test_done
10
+\ No newline at end of file
11
++test_done