{"thread":{"id":"14291","subject":"[PATCH] Fix apply --recount handling of no-EOL line","startedAt":"2008-07-04T19:10:14Z","lastAt":"2008-07-04T19:34:17Z","messageCount":2,"participants":["Thomas Rast","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"82248","messageId":"1215198614-22148-1-git-send-email-trast@student.ethz.ch","threadId":"14291","inReplyTo":null,"subject":"[PATCH] Fix apply --recount handling of no-EOL line","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2008-07-04T19:10:14Z","receivedAt":"2008-07-04T19:10:14Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"If a patch modifies the last line of a file that previously had no\nterminating '\\n', it looks like\n\n-old text\n\\ No newline at end of file\n+new text\n\nHence, a '\\' line does not signal the end of the hunk.  This modifies\n'git apply --recount' to take this into account.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nThis is just the straightforward fix.  A more elaborate solution might\ncheck if the previous line was a ' ' and '+', and if so, consider the\nhunk terminated anyway.\n\n- Thomas\n\n builtin-apply.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 194f03b..fb85a5b 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -931,7 +931,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)\n \t\t\tnewlines++;\n \t\t\tcontinue;\n \t\tcase '\\\\':\n-\t\t\tbreak;\n+\t\t\tcontinue;\n \t\tcase '@':\n \t\t\tret = size < 3 || prefixcmp(line, \"@@ \");\n \t\t\tbreak;\n-- \n1.5.6.1.330.g2ff03\n"},{"id":"82251","messageId":"alpine.DEB.1.00.0807042034040.9925@racer","threadId":"14291","inReplyTo":"1215198614-22148-1-git-send-email-trast@student.ethz.ch","subject":"Re: [PATCH] Fix apply --recount handling of no-EOL line","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-04T19:34:17Z","receivedAt":"2008-07-04T19:34:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 4 Jul 2008, Thomas Rast wrote:\n\n> If a patch modifies the last line of a file that previously had no\n> terminating '\\n', it looks like\n> \n> -old text\n> \\ No newline at end of file\n> +new text\n\nOh!\n\n> Hence, a '\\' line does not signal the end of the hunk.  This modifies\n> 'git apply --recount' to take this into account.\n> \n> Signed-off-by: Thomas Rast <trast@student.ethz.ch>\n\nACK!\n\nCiao,\nDscho\n"}]}