Skip to content

Commit 0a80bc9

Browse files
committed
apply: detect and mark whitespace errors in context lines when fixing
When the incoming patch has whitespace errors in a common context line (i.e. a line that is expected to be found and is not modified by the patch), "apply --whitespace=fix" corrects the whitespace errors the line has, in addition to the whitespace error on a line that is updated by the patch. However, we did not count and report that we fixed whitespace errors on such lines. [jc: This is iffy. What if the whitespace error has been fixed in the target since the patch was written? A common context line we see in the patch has errors, and it matches a line in the target that has the errors already corrected, resulting in no change, which we may not want to count after all. On the other hand, we are reporting whitespace errors _in_ the incoming patch, so...] Signed-off-by: Junio C Hamano <[email protected]>
1 parent 407a792 commit 0a80bc9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/apply.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,9 @@ static int parse_fragment(const char *line, unsigned long size,
16061606
if (!deleted && !added)
16071607
leading++;
16081608
trailing++;
1609+
if (!apply_in_reverse &&
1610+
ws_error_action == correct_ws_error)
1611+
check_whitespace(line, len, patch->ws_rule);
16091612
break;
16101613
case '-':
16111614
if (apply_in_reverse &&

0 commit comments

Comments
 (0)