Skip to contentSkip to conversation

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

PATCH New Junio C Hamano 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-apply: do not fix whitespaces on context lines.

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.

---
 builtin-apply.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
builtin-apply.c +2 -1
index abe3538..bec95d6 100644
@@ -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;
 	}
Signature · 1 line
1.5.0.2.775.g1a500