git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 4/4] apply: detect and mark whitespace errors in context lines when fixing
Date: Thu, 22 Jan 2015 14:58:25 -0800	[thread overview]
Message-ID: <1421967505-16879-5-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1421967505-16879-1-git-send-email-gitster@pobox.com>

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>
---
 builtin/apply.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index e895340..a51a1b0 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -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 &&
-- 
2.3.0-rc1-116-g84c5016

  parent reply	other threads:[~2015-01-22 22:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 18:20 Segmentation fault in git apply Michael Blume
2015-01-14 18:40 ` Michael Blume
2015-01-14 18:44   ` Michael Blume
2015-01-14 18:48     ` Michael Blume
2015-01-14 18:58       ` Michael Blume
2015-01-14 19:09         ` Michael Blume
2015-01-15  8:26           ` Kyle J. McKay
2015-01-15  9:10             ` Kyle J. McKay
2015-01-16 19:58               ` Junio C Hamano
2015-01-16 23:54                 ` [PATCH] apply: count the size of postimage correctly Junio C Hamano
2015-01-18 10:49                   ` [PATCH] test: add git apply whitespace expansion tests Kyle J. McKay
2015-01-18 22:11                     ` Junio C Hamano
2015-01-19  3:54                       ` Kyle J. McKay
2015-01-21 22:33                         ` Junio C Hamano
2015-01-22  6:55                           ` Kyle J. McKay
2015-01-22 19:23                             ` Junio C Hamano
2015-01-23  0:12                               ` Kyle J. McKay
2015-01-22 22:58                           ` [PATCH v2 0/4] apply --whitespace=fix buffer corruption fix Junio C Hamano
2015-01-22 22:58                             ` [PATCH v2 1/4] apply.c: typofix Junio C Hamano
2015-01-22 23:17                               ` Stefan Beller
2015-01-22 23:42                                 ` Junio C Hamano
2015-01-22 23:48                                   ` Stefan Beller
2015-01-22 22:58                             ` [PATCH v2 2/4] apply: make update_pre_post_images() sanity check the given postlen Junio C Hamano
2015-01-22 22:58                             ` [PATCH v2 3/4] apply: count the size of postimage correctly Junio C Hamano
2015-01-22 22:58                             ` Junio C Hamano [this message]
2015-01-14 18:50 ` Segmentation fault in git apply Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421967505-16879-5-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).