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

[PATCH v2 4/4] apply: detect and mark whitespace errors in context lines when fixing

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2015, 22:58 UTC
Message-ID
<1421967505-16879-5-git-send-email-gitster@pobox.com>
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
Previous: Junio C HamanoNext: Junio C Hamano
Message 25 of 26 in “Segmentation fault in git apply”
  1. Michael BlumeJan 14, 2015
  2. Michael BlumeJan 14, 2015
  3. Michael BlumeJan 14, 2015
  4. Michael BlumeJan 14, 2015
  5. Michael BlumeJan 14, 2015
  6. Michael BlumeJan 14, 2015
  7. Kyle J. McKayJan 15, 2015
  8. Kyle J. McKayJan 15, 2015
  9. Junio C HamanoJan 16, 2015
  10. apply: count the size of postimage correctlyJunio C Hamano, Jan 16, 2015
  11. test: add git apply whitespace expansion testsKyle J. McKay, Jan 18, 2015
  12. Junio C HamanoJan 18, 2015
  13. Kyle J. McKayJan 19, 2015
  14. Junio C HamanoJan 21, 2015
  15. Kyle J. McKayJan 22, 2015
  16. Junio C HamanoJan 22, 2015
  17. Kyle J. McKayJan 23, 2015
  18. 0/4 apply --whitespace=fix buffer corruption fixJunio C Hamano, Jan 22, 2015
  19. 1/4 apply.c: typofixJunio C Hamano, Jan 22, 2015
  20. Stefan BellerJan 22, 2015
  21. Junio C HamanoJan 22, 2015
  22. Stefan BellerJan 22, 2015
  23. 2/4 apply: make update_pre_post_images() sanity check the given postlenJunio C Hamano, Jan 22, 2015
  24. 3/4 apply: count the size of postimage correctlyJunio C Hamano, Jan 22, 2015
  25. 4/4 apply: detect and mark whitespace errors in context lines when fixingJunio C Hamano, Jan 22, 2015
  26. Junio C HamanoJan 14, 2015

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.