Skip to content

Commit

Permalink
apply: detect and mark whitespace errors in context lines when fixing
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jan 22, 2015
1 parent 407a792 commit 0a80bc9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,9 @@ static int parse_fragment(const char *line, unsigned long size,
if (!deleted && !added)
leading++;
trailing++;
if (!apply_in_reverse &&
ws_error_action == correct_ws_error)
check_whitespace(line, len, patch->ws_rule);
break;
case '-':
if (apply_in_reverse &&
Expand Down

0 comments on commit 0a80bc9

Please sign in to comment.