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

[PATCH v2 0/4] apply --whitespace=fix buffer corruption fix

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 22, 2015, 22:58 UTC
Message-ID
<1421967505-16879-1-git-send-email-gitster@pobox.com>
In-Reply-To
<xmqq1tmnwypp.fsf@gitster.dls.corp.google.com>

"git apply --whitespace=fix" used to be able to assume that fixing errors will always reduce the size by e.g. stripping whitespaces at the end of lines or collapsing runs of spaces into tabs at the beginning of lines. An update to accomodate fixes that lengthens the result by e.g. expanding leading tabs into spaces were made long time ago but the logic miscounted the necessary space after such whitespace fixes, leading to either under-allocation or over-usage of already allocated space.

The second patch in this series is to illustrate this with a runtime sanity-check to protect us from future breakage (this is a reroll of a "how about this" weatherbaloon patch $gmane/262579, with Kyle's test script).

The third patch corrects the under-counting and makes the new test pass.

The fourth patch makes us report the fact that we corrected whitespace errors in the common-context part. When asked to correct whitespace errors, and given a patch that has whitespace errors in the common context (i.e. the lines prefixed with " ") either in the patch itself or the corresponding part in the file we are patching, we have been correcting the whitespace errors "while at it" since around c1beba5b (git-apply --whitespace=fix: fix whitespace fuzz introduced by previous run, 2008-01-30), but we were not reporting that we saw a need to fix them.

This is not about the "buffer corruption fix", which is the primary focus of this series, but it is here because it is related to whitespace fix.

Junio C Hamano (4):
  typofix
  apply: make update_pre_post_images() sanity check the given postlen
  apply: count the size of postimage correctly
  apply: detect and mark whitespace errors in context lines when fixing
 builtin/apply.c               |  34 ++++++++++--
 t/t4138-apply-ws-expansion.sh | 121 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 152 insertions(+), 3 deletions(-)
 create mode 100755 t/t4138-apply-ws-expansion.sh
-- 
2.3.0-rc1-116-g84c5016
Previous: Kyle J. McKayNext: Junio C Hamano
Message 18 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.