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> ---
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(-)
Show changes to builtin-apply.c +1 −1
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