Skip to content

Commit 6cf9149

Browse files
trastgitster
authored andcommitted
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>
1 parent 7dde4bb commit 6cf9149

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

builtin-apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)
919919
newlines++;
920920
continue;
921921
case '\\':
922-
break;
922+
continue;
923923
case '@':
924924
ret = size < 3 || prefixcmp(line, "@@ ");
925925
break;

t/t4100-apply-stat.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ mode
3333
non git (1)
3434
non git (2)
3535
non git (3)
36+
incomplete (1)
37+
incomplete (2)
3638
EOF
3739

3840
test_done

t/t4100/t-apply-8.expect

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)