git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Thomas Rast <trast@student.ethz.ch>
Date
Jul 4, 2008, 19:10 UTC
Message-ID
<1215198614-22148-1-git-send-email-trast@student.ethz.ch>

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(-)
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
Next: Johannes Schindelin
Message 1 of 2 in “Fix apply --recount handling of no-EOL line”
  1. Fix apply --recount handling of no-EOL lineThomas Rast, Jul 4, 2008
  2. Johannes SchindelinJul 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.