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

[PATCH] git-apply: do not fix whitespaces on context lines.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 27, 2007, 09:33 UTC
Message-ID
<7vzm70hrma.fsf@assigned-by-dhcp.cox.net>

Internal function apply_line() is called to copy both context lines and added lines to the output buffer, while possibly fixing the whitespace breakages depending on --whitespace=strip settings. However, it did its fix-up on both context lines and added lines.

This resulted in two symptoms:
 (1) The number of lines reported to have been fixed up included
     these context lines.
 (2) However, the lines actually shown were limited to the added
     lines that had whitespace breakages.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-apply.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index abe3538..bec95d6 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1539,7 +1539,8 @@ static int apply_line(char *output, const char *patch, int plen)
 	int need_fix_leading_space = 0;
 	char *buf;
 
-	if ((new_whitespace != strip_whitespace) || !whitespace_error) {
+	if ((new_whitespace != strip_whitespace) || !whitespace_error ||
+	    *patch != '+') {
 		memcpy(output, patch + 1, plen);
 		return plen;
 	}
-- 
1.5.0.2.775.g1a500
Message 1 of 1 in “git-apply: do not fix whitespaces on context lines.”
  1. git-apply: do not fix whitespaces on context lines.Junio C Hamano, Feb 27, 2007

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.