[PATCH] Fix apply --recount handling of no-EOL line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---

This is just the straightforward fix.  A more elaborate solution might
check if the previous line was a ' ' and '+', and if so, consider the
hunk terminated anyway.

- Thomas

 builtin-apply.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index 194f03b..fb85a5b 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -931,7 +931,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)
 			newlines++;
 			continue;
 		case '\\':
-			break;
+			continue;
 		case '@':
 			ret = size < 3 || prefixcmp(line, "@@ ");
 			break;
-- 
1.5.6.1.330.g2ff03

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux